Merge pull request #2277 from makermelissa/master

Fixed I2CDisplay reset issue
This commit is contained in:
Melissa LeBlanc-Williams 2019-11-08 12:57:48 -08:00 committed by GitHub
commit 93cdf51b7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,6 +42,16 @@
void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
busio_i2c_obj_t* i2c, uint16_t device_address, const mcu_pin_obj_t* reset) {
// Reset the display before probing
self->reset.base.type = &mp_type_NoneType;
if (reset != NULL) {
self->reset.base.type = &digitalio_digitalinout_type;
common_hal_digitalio_digitalinout_construct(&self->reset, reset);
common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
never_reset_pin_number(reset->number);
common_hal_displayio_i2cdisplay_reset(self);
}
// Probe the bus to see if a device acknowledges the given address.
if (!common_hal_busio_i2c_probe(i2c, device_address)) {
mp_raise_ValueError_varg(translate("Unable to find I2C Display at %x"), device_address);
@ -55,15 +65,6 @@ void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
gc_never_free(self->bus);
self->address = device_address;
self->reset.base.type = &mp_type_NoneType;
if (reset != NULL) {
self->reset.base.type = &digitalio_digitalinout_type;
common_hal_digitalio_digitalinout_construct(&self->reset, reset);
common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
never_reset_pin_number(reset->number);
common_hal_displayio_i2cdisplay_reset(self);
}
}
void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t* self) {