diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-01-17 00:20:16 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2019-01-17 00:20:16 -0800 |
| commit | 84292ad89070f1994ed09b59c8a693216a40cd89 (patch) | |
| tree | 267e6ae05f87d95a432f6cd112c46189c9a70ce0 /shared-bindings/displayio/FourWire.c | |
| parent | 05d8885a1ab959fabdbb77f99408b2e7dc78b97c (diff) | |
External fourwire works and blinka splash after
Diffstat (limited to 'shared-bindings/displayio/FourWire.c')
| -rw-r--r-- | shared-bindings/displayio/FourWire.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index 674d1c900..9833fbc64 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -69,18 +69,21 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ if (command == mp_const_none || chip_select == mp_const_none) { mp_raise_ValueError(translate("Command and chip_select required")); } + assert_pin_free(command); + assert_pin_free(chip_select); + assert_pin_free(reset); - displayio_fourwire_obj_t* self; + displayio_fourwire_obj_t* self = NULL; mp_obj_t spi = args[ARG_spi_bus].u_obj; - if (board_spi() == spi && primary_display.bus_type == NULL) { - self = &primary_display.fourwire_bus; - primary_display.bus_type = &displayio_fourwire_type; - } else { - // TODO(tannewt): Always check pin free. For now we ignore the primary display. - assert_pin_free(command); - assert_pin_free(chip_select); - assert_pin_free(reset); - self = m_new_obj(displayio_fourwire_obj_t); + for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { + if (displays[i].fourwire_bus.base.type== NULL) { + self = &displays[i].fourwire_bus; + self->base.type = &displayio_fourwire_type; + break; + } + } + if (self == NULL) { + mp_raise_RuntimeError(translate("Display bus limit reached")); } common_hal_displayio_fourwire_construct(self, |
