diff --git a/ports/atmel-samd/boards/pyportal/board.c b/ports/atmel-samd/boards/pyportal/board.c index 166b14fd5b..b46b176afc 100644 --- a/ports/atmel-samd/boards/pyportal/board.c +++ b/ports/atmel-samd/boards/pyportal/board.c @@ -61,9 +61,9 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_parallelbus_obj_t *bus = &displays[0].parallel_bus; - bus->base.type = &displayio_parallelbus_type; - common_hal_displayio_parallelbus_construct(bus, + paralleldisplay_parallelbus_obj_t *bus = &displays[0].parallel_bus; + bus->base.type = ¶lleldisplay_parallelbus_type; + common_hal_paralleldisplay_parallelbus_construct(bus, &pin_PA16, // Data0 &pin_PB05, // Command or data &pin_PB06, // Chip select diff --git a/ports/atmel-samd/boards/pyportal_titano/board.c b/ports/atmel-samd/boards/pyportal_titano/board.c index 6c05e47d92..138f94ebc8 100644 --- a/ports/atmel-samd/boards/pyportal_titano/board.c +++ b/ports/atmel-samd/boards/pyportal_titano/board.c @@ -78,9 +78,9 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_parallelbus_obj_t *bus = &displays[0].parallel_bus; - bus->base.type = &displayio_parallelbus_type; - common_hal_displayio_parallelbus_construct(bus, + paralleldisplay_parallelbus_obj_t *bus = &displays[0].parallel_bus; + bus->base.type = ¶lleldisplay_parallelbus_type; + common_hal_paralleldisplay_parallelbus_construct(bus, &pin_PA16, // Data0 &pin_PB05, // Command or data &pin_PB06, // Chip select diff --git a/ports/atmel-samd/common-hal/displayio/ParallelBus.c b/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c similarity index 85% rename from ports/atmel-samd/common-hal/displayio/ParallelBus.c rename to ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c index e5575f8dc2..490c595e74 100644 --- a/ports/atmel-samd/common-hal/displayio/ParallelBus.c +++ b/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include @@ -33,7 +33,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/__init__.h" -void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *self, +void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, const mcu_pin_obj_t *data0, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *write, const mcu_pin_obj_t *read, const mcu_pin_obj_t *reset, uint32_t frequency) { @@ -83,7 +83,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *sel 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_parallelbus_reset(self); + common_hal_paralleldisplay_parallelbus_reset(self); } never_reset_pin_number(command->number); @@ -95,7 +95,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *sel } } -void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) { +void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { for (uint8_t i = 0; i < 8; i++) { reset_pin_number(self->data0_pin + i); } @@ -107,8 +107,8 @@ void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) reset_pin_number(self->reset.pin->number); } -bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->reset.base.type == &mp_type_NoneType) { return false; } @@ -119,19 +119,19 @@ bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { return true; } -bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { return true; } -bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); return true; } -void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA); uint32_t *clear_write = (uint32_t *)&self->write_group->OUTCLR.reg; uint32_t *set_write = (uint32_t *)&self->write_group->OUTSET.reg; @@ -143,7 +143,7 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt } } -void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, true); } diff --git a/ports/atmel-samd/common-hal/displayio/ParallelBus.h b/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.h similarity index 96% rename from ports/atmel-samd/common-hal/displayio/ParallelBus.h rename to ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.h index ee19caddf6..4b6ec64b11 100644 --- a/ports/atmel-samd/common-hal/displayio/ParallelBus.h +++ b/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_PARALLELBUS_H -#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H #include "common-hal/digitalio/DigitalInOut.h" @@ -40,6 +40,6 @@ typedef struct { uint8_t data0_pin; PortGroup *write_group; uint32_t write_mask; -} displayio_parallelbus_obj_t; +} paralleldisplay_parallelbus_obj_t; -#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.c b/ports/esp32s2/common-hal/paralleldisplay/ParallelBus.c similarity index 90% rename from ports/esp32s2/common-hal/displayio/ParallelBus.c rename to ports/esp32s2/common-hal/paralleldisplay/ParallelBus.c index cbe093164f..befd836247 100644 --- a/ports/esp32s2/common-hal/displayio/ParallelBus.c +++ b/ports/esp32s2/common-hal/paralleldisplay/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include @@ -38,7 +38,7 @@ * - data0 pin must be byte aligned */ -void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *self, +void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, const mcu_pin_obj_t *data0, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *write, const mcu_pin_obj_t *read, const mcu_pin_obj_t *reset, uint32_t frequency) { @@ -120,7 +120,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *sel 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_parallelbus_reset(self); + common_hal_paralleldisplay_parallelbus_reset(self); } never_reset_pin_number(command->number); @@ -133,7 +133,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *sel } -void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) { +void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { /* SNIP - same as from SAMD and NRF ports */ for (uint8_t i = 0; i < 8; i++) { reset_pin_number(self->data0_pin + i); @@ -146,9 +146,9 @@ void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) reset_pin_number(self->reset.pin->number); } -bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { /* SNIP - same as from SAMD and NRF ports */ - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->reset.base.type == &mp_type_NoneType) { return false; } @@ -160,21 +160,21 @@ bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { } -bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { /* SNIP - same as from SAMD and NRF ports */ return true; } -bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { /* SNIP - same as from SAMD and NRF ports */ - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); return true; } -void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA); uint32_t *clear_write = self->write_clear_register; @@ -220,8 +220,8 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt } -void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) { +void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { /* SNIP - same as from SAMD and NRF ports */ - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, true); } diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.h b/ports/esp32s2/common-hal/paralleldisplay/ParallelBus.h similarity index 91% rename from ports/esp32s2/common-hal/displayio/ParallelBus.h rename to ports/esp32s2/common-hal/paralleldisplay/ParallelBus.h index 59eb64f34d..adf5d6226f 100644 --- a/ports/esp32s2/common-hal/displayio/ParallelBus.h +++ b/ports/esp32s2/common-hal/paralleldisplay/ParallelBus.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELBUS_H -#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H #include "common-hal/digitalio/DigitalInOut.h" @@ -42,6 +42,6 @@ typedef struct { uint32_t *write_set_register; // pointer to the write group for setting the write bit to latch the data on the LCD uint32_t *write_clear_register; // pointer to the write group for clearing the write bit to latch the data on the LCD uint32_t write_mask; // bit mask for the single bit for the write pin register -} displayio_parallelbus_obj_t; +} paralleldisplay_parallelbus_obj_t; -#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H diff --git a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.c b/ports/mimxrt10xx/common-hal/paralleldisplay/ParallelBus.c similarity index 74% rename from ports/mimxrt10xx/common-hal/displayio/ParallelBus.c rename to ports/mimxrt10xx/common-hal/paralleldisplay/ParallelBus.c index f7889c70f4..6d0c8a9476 100644 --- a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.c +++ b/ports/mimxrt10xx/common-hal/paralleldisplay/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include @@ -33,35 +33,35 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/__init__.h" -void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *self, +void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, const mcu_pin_obj_t *data0, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *write, const mcu_pin_obj_t *read, const mcu_pin_obj_t *reset, uint32_t frequency) { mp_raise_NotImplementedError(translate("ParallelBus not yet supported")); } -void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) { +void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { } -bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { return false; } -bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { return false; } -bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { return false; } -void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { } -void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) { +void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { } diff --git a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.h b/ports/mimxrt10xx/common-hal/paralleldisplay/ParallelBus.h similarity index 95% rename from ports/mimxrt10xx/common-hal/displayio/ParallelBus.h rename to ports/mimxrt10xx/common-hal/paralleldisplay/ParallelBus.h index 845e44df06..8034e1132c 100644 --- a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.h +++ b/ports/mimxrt10xx/common-hal/paralleldisplay/ParallelBus.h @@ -24,13 +24,13 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELBUS_H -#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H #include "common-hal/digitalio/DigitalInOut.h" typedef struct { mp_obj_base_t base; -} displayio_parallelbus_obj_t; +} paralleldisplay_parallelbus_obj_t; -#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H diff --git a/ports/nrf/common-hal/displayio/ParallelBus.c b/ports/nrf/common-hal/paralleldisplay/ParallelBus.c similarity index 85% rename from ports/nrf/common-hal/displayio/ParallelBus.c rename to ports/nrf/common-hal/paralleldisplay/ParallelBus.c index 7e0aea0d63..6f84ceb214 100644 --- a/ports/nrf/common-hal/displayio/ParallelBus.c +++ b/ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include @@ -33,7 +33,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/__init__.h" -void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *self, +void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, const mcu_pin_obj_t *data0, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *write, const mcu_pin_obj_t *read, const mcu_pin_obj_t *reset, uint32_t frequency) { @@ -94,7 +94,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *sel 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_parallelbus_reset(self); + common_hal_paralleldisplay_parallelbus_reset(self); } never_reset_pin_number(command->number); @@ -106,7 +106,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *sel } } -void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) { +void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { for (uint8_t i = 0; i < 8; i++) { reset_pin_number(self->data0_pin + i); } @@ -118,8 +118,8 @@ void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) reset_pin_number(self->reset.pin->number); } -bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->reset.base.type == &mp_type_NoneType) { return false; } @@ -130,20 +130,20 @@ bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { return true; } -bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { return true; } -bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); return true; } // This ignores chip_select behaviour because data is clocked in by the write line toggling. -void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA); uint32_t *clear_write = (uint32_t *)&self->write_group->OUTCLR; uint32_t *set_write = (uint32_t *)&self->write_group->OUTSET; @@ -155,7 +155,7 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt } } -void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, true); } diff --git a/ports/nrf/common-hal/displayio/ParallelBus.h b/ports/nrf/common-hal/paralleldisplay/ParallelBus.h similarity index 87% rename from ports/nrf/common-hal/displayio/ParallelBus.h rename to ports/nrf/common-hal/paralleldisplay/ParallelBus.h index 30a0c7e61e..3a3f71e3c9 100644 --- a/ports/nrf/common-hal/displayio/ParallelBus.h +++ b/ports/nrf/common-hal/paralleldisplay/ParallelBus.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_DISPLAYIO_PARALLELBUS_H -#define MICROPY_INCLUDED_NRF_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H #include "common-hal/digitalio/DigitalInOut.h" @@ -40,6 +40,6 @@ typedef struct { uint8_t data0_pin; NRF_GPIO_Type *write_group; uint32_t write_mask; -} displayio_parallelbus_obj_t; +} paralleldisplay_parallelbus_obj_t; -#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H diff --git a/ports/raspberrypi/common-hal/displayio/ParallelBus.c b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c similarity index 85% rename from ports/raspberrypi/common-hal/displayio/ParallelBus.c rename to ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c index 93477e2453..9971474042 100644 --- a/ports/raspberrypi/common-hal/displayio/ParallelBus.c +++ b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include @@ -43,7 +43,7 @@ static const uint16_t parallel_program[] = { // .wrap }; -void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *self, +void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, const mcu_pin_obj_t *data0, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *write, const mcu_pin_obj_t *read, const mcu_pin_obj_t *reset, uint32_t frequency) { @@ -80,7 +80,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *sel 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_parallelbus_reset(self); + common_hal_paralleldisplay_parallelbus_reset(self); } never_reset_pin_number(command->number); @@ -110,7 +110,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *sel common_hal_rp2pio_statemachine_never_reset(&self->state_machine); } -void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) { +void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { common_hal_rp2pio_statemachine_deinit(&self->state_machine); for (uint8_t i = 0; i < 8; i++) { @@ -124,8 +124,8 @@ void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) reset_pin_number(self->reset.pin->number); } -bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->reset.base.type == &mp_type_NoneType) { return false; } @@ -136,26 +136,26 @@ bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { return true; } -bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { return true; } -bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); return true; } -void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA); common_hal_rp2pio_statemachine_write(&self->state_machine, data, data_length, 1); } -void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) { - displayio_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { + paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, true); } diff --git a/ports/raspberrypi/common-hal/displayio/ParallelBus.h b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.h similarity index 96% rename from ports/raspberrypi/common-hal/displayio/ParallelBus.h rename to ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.h index 3d83c8fca7..c93034da18 100644 --- a/ports/raspberrypi/common-hal/displayio/ParallelBus.h +++ b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_DISPLAYIO_PARALLELBUS_H -#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#ifndef MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H +#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H #include "common-hal/digitalio/DigitalInOut.h" #include "bindings/rp2pio/StateMachine.h" @@ -40,6 +40,6 @@ typedef struct { uint8_t write; uint8_t data0_pin; rp2pio_statemachine_obj_t state_machine; -} displayio_parallelbus_obj_t; +} paralleldisplay_parallelbus_obj_t; -#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H diff --git a/ports/stm/common-hal/displayio/ParallelBus.c b/ports/stm/common-hal/paralleldisplay/ParallelBus.c similarity index 75% rename from ports/stm/common-hal/displayio/ParallelBus.c rename to ports/stm/common-hal/paralleldisplay/ParallelBus.c index d36d8ad64a..b6b658bb39 100644 --- a/ports/stm/common-hal/displayio/ParallelBus.c +++ b/ports/stm/common-hal/paralleldisplay/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include @@ -33,35 +33,35 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/__init__.h" -void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *self, +void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, const mcu_pin_obj_t *data0, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *write, const mcu_pin_obj_t *read, const mcu_pin_obj_t *reset, uint32_t frequency) { mp_raise_NotImplementedError(translate("ParallelBus not yet supported")); } -void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self) { +void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { } -bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { return false; } -bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { return false; } -bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) { +bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { return false; } -void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { } -void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) { +void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { } diff --git a/ports/stm/common-hal/displayio/ParallelBus.h b/ports/stm/common-hal/paralleldisplay/ParallelBus.h similarity index 88% rename from ports/stm/common-hal/displayio/ParallelBus.h rename to ports/stm/common-hal/paralleldisplay/ParallelBus.h index 85d100715e..f637fa5a28 100644 --- a/ports/stm/common-hal/displayio/ParallelBus.h +++ b/ports/stm/common-hal/paralleldisplay/ParallelBus.h @@ -24,13 +24,13 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H -#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H +#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H #include "common-hal/digitalio/DigitalInOut.h" typedef struct { mp_obj_base_t base; -} displayio_parallelbus_obj_t; +} paralleldisplay_parallelbus_obj_t; -#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELDISPLAY_H diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 78fb255801..ae701cd201 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -175,6 +175,9 @@ endif ifeq ($(CIRCUITPY_DISPLAYIO),1) SRC_PATTERNS += displayio/% endif +ifeq ($(CIRCUITPY_PARALLELDISPLAY),1) +SRC_PATTERNS += paralleldisplay/% +endif ifeq ($(CIRCUITPY_VECTORIO),1) SRC_PATTERNS += vectorio/% endif @@ -385,7 +388,6 @@ SRC_COMMON_HAL_ALL = \ countio/__init__.c \ digitalio/DigitalInOut.c \ digitalio/__init__.c \ - displayio/ParallelBus.c \ dualbank/__init__.c \ frequencyio/FrequencyIn.c \ frequencyio/__init__.c \ @@ -404,6 +406,7 @@ SRC_COMMON_HAL_ALL = \ nvm/ByteArray.c \ nvm/__init__.c \ os/__init__.c \ + paralleldisplay/ParallelBus.c \ ps2io/Ps2.c \ ps2io/__init__.c \ pulseio/PulseIn.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 1db489b953..1590ddcbf0 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -330,6 +330,7 @@ extern const struct _mp_obj_module_t canio_module; // CIRCUITPY_COUNTIO uses MP_REGISTER_MODULE // CIRCUITPY_DIGITALIO uses MP_REGISTER_MODULE // CIRCUITPY_DISPLAYIO uses MP_REGISTER_MODULE +// CIRCUITPY_PARALLELDISPLAY uses MP_REGISTER_MODULE // CIRCUITPY_TERMINALIO uses MP_REGISTER_MODULE // CIRCUITPY_FONTIO uses MP_REGISTER_MODULE diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 53030aec2c..1bb8ea3200 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -154,6 +154,13 @@ CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO) +ifeq ($(CIRCUITPY_DISPLAYIO),1) +CIRCUITPY_PARALLELDISPLAY ?= $(CIRCUITPY_FULL_BUILD) +else +CIRCUITPY_PARALLELDISPLAY = 0 +endif +CFLAGS += -DCIRCUITPY_PARALLELDISPLAY=$(CIRCUITPY_PARALLELDISPLAY) + # bitmaptools and framebufferio rely on displayio ifeq ($(CIRCUITPY_DISPLAYIO),1) CIRCUITPY_BITMAPTOOLS ?= $(CIRCUITPY_FULL_BUILD) diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index 89d18d9609..a9aa49cdbf 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -40,7 +40,7 @@ #include "shared-bindings/displayio/I2CDisplay.h" #include "shared-bindings/displayio/OnDiskBitmap.h" #include "shared-bindings/displayio/Palette.h" -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include "shared-bindings/displayio/Shape.h" #include "shared-bindings/displayio/TileGrid.h" @@ -125,7 +125,9 @@ STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_FourWire), MP_ROM_PTR(&displayio_fourwire_type) }, { MP_ROM_QSTR(MP_QSTR_I2CDisplay), MP_ROM_PTR(&displayio_i2cdisplay_type) }, - { MP_ROM_QSTR(MP_QSTR_ParallelBus), MP_ROM_PTR(&displayio_parallelbus_type) }, + #if CIRCUITPY_PARALLELDISPLAY + { MP_ROM_QSTR(MP_QSTR_ParallelBus), MP_ROM_PTR(¶lleldisplay_parallelbus_type) }, + #endif { MP_ROM_QSTR(MP_QSTR_release_displays), MP_ROM_PTR(&displayio_release_displays_obj) }, }; diff --git a/shared-bindings/displayio/ParallelBus.c b/shared-bindings/paralleldisplay/ParallelBus.c similarity index 74% rename from shared-bindings/displayio/ParallelBus.c rename to shared-bindings/paralleldisplay/ParallelBus.c index efa64dddf4..22d0b9393b 100644 --- a/shared-bindings/displayio/ParallelBus.c +++ b/shared-bindings/paralleldisplay/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include @@ -59,7 +59,7 @@ //| :param microcontroller.Pin reset: Reset pin""" //| ... //| -STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_data0, ARG_command, ARG_chip_select, ARG_write, ARG_read, ARG_reset, ARG_frequency }; static const mp_arg_t allowed_args[] = { { MP_QSTR_data0, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, @@ -80,10 +80,10 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t mcu_pin_obj_t *read = validate_obj_is_free_pin(args[ARG_read].u_obj); mcu_pin_obj_t *reset = validate_obj_is_free_pin(args[ARG_reset].u_obj); - displayio_parallelbus_obj_t *self = &allocate_display_bus_or_raise()->parallel_bus; - self->base.type = &displayio_parallelbus_type; + paralleldisplay_parallelbus_obj_t *self = &allocate_display_bus_or_raise()->parallel_bus; + self->base.type = ¶lleldisplay_parallelbus_type; - common_hal_displayio_parallelbus_construct(self, data0, command, chip_select, write, read, reset, args[ARG_frequency].u_int); + common_hal_paralleldisplay_parallelbus_construct(self, data0, command, chip_select, write, read, reset, args[ARG_frequency].u_int); return self; } @@ -93,22 +93,22 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t //| ... //| -STATIC mp_obj_t displayio_parallelbus_obj_reset(mp_obj_t self_in) { - displayio_parallelbus_obj_t *self = self_in; +STATIC mp_obj_t paralleldisplay_parallelbus_obj_reset(mp_obj_t self_in) { + paralleldisplay_parallelbus_obj_t *self = self_in; - if (!common_hal_displayio_parallelbus_reset(self)) { + if (!common_hal_paralleldisplay_parallelbus_reset(self)) { mp_raise_RuntimeError(translate("no reset pin available")); } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_parallelbus_reset_obj, displayio_parallelbus_obj_reset); +MP_DEFINE_CONST_FUN_OBJ_1(paralleldisplay_parallelbus_reset_obj, paralleldisplay_parallelbus_obj_reset); //| def send(self, command: int, data: ReadableBuffer) -> None: //| """Sends the given command value followed by the full set of data. Display state, such as //| vertical scroll, set via ``send`` may or may not be reset once the code is done.""" //| ... //| -STATIC mp_obj_t displayio_parallelbus_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { +STATIC mp_obj_t paralleldisplay_parallelbus_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { mp_int_t command_int = MP_OBJ_SMALL_INT_VALUE(command_obj); if (!mp_obj_is_small_int(command_obj) || command_int > 255 || command_int < 0) { mp_raise_ValueError(translate("Command must be an int between 0 and 255")); @@ -118,26 +118,26 @@ STATIC mp_obj_t displayio_parallelbus_obj_send(mp_obj_t self, mp_obj_t command_o mp_get_buffer_raise(data_obj, &bufinfo, MP_BUFFER_READ); // Wait for display bus to be available. - while (!common_hal_displayio_parallelbus_begin_transaction(self)) { + while (!common_hal_paralleldisplay_parallelbus_begin_transaction(self)) { RUN_BACKGROUND_TASKS; } - common_hal_displayio_parallelbus_send(self, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, &command, 1); - common_hal_displayio_parallelbus_send(self, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, ((uint8_t *)bufinfo.buf), bufinfo.len); - common_hal_displayio_parallelbus_end_transaction(self); + common_hal_paralleldisplay_parallelbus_send(self, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, &command, 1); + common_hal_paralleldisplay_parallelbus_send(self, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, ((uint8_t *)bufinfo.buf), bufinfo.len); + common_hal_paralleldisplay_parallelbus_end_transaction(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_3(displayio_parallelbus_send_obj, displayio_parallelbus_obj_send); +MP_DEFINE_CONST_FUN_OBJ_3(paralleldisplay_parallelbus_send_obj, paralleldisplay_parallelbus_obj_send); -STATIC const mp_rom_map_elem_t displayio_parallelbus_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&displayio_parallelbus_reset_obj) }, - { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&displayio_parallelbus_send_obj) }, +STATIC const mp_rom_map_elem_t paralleldisplay_parallelbus_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(¶lleldisplay_parallelbus_reset_obj) }, + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(¶lleldisplay_parallelbus_send_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(displayio_parallelbus_locals_dict, displayio_parallelbus_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(paralleldisplay_parallelbus_locals_dict, paralleldisplay_parallelbus_locals_dict_table); -const mp_obj_type_t displayio_parallelbus_type = { +const mp_obj_type_t paralleldisplay_parallelbus_type = { { &mp_type_type }, .name = MP_QSTR_ParallelBus, - .make_new = displayio_parallelbus_make_new, - .locals_dict = (mp_obj_dict_t *)&displayio_parallelbus_locals_dict, + .make_new = paralleldisplay_parallelbus_make_new, + .locals_dict = (mp_obj_dict_t *)¶lleldisplay_parallelbus_locals_dict, }; diff --git a/shared-bindings/displayio/ParallelBus.h b/shared-bindings/paralleldisplay/ParallelBus.h similarity index 67% rename from shared-bindings/displayio/ParallelBus.h rename to shared-bindings/paralleldisplay/ParallelBus.h index 1a61aae0af..2f9c8d10e3 100644 --- a/shared-bindings/displayio/ParallelBus.h +++ b/shared-bindings/paralleldisplay/ParallelBus.h @@ -24,31 +24,31 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_PARALLELBUS_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_PARALLELBUS_H +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_PARALLELDISPLAY_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_PARALLELDISPLAY_H -#include "common-hal/displayio/ParallelBus.h" +#include "common-hal/paralleldisplay/ParallelBus.h" #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/displayio/__init__.h" #include "shared-module/displayio/Group.h" -extern const mp_obj_type_t displayio_parallelbus_type; +extern const mp_obj_type_t paralleldisplay_parallelbus_type; -void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *self, +void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, const mcu_pin_obj_t *data0, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *write, const mcu_pin_obj_t *read, const mcu_pin_obj_t *reset, uint32_t frequency); -void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self); +void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self); -bool common_hal_displayio_parallelbus_reset(mp_obj_t self); -bool common_hal_displayio_parallelbus_bus_free(mp_obj_t self); +bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t self); +bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t self); -bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t self); +bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t self); -void common_hal_displayio_parallelbus_send(mp_obj_t self, display_byte_type_t byte_type, +void common_hal_paralleldisplay_parallelbus_send(mp_obj_t self, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length); -void common_hal_displayio_parallelbus_end_transaction(mp_obj_t self); +void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t self); -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_PARALLELBUS_H +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_PARALLELDISPLAY_H diff --git a/shared-bindings/paralleldisplay/__init__.h b/shared-bindings/paralleldisplay/__init__.h new file mode 100644 index 0000000000..e87479a9f9 --- /dev/null +++ b/shared-bindings/paralleldisplay/__init__.h @@ -0,0 +1,51 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/enum.h" +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/paralleldisplay/__init__.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" + +//| """Native helpers for driving parallel displays""" + + +STATIC const mp_rom_map_elem_t paralleldisplay_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_paralleldisplay) }, + { MP_ROM_QSTR(MP_QSTR_ParallelBus), MP_ROM_PTR(¶lleldisplay_parallelbus_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(paralleldisplay_module_globals, paralleldisplay_module_globals_table); + +const mp_obj_module_t paralleldisplay_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)¶lleldisplay_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_paralleldisplay, paralleldisplay_module, CIRCUITPY_PARALLELDISPLAY); diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 4c30a85970..40a2e31feb 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -29,7 +29,7 @@ #include "py/runtime.h" #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/I2CDisplay.h" -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/__init__.h" diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index 8de7d4e45f..9731aa90f0 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -31,7 +31,7 @@ #include "shared-bindings/displayio/ColorConverter.h" #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/I2CDisplay.h" -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/__init__.h" diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index 8fda1b5cb0..d264531c99 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -109,8 +109,10 @@ void common_hal_displayio_release_displays(void) { common_hal_displayio_fourwire_deinit(&displays[i].fourwire_bus); } else if (bus_type == &displayio_i2cdisplay_type) { common_hal_displayio_i2cdisplay_deinit(&displays[i].i2cdisplay_bus); - } else if (bus_type == &displayio_parallelbus_type) { - common_hal_displayio_parallelbus_deinit(&displays[i].parallel_bus); + #if CIRCUITPY_PARALLELDISPLAY + } else if (bus_type == ¶lleldisplay_parallelbus_type) { + common_hal_paralleldisplay_parallelbus_deinit(&displays[i].parallel_bus); + #endif #if CIRCUITPY_RGBMATRIX } else if (bus_type == &rgbmatrix_RGBMatrix_type) { common_hal_rgbmatrix_rgbmatrix_deinit(&displays[i].rgbmatrix); diff --git a/shared-module/displayio/__init__.h b/shared-module/displayio/__init__.h index 4a74b0e0e0..09f2f7ae08 100644 --- a/shared-module/displayio/__init__.h +++ b/shared-module/displayio/__init__.h @@ -35,7 +35,7 @@ #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/Group.h" #include "shared-bindings/displayio/I2CDisplay.h" -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #if CIRCUITPY_RGBMATRIX #include "shared-bindings/rgbmatrix/RGBMatrix.h" #endif @@ -48,7 +48,7 @@ typedef struct { mp_obj_base_t bus_base; displayio_fourwire_obj_t fourwire_bus; displayio_i2cdisplay_obj_t i2cdisplay_bus; - displayio_parallelbus_obj_t parallel_bus; + paralleldisplay_parallelbus_obj_t parallel_bus; #if CIRCUITPY_RGBMATRIX rgbmatrix_rgbmatrix_obj_t rgbmatrix; #endif diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 234c0a096b..d1efbf7ddc 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/I2CDisplay.h" -#include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/__init__.h" @@ -61,13 +61,16 @@ void displayio_display_core_construct(displayio_display_core_t *self, // (framebufferdisplay already validated its 'bus' is a buffer-protocol object) if (bus) { - if (mp_obj_is_type(bus, &displayio_parallelbus_type)) { - self->bus_reset = common_hal_displayio_parallelbus_reset; - self->bus_free = common_hal_displayio_parallelbus_bus_free; - self->begin_transaction = common_hal_displayio_parallelbus_begin_transaction; - self->send = common_hal_displayio_parallelbus_send; - self->end_transaction = common_hal_displayio_parallelbus_end_transaction; - } else if (mp_obj_is_type(bus, &displayio_fourwire_type)) { + #if CIRCUITPY_PARALLELDISPLAY + if (mp_obj_is_type(bus, ¶lleldisplay_parallelbus_type)) { + self->bus_reset = common_hal_paralleldisplay_parallelbus_reset; + self->bus_free = common_hal_paralleldisplay_parallelbus_bus_free; + self->begin_transaction = common_hal_paralleldisplay_parallelbus_begin_transaction; + self->send = common_hal_paralleldisplay_parallelbus_send; + self->end_transaction = common_hal_paralleldisplay_parallelbus_end_transaction; + } else + #endif + if (mp_obj_is_type(bus, &displayio_fourwire_type)) { self->bus_reset = common_hal_displayio_fourwire_reset; self->bus_free = common_hal_displayio_fourwire_bus_free; self->begin_transaction = common_hal_displayio_fourwire_begin_transaction;