diff --git a/docs/redirects.txt b/docs/redirects.txt index d8fc46b35809..248a042e7ae4 100644 --- a/docs/redirects.txt +++ b/docs/redirects.txt @@ -71,7 +71,7 @@ shared-bindings/displayio/Group.rst shared-bindings/displayio/#displayio.Group shared-bindings/displayio/I2CDisplay.rst shared-bindings/displayio/#displayio.I2CDisplay shared-bindings/displayio/OnDiskBitmap.rst shared-bindings/displayio/#displayio.OnDiskBitmap shared-bindings/displayio/Palette.rst shared-bindings/displayio/#displayio.Palette -shared-bindings/displayio/ParallelBus.rst shared-bindings/displayio/#displayio.ParallelBus +shared-bindings/paralleldisplay/ParallelBus.rst shared-bindings/paralleldisplay/#paralleldisplay.ParallelBus shared-bindings/displayio/Shape.rst shared-bindings/displayio/#displayio.Shape shared-bindings/displayio/TileGrid.rst shared-bindings/displayio/#displayio.TileGrid shared-bindings/displayio/__init__.rst shared-bindings/displayio/ diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index 3a97c3983045..fd9e6cc2e683 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -20,6 +20,7 @@ CIRCUITPY_USB_MIDI = 0 # So not all of displayio, sorry! CIRCUITPY_VECTORIO = 0 CIRCUITPY_BITMAPTOOLS = 0 +CIRCUITPY_PARALLELDISPLAY = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index 2a4d58f13412..7c3e7eb3ed1d 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -20,6 +20,7 @@ CIRCUITPY_BITBANG_APA102 = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_PARALLELDISPLAY = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_PS2IO = 0 CIRCUITPY_PULSEIO = 0 diff --git a/ports/atmel-samd/boards/pyportal/board.c b/ports/atmel-samd/boards/pyportal/board.c index 166b14fd5b82..b46b176afcb5 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 6c05e47d9296..138f94ebc82c 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/boards/ugame10/mpconfigboard.mk b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk index 225b37fb20cf..f942490f29da 100644 --- a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk @@ -24,6 +24,7 @@ CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_PARALLELDISPLAY = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_RTC = 0 CIRCUITPY_TOUCHIO = 0 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 e5575f8dc244..490c595e7428 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 85% rename from ports/atmel-samd/common-hal/displayio/ParallelBus.h rename to ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.h index ee19caddf6c7..5ef7bcf19507 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_PARALLELDISPLAY_PARALLELBUS_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_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_PARALLELDISPLAY_PARALLELBUS_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 cbe093164fa4..befd8362471d 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 89% rename from ports/esp32s2/common-hal/displayio/ParallelBus.h rename to ports/esp32s2/common-hal/paralleldisplay/ParallelBus.h index 59eb64f34d05..8758b8fccae6 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_PARALLELDISPLAY_PARALLELBUS_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_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_PARALLELDISPLAY_PARALLELBUS_H diff --git a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.c b/ports/mimxrt10xx/common-hal/displayio/ParallelBus.c deleted file mode 100644 index f7889c70f4df..000000000000 --- a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2020 Artur Pacholec - * - * 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 "shared-bindings/displayio/ParallelBus.h" - -#include - -#include "common-hal/microcontroller/Pin.h" -#include "py/runtime.h" -#include "shared-bindings/digitalio/DigitalInOut.h" -#include "shared-bindings/microcontroller/__init__.h" - -void common_hal_displayio_parallelbus_construct(displayio_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) { - -} - -bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { - return false; -} - -bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { - return false; -} - -bool common_hal_displayio_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, - 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) { - -} diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index 3f4d9d4b7f58..ed9446d0e7d5 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -28,6 +28,7 @@ CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_NVM = 0 +CIRCUITPY_PARALLELDISPLAY = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_USB_MIDI = 1 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 7e0aea0d63d6..6f84ceb2148e 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 86% rename from ports/nrf/common-hal/displayio/ParallelBus.h rename to ports/nrf/common-hal/paralleldisplay/ParallelBus.h index 30a0c7e61e45..14ba7bbc118a 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_PARALLELDISPLAY_PARALLELBUS_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_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_PARALLELDISPLAY_PARALLELBUS_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 93477e2453bf..997147404217 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 86% rename from ports/raspberrypi/common-hal/displayio/ParallelBus.h rename to ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.h index 3d83c8fca7f7..87f149b9b873 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_PARALLELDISPLAY_PARALLELBUS_H +#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_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_PARALLELDISPLAY_PARALLELBUS_H diff --git a/ports/stm/common-hal/displayio/ParallelBus.c b/ports/stm/common-hal/displayio/ParallelBus.c deleted file mode 100644 index d36d8ad64a4c..000000000000 --- a/ports/stm/common-hal/displayio/ParallelBus.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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 "shared-bindings/displayio/ParallelBus.h" - -#include - -#include "common-hal/microcontroller/Pin.h" -#include "py/runtime.h" -#include "shared-bindings/digitalio/DigitalInOut.h" -#include "shared-bindings/microcontroller/__init__.h" - -void common_hal_displayio_parallelbus_construct(displayio_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) { - -} - -bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { - return false; -} - -bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { - return false; -} - -bool common_hal_displayio_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, - 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) { - -} diff --git a/ports/stm/common-hal/displayio/ParallelBus.h b/ports/stm/common-hal/displayio/ParallelBus.h deleted file mode 100644 index 85d100715ee8..000000000000 --- a/ports/stm/common-hal/displayio/ParallelBus.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Lucian Copeland 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. - */ - -#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H -#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H - -#include "common-hal/digitalio/DigitalInOut.h" - -typedef struct { - mp_obj_base_t base; -} displayio_parallelbus_obj_t; - -#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H diff --git a/ports/stm/mpconfigport.mk b/ports/stm/mpconfigport.mk index c68a5077ee5e..16c098841c28 100644 --- a/ports/stm/mpconfigport.mk +++ b/ports/stm/mpconfigport.mk @@ -61,3 +61,5 @@ ifeq ($(MCU_SERIES),F7) USB_NUM_ENDPOINT_PAIRS = 6 endif + +CIRCUITPY_PARALLELDISPLAY := 0 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 78fb255801ce..ae701cd20119 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 1db489b953f3..1590ddcbf0e0 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 53030aec2c07..1bb8ea320089 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/Display.c b/shared-bindings/displayio/Display.c index 3dcc26f691a2..b5c8868de5d8 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -39,8 +39,8 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/translate.h" -//| _DisplayBus = Union['FourWire', 'ParallelBus', 'I2CDisplay'] -//| """:py:class:`FourWire`, :py:class:`ParallelBus` or :py:class:`I2CDisplay`""" +//| _DisplayBus = Union['FourWire', 'paralleldisplay.ParallelBus', 'I2CDisplay'] +//| """:py:class:`FourWire`, :py:class:`paralleldisplay.ParallelBus` or :py:class:`I2CDisplay`""" //| //| diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index 689ac413ebe4..afe132125181 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -64,7 +64,7 @@ //| busy_pin: Optional[microcontroller.Pin] = None, busy_state: bool = True, //| seconds_per_frame: float = 180, always_toggle_chip_select: bool = False, //| grayscale: bool = False) -> None: -//| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`). +//| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `paralleldisplay.ParallelBus`). //| //| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every //| command begins with a command byte followed by a byte to determine the parameter count and @@ -75,7 +75,7 @@ //| extra long 500 ms delay instead of 255 ms. The next byte will begin a new command definition. //| //| :param display_bus: The bus that the display is connected to -//| :type _DisplayBus: displayio.FourWire or displayio.ParallelBus +//| :type _DisplayBus: displayio.FourWire or paralleldisplay.ParallelBus //| :param ~_typing.ReadableBuffer start_sequence: Byte-packed initialization sequence. //| :param ~_typing.ReadableBuffer stop_sequence: Byte-packed initialization sequence. //| :param int width: Width in pixels diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index 89d18d960951..7ac2a849030a 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -40,7 +40,9 @@ #include "shared-bindings/displayio/I2CDisplay.h" #include "shared-bindings/displayio/OnDiskBitmap.h" #include "shared-bindings/displayio/Palette.h" -#include "shared-bindings/displayio/ParallelBus.h" +#if CIRCUITPY_PARALLELDISPLAY +#include "shared-bindings/paralleldisplay/ParallelBus.h" +#endif #include "shared-bindings/displayio/Shape.h" #include "shared-bindings/displayio/TileGrid.h" @@ -50,6 +52,8 @@ //| including synchronizing with refresh rates and partial updating.""" //| +//| import paralleldisplay + //| def release_displays() -> None: //| """Releases any actively used displays so their busses and pins can be used again. This will also //| release the builtin display on boards that have one. You will need to reinitialize it yourself @@ -125,7 +129,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 efa64dddf450..22d0b9393b7d 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 1a61aae0af82..cd9e32f9be39 100644 --- a/shared-bindings/displayio/ParallelBus.h +++ b/shared-bindings/paralleldisplay/ParallelBus.h @@ -24,31 +24,28 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_PARALLELBUS_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_PARALLELBUS_H +#pragma once -#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); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_PARALLELBUS_H +void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t self); diff --git a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.h b/shared-bindings/paralleldisplay/__init__.h similarity index 56% rename from ports/mimxrt10xx/common-hal/displayio/ParallelBus.h rename to shared-bindings/paralleldisplay/__init__.h index 845e44df0603..e87479a9f95e 100644 --- a/ports/mimxrt10xx/common-hal/displayio/ParallelBus.h +++ b/shared-bindings/paralleldisplay/__init__.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Artur Pacholec + * 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 @@ -24,13 +24,28 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELBUS_H -#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_PARALLELBUS_H +#include -#include "common-hal/digitalio/DigitalInOut.h" +#include "py/enum.h" +#include "py/obj.h" +#include "py/runtime.h" -typedef struct { - mp_obj_base_t base; -} displayio_parallelbus_obj_t; +#include "shared-bindings/paralleldisplay/__init__.h" +#include "shared-bindings/paralleldisplay/ParallelBus.h" -#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_DISPLAYIO_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 4c30a8597038..f74b472bf41f 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -29,7 +29,9 @@ #include "py/runtime.h" #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/I2CDisplay.h" -#include "shared-bindings/displayio/ParallelBus.h" +#if CIRCUITPY_PARALLELDISPLAY +#include "shared-bindings/paralleldisplay/ParallelBus.h" +#endif #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 8de7d4e45fc5..b1d06fbd726e 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -31,7 +31,9 @@ #include "shared-bindings/displayio/ColorConverter.h" #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/I2CDisplay.h" -#include "shared-bindings/displayio/ParallelBus.h" +#if CIRCUITPY_PARALLELDISPLAY +#include "shared-bindings/paralleldisplay/ParallelBus.h" +#endif #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 8fda1b5cb0d6..d264531c99c4 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 4a74b0e0e0c2..5bfee4d67d01 100644 --- a/shared-module/displayio/__init__.h +++ b/shared-module/displayio/__init__.h @@ -35,7 +35,9 @@ #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/Group.h" #include "shared-bindings/displayio/I2CDisplay.h" -#include "shared-bindings/displayio/ParallelBus.h" +#if CIRCUITPY_PARALLELDISPLAY +#include "shared-bindings/paralleldisplay/ParallelBus.h" +#endif #if CIRCUITPY_RGBMATRIX #include "shared-bindings/rgbmatrix/RGBMatrix.h" #endif @@ -48,7 +50,9 @@ 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; + #if CIRCUITPY_PARALLELDISPLAY + paralleldisplay_parallelbus_obj_t parallel_bus; + #endif #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 234c0a096b57..114b274fd1d9 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -30,7 +30,9 @@ #include "py/runtime.h" #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/I2CDisplay.h" -#include "shared-bindings/displayio/ParallelBus.h" +#if CIRCUITPY_PARALLELDISPLAY +#include "shared-bindings/paralleldisplay/ParallelBus.h" +#endif #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/__init__.h" @@ -61,13 +63,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;