Skip to content

Fixed I2CDisplay reset issue #2277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions shared-module/displayio/I2CDisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,29 @@
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);
}

// Write to the device and return 0 on success or an appropriate error code from mperrno.h
// Write to the device and return 0 on success or an appropriate error code from mperrno.h
self->bus = i2c;
common_hal_busio_i2c_never_reset(self->bus);
// Our object is statically allocated off the heap so make sure the bus object lives to the end
// of the heap as well.
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) {
Expand Down