summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-08-21 11:49:49 -0700
committerScott Shawcroft <scott@tannewt.org>2019-08-22 14:23:33 -0700
commit3a98de12368a63de1538f61da7690e9fa230b540 (patch)
tree52f304d2cf5168d14277b23510f33f5d01e430ab /shared-module
parent24b30965c41ae32b82c56b166f3287cf2c14f419 (diff)
Add reset() to display busses to detect whether it works
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/displayio/FourWire.c8
-rw-r--r--shared-module/displayio/I2CDisplay.c10
-rw-r--r--shared-module/displayio/display_core.h2
3 files changed, 15 insertions, 5 deletions
diff --git a/shared-module/displayio/FourWire.c b/shared-module/displayio/FourWire.c
index 64ad80665..7294e9772 100644
--- a/shared-module/displayio/FourWire.c
+++ b/shared-module/displayio/FourWire.c
@@ -55,7 +55,9 @@ void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self,
common_hal_digitalio_digitalinout_construct(&self->chip_select, chip_select);
common_hal_digitalio_digitalinout_switch_to_output(&self->chip_select, true, DRIVE_MODE_PUSH_PULL);
+ 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);
@@ -76,12 +78,16 @@ void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t* self) {
reset_pin_number(self->reset.pin->number);
}
-void common_hal_displayio_fourwire_reset(mp_obj_t obj) {
+bool common_hal_displayio_fourwire_reset(mp_obj_t obj) {
displayio_fourwire_obj_t* self = MP_OBJ_TO_PTR(obj);
+ if (self->reset.base.type == &mp_type_NoneType) {
+ return false;
+ }
common_hal_digitalio_digitalinout_set_value(&self->reset, false);
common_hal_time_delay_ms(1);
common_hal_digitalio_digitalinout_set_value(&self->reset, true);
common_hal_time_delay_ms(1);
+ return true;
}
bool common_hal_displayio_fourwire_bus_free(mp_obj_t obj) {
diff --git a/shared-module/displayio/I2CDisplay.c b/shared-module/displayio/I2CDisplay.c
index 23ebc0889..95830ba0e 100644
--- a/shared-module/displayio/I2CDisplay.c
+++ b/shared-module/displayio/I2CDisplay.c
@@ -55,7 +55,9 @@ void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
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);
@@ -71,16 +73,18 @@ void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t* self) {
reset_pin_number(self->reset.pin->number);
}
-
-void common_hal_displayio_i2cdisplay_reset(mp_obj_t obj) {
+bool common_hal_displayio_i2cdisplay_reset(mp_obj_t obj) {
displayio_i2cdisplay_obj_t* self = MP_OBJ_TO_PTR(obj);
+ if (self->reset.base.type == &mp_type_NoneType) {
+ return false;
+ }
common_hal_digitalio_digitalinout_set_value(&self->reset, false);
common_hal_mcu_delay_us(1);
common_hal_digitalio_digitalinout_set_value(&self->reset, true);
+ return true;
}
-
bool common_hal_displayio_i2cdisplay_bus_free(mp_obj_t obj) {
displayio_i2cdisplay_obj_t* self = MP_OBJ_TO_PTR(obj);
if (!common_hal_busio_i2c_try_lock(self->bus)) {
diff --git a/shared-module/displayio/display_core.h b/shared-module/displayio/display_core.h
index c837ce913..b1a412883 100644
--- a/shared-module/displayio/display_core.h
+++ b/shared-module/displayio/display_core.h
@@ -33,7 +33,7 @@
#define NO_COMMAND 0x100
-typedef void (*display_bus_bus_reset)(mp_obj_t bus);
+typedef bool (*display_bus_bus_reset)(mp_obj_t bus);
typedef bool (*display_bus_bus_free)(mp_obj_t bus);
typedef bool (*display_bus_begin_transaction)(mp_obj_t bus);
typedef void (*display_bus_send)(mp_obj_t bus, bool command, bool toggle_every_byte, uint8_t *data, uint32_t data_length);