diff --git a/main.c b/main.c index c593739a04..b4345b65e0 100644 --- a/main.c +++ b/main.c @@ -94,6 +94,10 @@ #include "shared-module/displayio/__init__.h" #endif +#if CIRCUITPY_EPAPERDISPLAY +#include "shared-bindings/epaperdisplay/EPaperDisplay.h" +#endif + #if CIRCUITPY_KEYPAD #include "shared-module/keypad/__init__.h" #endif @@ -534,7 +538,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) { // Program has finished running. bool printed_press_any_key = false; - #if CIRCUITPY_DISPLAYIO + #if CIRCUITPY_EPAPERDISPLAY size_t time_to_epaper_refresh = 1; #endif @@ -682,7 +686,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) { // Refresh the ePaper display if we have one. That way it'll show an error message. // Skip if we're about to autoreload. Otherwise we may delay when user code can update // the display. - #if CIRCUITPY_DISPLAYIO + #if CIRCUITPY_EPAPERDISPLAY if (time_to_epaper_refresh > 0 && !autoreload_pending()) { time_to_epaper_refresh = maybe_refresh_epaperdisplay(); } @@ -724,7 +728,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) { } time_to_next_change = total_time - tick_diff; } - #if CIRCUITPY_DISPLAYIO + #if CIRCUITPY_EPAPERDISPLAY if (time_to_epaper_refresh > 0 && time_to_next_change > 0) { time_to_next_change = MIN(time_to_next_change, time_to_epaper_refresh); } diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c index 357cda495c..ac27080b76 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c @@ -27,12 +27,12 @@ #include "supervisor/board.h" #include "shared-bindings/board/__init__.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/busio/SPI.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -69,11 +69,11 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; busio_spi_obj_t *spi = common_hal_board_create_spi(0); common_hal_busio_spi_never_reset(spi); - common_hal_displayio_fourwire_construct(bus, + common_hal_fourwire_fourwire_construct(bus, spi, &pin_PA28, // Command or data &pin_PA01, // Chip select @@ -82,9 +82,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 128, // Width 128, // Height diff --git a/ports/atmel-samd/boards/hallowing_m4_express/board.c b/ports/atmel-samd/boards/hallowing_m4_express/board.c index c070db6e52..82d8cea619 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m4_express/board.c @@ -28,11 +28,12 @@ #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/busdisplay/BusDisplay.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -47,13 +48,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_PB31, // TFT_DC Command or data &pin_PA27, // TFT_CS Chip select @@ -62,9 +63,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 240, // Width (after rotation) 240, // Height (after rotation) diff --git a/ports/atmel-samd/boards/monster_m4sk/board.c b/ports/atmel-samd/boards/monster_m4sk/board.c index c67bc7dab9..34948b6a34 100644 --- a/ports/atmel-samd/boards/monster_m4sk/board.c +++ b/ports/atmel-samd/boards/monster_m4sk/board.c @@ -28,11 +28,11 @@ #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -48,13 +48,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_PA07, // TFT_DC Command or data &pin_PA06, // TFT_CS Chip select @@ -63,9 +63,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 240, // Width (after rotation) 240, // Height (after rotation) diff --git a/ports/atmel-samd/boards/openbook_m4/board.c b/ports/atmel-samd/boards/openbook_m4/board.c index 5867a279f4..d6911c7a07 100644 --- a/ports/atmel-samd/boards/openbook_m4/board.c +++ b/ports/atmel-samd/boards/openbook_m4/board.c @@ -28,12 +28,12 @@ #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 #define HEIGHT 400 @@ -57,13 +57,13 @@ uint8_t refresh_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_PB05, // EPD_DC Command or data &pin_PB07, // EPD_CS Chip select @@ -72,9 +72,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; - display->base.type = &displayio_epaperdisplay_type; - common_hal_displayio_epaperdisplay_construct(display, + epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; + display->base.type = &epaperdisplay_epaperdisplay_type; + common_hal_epaperdisplay_epaperdisplay_construct(display, bus, start_sequence, sizeof(start_sequence), diff --git a/ports/atmel-samd/boards/pewpew_lcd/board.c b/ports/atmel-samd/boards/pewpew_lcd/board.c index 8c058fb6d9..643494017d 100644 --- a/ports/atmel-samd/boards/pewpew_lcd/board.c +++ b/ports/atmel-samd/boards/pewpew_lcd/board.c @@ -27,12 +27,12 @@ #include "supervisor/board.h" #include "shared-bindings/board/__init__.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/busio/SPI.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -46,13 +46,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_PA23, &pin_PA22, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, NULL, // Command or data &pin_PA19, // Chip select @@ -61,9 +61,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 96, // Width 68, // Height diff --git a/ports/atmel-samd/boards/pewpew_m4/board.c b/ports/atmel-samd/boards/pewpew_m4/board.c index 381af5ec16..ba37a9ddce 100644 --- a/ports/atmel-samd/boards/pewpew_m4/board.c +++ b/ports/atmel-samd/boards/pewpew_m4/board.c @@ -29,11 +29,11 @@ #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; typedef struct { const uint32_t *config_data; @@ -97,13 +97,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA15, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_PA16, // TFT_DC Command or data &pin_PA11, // TFT_CS Chip select @@ -115,9 +115,9 @@ void board_init(void) { uint32_t cfg0 = lookupCfg(CFG_DISPLAY_CFG0, 0x000000); uint32_t offX = (cfg0 >> 8) & 0xff; uint32_t offY = (cfg0 >> 16) & 0xff; - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 160, // Width (after rotation) 128, // Height (after rotation) diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index 4b5ac1dc19..8314f354a2 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "supervisor/shared/board.h" @@ -68,13 +68,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_PB05, // TFT_DC Command or data &pin_PB07, // TFT_CS Chip select @@ -83,9 +83,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 160, // Width (after rotation) 128, // Height (after rotation) diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c index 84b81a4b4e..746298f578 100644 --- a/ports/atmel-samd/boards/pygamer/board.c +++ b/ports/atmel-samd/boards/pygamer/board.c @@ -28,12 +28,12 @@ #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "supervisor/shared/board.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -70,13 +70,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_PB05, // TFT_DC Command or data &pin_PB12, // TFT_CS Chip select @@ -85,9 +85,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 160, // Width 128, // Height diff --git a/ports/atmel-samd/boards/pyportal/board.c b/ports/atmel-samd/boards/pyportal/board.c index 49dd831c4d..4080d703b8 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) { - paralleldisplay_parallelbus_obj_t *bus = &allocate_display_bus()->parallel_bus; - bus->base.type = ¶lleldisplay_parallelbus_type; - common_hal_paralleldisplay_parallelbus_construct(bus, + paralleldisplaybus_parallelbus_obj_t *bus = &allocate_display_bus()->parallel_bus; + bus->base.type = ¶lleldisplaybus_parallelbus_type; + common_hal_paralleldisplaybus_parallelbus_construct(bus, &pin_PA16, // Data0 &pin_PB05, // Command or data &pin_PB06, // Chip select @@ -72,9 +72,9 @@ void board_init(void) { &pin_PA00, // Reset 0); // Frequency - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 320, // Width 240, // Height diff --git a/ports/atmel-samd/boards/pyportal_titano/board.c b/ports/atmel-samd/boards/pyportal_titano/board.c index f938456599..245b8b9dd8 100644 --- a/ports/atmel-samd/boards/pyportal_titano/board.c +++ b/ports/atmel-samd/boards/pyportal_titano/board.c @@ -29,7 +29,7 @@ #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" @@ -78,9 +78,9 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - paralleldisplay_parallelbus_obj_t *bus = &allocate_display_bus()->parallel_bus; - bus->base.type = ¶lleldisplay_parallelbus_type; - common_hal_paralleldisplay_parallelbus_construct(bus, + paralleldisplaybus_parallelbus_obj_t *bus = &allocate_display_bus()->parallel_bus; + bus->base.type = ¶lleldisplaybus_parallelbus_type; + common_hal_paralleldisplaybus_parallelbus_construct(bus, &pin_PA16, // Data0 &pin_PB05, // Command or data &pin_PB06, // Chip select @@ -89,9 +89,9 @@ void board_init(void) { &pin_PA00, // Reset 0); // Frequency - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 480, // Width 320, // Height diff --git a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c index 6a18d4ea84..a4e563017a 100644 --- a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c +++ b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c @@ -28,12 +28,12 @@ #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/digitalio/DigitalInOut.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; digitalio_digitalinout_obj_t CTR_5V; digitalio_digitalinout_obj_t CTR_3V3; digitalio_digitalinout_obj_t USB_HOST_ENABLE; @@ -65,13 +65,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_PB20, &pin_PB19, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_PC06, // TFT_DC Command or data &pin_PB21, // TFT_CS Chip select @@ -80,9 +80,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 320, // Width 240, // Height diff --git a/ports/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c index 6db511d775..5578beb06a 100644 --- a/ports/atmel-samd/boards/ugame10/board.c +++ b/ports/atmel-samd/boards/ugame10/board.c @@ -28,12 +28,12 @@ #include "supervisor/board.h" #include "shared-bindings/board/__init__.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/busio/SPI.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -70,10 +70,10 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; busio_spi_obj_t *spi = common_hal_board_create_spi(0); - common_hal_displayio_fourwire_construct(bus, + common_hal_fourwire_fourwire_construct(bus, spi, &pin_PA09, // Command or data &pin_PA08, // Chip select @@ -82,9 +82,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 128, // Width 128, // Height diff --git a/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c b/ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.c similarity index 84% rename from ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c rename to ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.c index 10407d3b3a..5358a2e9a3 100644 --- a/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/paralleldisplay/ParallelBus.h" +#include "shared-bindings/paralleldisplaybus/ParallelBus.h" #include @@ -33,7 +33,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/__init__.h" -void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, +void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_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) { @@ -87,7 +87,7 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu 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_paralleldisplay_parallelbus_reset(self); + common_hal_paralleldisplaybus_parallelbus_reset(self); } never_reset_pin_number(command->number); @@ -98,7 +98,7 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu } } -void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { +void common_hal_paralleldisplaybus_parallelbus_deinit(paralleldisplaybus_parallelbus_obj_t *self) { for (uint8_t i = 0; i < 8; i++) { reset_pin_number(self->data0_pin + i); } @@ -110,8 +110,8 @@ void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_o reset_pin_number(self->reset.pin->number); } -bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplaybus_parallelbus_reset(mp_obj_t obj) { + paralleldisplaybus_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->reset.base.type == &mp_type_NoneType) { return false; } @@ -122,19 +122,19 @@ bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { return true; } -bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplaybus_parallelbus_bus_free(mp_obj_t obj) { return true; } -bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplaybus_parallelbus_begin_transaction(mp_obj_t obj) { + paralleldisplaybus_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); return true; } -void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplaybus_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) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplaybus_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; @@ -146,7 +146,7 @@ void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type } } -void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +void common_hal_paralleldisplaybus_parallelbus_end_transaction(mp_obj_t obj) { + paralleldisplaybus_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/paralleldisplay/ParallelBus.h b/ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.h similarity index 87% rename from ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.h rename to ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.h index 5ef7bcf195..f1435352dd 100644 --- a/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.h +++ b/ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.h @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H -#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H +#pragma once #include "common-hal/digitalio/DigitalInOut.h" @@ -40,6 +39,4 @@ typedef struct { uint8_t data0_pin; PortGroup *write_group; uint32_t write_mask; -} paralleldisplay_parallelbus_obj_t; - -#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H +} paralleldisplaybus_parallelbus_obj_t; diff --git a/ports/broadcom/mpconfigport.mk b/ports/broadcom/mpconfigport.mk index b992d24f0e..543e174683 100644 --- a/ports/broadcom/mpconfigport.mk +++ b/ports/broadcom/mpconfigport.mk @@ -11,7 +11,7 @@ CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CTARGET = 0 CIRCUITPY_NVM = 0 -CIRCUITPY_PARALLELDISPLAY = 0 +CIRCUITPY_PARALLELDISPLAYBUS = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 0 CIRCUITPY_ROTARYIO = 0 diff --git a/ports/espressif/boards/01space_lcd042_esp32c3/board.c b/ports/espressif/boards/01space_lcd042_esp32c3/board.c index 53f6e4a48e..3bc314b498 100644 --- a/ports/espressif/boards/01space_lcd042_esp32c3/board.c +++ b/ports/espressif/boards/01space_lcd042_esp32c3/board.c @@ -26,7 +26,7 @@ */ #include "shared-bindings/board/__init__.h" -#include "shared-bindings/displayio/I2CDisplay.h" +#include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/busio/I2C.h" @@ -59,17 +59,17 @@ void board_init(void) { // common_hal_busio_i2c_construct(i2c, &pin_GPIO23, &pin_GPIO22, 100000, 0); // common_hal_busio_i2c_never_reset(i2c); - displayio_i2cdisplay_obj_t *bus = &allocate_display_bus()->i2cdisplay_bus; - bus->base.type = &displayio_i2cdisplay_type; - common_hal_displayio_i2cdisplay_construct(bus, + i2cdisplaybus_i2cdisplaybus_obj_t *bus = &allocate_display_bus()->i2cdisplay_bus; + bus->base.type = &i2cdisplaybus_i2cdisplaybus_type; + common_hal_i2cdisplaybus_i2cdisplaybus_construct(bus, i2c, 0x3c, NULL ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 72, // Width 40, // Height diff --git a/ports/espressif/boards/adafruit_esp32s3_camera/board.c b/ports/espressif/boards/adafruit_esp32s3_camera/board.c index 83396b81a2..b9ddba9f0d 100644 --- a/ports/espressif/boards/adafruit_esp32s3_camera/board.c +++ b/ports/espressif/boards/adafruit_esp32s3_camera/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" @@ -38,7 +38,7 @@ #include "esp_err.h" #include "driver/i2c.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -116,9 +116,9 @@ static void io_expander_backlight_init(void) { void board_init(void) { io_expander_backlight_init(); busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO40, // TFT_DC Command or data &pin_GPIO39, // TFT_CS Chip select @@ -127,9 +127,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct( + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // Width (after rotation) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_reverse_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_reverse_tft/board.c index ef6908d50a..0e0c35bcbf 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_reverse_tft/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_reverse_tft/board.c @@ -27,13 +27,13 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -72,10 +72,10 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO40, // DC @@ -85,10 +85,10 @@ void board_init(void) { 0, // polarity 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c index ce0aa8d2b9..f383f4de25 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c @@ -27,13 +27,13 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -72,10 +72,10 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO39, // DC @@ -85,10 +85,10 @@ void board_init(void) { 0, // polarity 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/adafruit_feather_esp32s3_reverse_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s3_reverse_tft/board.c index ef6908d50a..0e0c35bcbf 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s3_reverse_tft/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s3_reverse_tft/board.c @@ -27,13 +27,13 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -72,10 +72,10 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO40, // DC @@ -85,10 +85,10 @@ void board_init(void) { 0, // polarity 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/adafruit_feather_esp32s3_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s3_tft/board.c index 18f361cc06..0b6e4d8abe 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s3_tft/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s3_tft/board.c @@ -27,13 +27,13 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -72,10 +72,10 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO39, // DC @@ -85,10 +85,10 @@ void board_init(void) { 0, // polarity 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/adafruit_feather_esp32s3_tft/mpconfigboard.mk b/ports/espressif/boards/adafruit_feather_esp32s3_tft/mpconfigboard.mk index a94670910b..34bbb872b9 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s3_tft/mpconfigboard.mk +++ b/ports/espressif/boards/adafruit_feather_esp32s3_tft/mpconfigboard.mk @@ -6,7 +6,7 @@ USB_MANUFACTURER = "Adafruit" IDF_TARGET = esp32s3 -CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_MODE = qio CIRCUITPY_ESP_FLASH_FREQ = 80m CIRCUITPY_ESP_FLASH_SIZE = 4MB diff --git a/ports/espressif/boards/adafruit_funhouse/board.c b/ports/espressif/boards/adafruit_funhouse/board.c index daa4aa474e..a19ceda837 100644 --- a/ports/espressif/boards/adafruit_funhouse/board.c +++ b/ports/espressif/boards/adafruit_funhouse/board.c @@ -28,14 +28,14 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "esp_log.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -50,13 +50,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO39, // TFT_DC Command or data &pin_GPIO40, // TFT_CS Chip select @@ -65,9 +65,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct( + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // Width (after rotation) diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c index bd5ad77c93..841c241b31 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "supervisor/shared/board.h" @@ -114,13 +114,13 @@ const uint8_t refresh_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO7, // EPD_DC Command or data &pin_GPIO8, // EPD_CS Chip select @@ -129,9 +129,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; - display->base.type = &displayio_epaperdisplay_type; - common_hal_displayio_epaperdisplay_construct( + epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; + display->base.type = &epaperdisplay_epaperdisplay_type; + common_hal_epaperdisplay_epaperdisplay_construct( display, bus, display_start_sequence, sizeof(display_start_sequence), @@ -189,10 +189,10 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) { } void board_deinit(void) { - displayio_epaperdisplay_obj_t *display = &displays[0].epaper_display; - if (display->base.type == &displayio_epaperdisplay_type) { + epaperdisplay_epaperdisplay_obj_t *display = &displays[0].epaper_display; + if (display->base.type == &epaperdisplay_epaperdisplay_type) { size_t i = 0; - while (common_hal_displayio_epaperdisplay_get_busy(display)) { + while (common_hal_epaperdisplay_epaperdisplay_get_busy(display)) { RUN_BACKGROUND_TASKS; i++; } diff --git a/ports/espressif/boards/espressif_esp32s3_box/board.c b/ports/espressif/boards/espressif_esp32s3_box/board.c index 4a2ce0efed..3ab932c83a 100644 --- a/ports/espressif/boards/espressif_esp32s3_box/board.c +++ b/ports/espressif/boards/espressif_esp32s3_box/board.c @@ -29,7 +29,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" @@ -43,13 +43,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO7, &pin_GPIO6, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO4, // TFT_DC Command or data &pin_GPIO5, // TFT_CS Chip select @@ -58,9 +58,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 320, // Width 240, // Height diff --git a/ports/espressif/boards/espressif_esp32s3_box_lite/board.c b/ports/espressif/boards/espressif_esp32s3_box_lite/board.c index 1917e6df4c..fe9cc993e8 100644 --- a/ports/espressif/boards/espressif_esp32s3_box_lite/board.c +++ b/ports/espressif/boards/espressif_esp32s3_box_lite/board.c @@ -29,7 +29,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" @@ -44,13 +44,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO7, &pin_GPIO6, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO4, // TFT_DC Command or data &pin_GPIO5, // TFT_CS Chip select @@ -59,9 +59,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 320, // Width 240, // Height diff --git a/ports/espressif/boards/espressif_esp32s3_eye/board.c b/ports/espressif/boards/espressif_esp32s3_eye/board.c index 49535de902..58bd9dcb4e 100644 --- a/ports/espressif/boards/espressif_esp32s3_eye/board.c +++ b/ports/espressif/boards/espressif_esp32s3_eye/board.c @@ -27,13 +27,13 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -71,10 +71,10 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO43, // DC @@ -84,10 +84,10 @@ void board_init(void) { 0, // polarity 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/board.c b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/board.c index 197dea0a49..3dd272b622 100644 --- a/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/board.c +++ b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/board.c @@ -29,7 +29,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" @@ -71,13 +71,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO6, &pin_GPIO7, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO4, // TFT_DC Command or data &pin_GPIO5, // TFT_CS Chip select @@ -86,9 +86,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 240, // Width 240, // Height diff --git a/ports/espressif/boards/hardkernel_odroid_go/board.c b/ports/espressif/boards/hardkernel_odroid_go/board.c index 54ecd27ff3..141a891d57 100644 --- a/ports/espressif/boards/hardkernel_odroid_go/board.c +++ b/ports/espressif/boards/hardkernel_odroid_go/board.c @@ -27,7 +27,7 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" @@ -63,13 +63,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO18, &pin_GPIO23, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO21, // TFT_DC Command or data &pin_GPIO5, // TFT_CS Chip select @@ -78,9 +78,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 320, // Width (after rotation) 240, // Height (after rotation) diff --git a/ports/espressif/boards/hexky_s2/board.c b/ports/espressif/boards/hexky_s2/board.c index ef99a96e1d..ddcfe5f7f9 100644 --- a/ports/espressif/boards/hexky_s2/board.c +++ b/ports/espressif/boards/hexky_s2/board.c @@ -27,13 +27,13 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -72,10 +72,10 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO34, // DC @@ -85,10 +85,10 @@ void board_init(void) { 0, // polarity 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/hiibot_iots2/board.c b/ports/espressif/boards/hiibot_iots2/board.c index 8524c80202..8720aa1b5c 100644 --- a/ports/espressif/boards/hiibot_iots2/board.c +++ b/ports/espressif/boards/hiibot_iots2/board.c @@ -65,7 +65,7 @@ uint8_t display_init_sequence[] = { }; static void display_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct( @@ -77,9 +77,9 @@ static void display_init(void) { common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO35, // DC @@ -90,10 +90,10 @@ static void display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/lilygo_tembed_esp32s3/board.c b/ports/espressif/boards/lilygo_tembed_esp32s3/board.c index ee48d50288..8039f618f0 100644 --- a/ports/espressif/boards/lilygo_tembed_esp32s3/board.c +++ b/ports/espressif/boards/lilygo_tembed_esp32s3/board.c @@ -29,7 +29,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" @@ -43,13 +43,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO12, &pin_GPIO11, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO13, // TFT_DC Command or data &pin_GPIO10, // TFT_CS Chip select @@ -58,9 +58,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 320, // Width 170, // Height diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c index f6ac6ede2d..e2970b5bfc 100644 --- a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c @@ -65,7 +65,7 @@ uint8_t display_init_sequence[] = { }; static void display_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct( @@ -77,9 +77,9 @@ static void display_init(void) { common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO37, // DC @@ -90,10 +90,10 @@ static void display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/board.c b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/board.c index 916f1d0a78..1821f7de49 100644 --- a/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/board.c +++ b/ports/espressif/boards/lilygo_ttgo_tdisplay_esp32_16m/board.c @@ -45,7 +45,7 @@ uint8_t display_init_sequence[] = { }; static void display_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct( @@ -57,9 +57,9 @@ static void display_init(void) { common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO16, // DC @@ -71,10 +71,10 @@ static void display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/lilygo_twatch_2020_v3/board.c b/ports/espressif/boards/lilygo_twatch_2020_v3/board.c index de2b79b895..4952093652 100644 --- a/ports/espressif/boards/lilygo_twatch_2020_v3/board.c +++ b/ports/espressif/boards/lilygo_twatch_2020_v3/board.c @@ -48,7 +48,7 @@ uint8_t display_init_sequence[] = { }; static void display_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct( @@ -61,9 +61,9 @@ static void display_init(void) { common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO27, // DC @@ -74,10 +74,10 @@ static void display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/lolin_s2_pico/board.c b/ports/espressif/boards/lolin_s2_pico/board.c index dfac8d0f57..541b9020d4 100644 --- a/ports/espressif/boards/lolin_s2_pico/board.c +++ b/ports/espressif/boards/lolin_s2_pico/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/board/__init__.h" -#include "shared-bindings/displayio/I2CDisplay.h" +#include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/busio/I2C.h" @@ -54,17 +54,17 @@ uint8_t display_init_sequence[] = { // SSD1306 static void display_init(void) { busio_i2c_obj_t *i2c = common_hal_board_create_i2c(0); - displayio_i2cdisplay_obj_t *bus = &allocate_display_bus()->i2cdisplay_bus; - bus->base.type = &displayio_i2cdisplay_type; - common_hal_displayio_i2cdisplay_construct(bus, + i2cdisplaybus_i2cdisplaybus_obj_t *bus = &allocate_display_bus()->i2cdisplay_bus; + bus->base.type = &i2cdisplaybus_i2cdisplaybus_type; + common_hal_i2cdisplaybus_i2cdisplaybus_construct(bus, i2c, 0x3c, &pin_GPIO18 // reset ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 128, // Width 32, // Height diff --git a/ports/espressif/boards/m5stack_atoms3/board.c b/ports/espressif/boards/m5stack_atoms3/board.c index ee8b6c8f4d..5b7faf2bec 100644 --- a/ports/espressif/boards/m5stack_atoms3/board.c +++ b/ports/espressif/boards/m5stack_atoms3/board.c @@ -27,13 +27,13 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -51,14 +51,14 @@ uint8_t display_init_sequence[] = { void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; // busio_spi_obj_t *spi = common_hal_board_create_spi(0); busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO17, &pin_GPIO21, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO33, // DC @@ -68,10 +68,10 @@ void board_init(void) { 0, // polarity 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 128, // width (after rotation) diff --git a/ports/espressif/boards/m5stack_core2/board.c b/ports/espressif/boards/m5stack_core2/board.c index 29011638b2..f8abd4df62 100644 --- a/ports/espressif/boards/m5stack_core2/board.c +++ b/ports/espressif/boards/m5stack_core2/board.c @@ -27,7 +27,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/busio/I2C.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" @@ -40,7 +40,7 @@ #include "../../pmic/axp192/axp192.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 #define PMIC_POWER_SOURCE_USB 0 @@ -333,10 +333,10 @@ static bool pmic_init(busio_i2c_obj_t *i2c) { static bool display_init(void) { busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO15, // DC @@ -347,10 +347,10 @@ static bool display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 320, // width (after rotation) diff --git a/ports/espressif/boards/m5stack_core_basic/board.c b/ports/espressif/boards/m5stack_core_basic/board.c index 270f3a64ed..6a125015f7 100644 --- a/ports/espressif/boards/m5stack_core_basic/board.c +++ b/ports/espressif/boards/m5stack_core_basic/board.c @@ -27,13 +27,13 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; // display init sequence according to M5Gfx @@ -57,10 +57,10 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO27, // DC @@ -71,10 +71,10 @@ void board_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 320, // width (after rotation) diff --git a/ports/espressif/boards/m5stack_core_fire/board.c b/ports/espressif/boards/m5stack_core_fire/board.c index 270f3a64ed..6a125015f7 100644 --- a/ports/espressif/boards/m5stack_core_fire/board.c +++ b/ports/espressif/boards/m5stack_core_fire/board.c @@ -27,13 +27,13 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; // display init sequence according to M5Gfx @@ -57,10 +57,10 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = common_hal_board_create_spi(0); - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO27, // DC @@ -71,10 +71,10 @@ void board_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 320, // width (after rotation) diff --git a/ports/espressif/boards/m5stack_m5paper/board.c b/ports/espressif/boards/m5stack_m5paper/board.c index 55d1f3e349..747a3c6f6b 100644 --- a/ports/espressif/boards/m5stack_m5paper/board.c +++ b/ports/espressif/boards/m5stack_m5paper/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-bindings/board/__init__.h" @@ -50,9 +50,9 @@ void board_init(void) { // common_hal_busio_spi_never_reset(spi); // // Set up the DisplayIO pin object - // displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - // bus->base.type = &displayio_fourwire_type; - // common_hal_displayio_fourwire_construct(bus, + // fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + // bus->base.type = &fourwire_fourwire_type; + // common_hal_fourwire_fourwire_construct(bus, // spi, // &pin_GPIO20, // EPD_DC Command or data // &pin_GPIO15, // EPD_CS Chip select @@ -61,10 +61,10 @@ void board_init(void) { // 0, // Polarity // 0); // Phase - // displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; - // display->base.type = &displayio_epaperdisplay_type; + // epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; + // display->base.type = &epaperdisplay_epaperdisplay_type; - // common_hal_displayio_epaperdisplay_construct( + // common_hal_epaperdisplay_epaperdisplay_construct( // display, // bus, // display_start_sequence, sizeof(display_start_sequence), diff --git a/ports/espressif/boards/m5stack_stick_c/board.c b/ports/espressif/boards/m5stack_stick_c/board.c index 7f9b5a54f4..4d33b21c58 100644 --- a/ports/espressif/boards/m5stack_stick_c/board.c +++ b/ports/espressif/boards/m5stack_stick_c/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/busio/I2C.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" @@ -165,14 +165,14 @@ static bool pmic_init(busio_i2c_obj_t *i2c) { } static bool display_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO13, &pin_GPIO15, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO23, // DC @@ -183,10 +183,10 @@ static bool display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 80, // width (after rotation) diff --git a/ports/espressif/boards/m5stack_stick_c_plus/board.c b/ports/espressif/boards/m5stack_stick_c_plus/board.c index 5901f8cea8..6d58e3a0a4 100644 --- a/ports/espressif/boards/m5stack_stick_c_plus/board.c +++ b/ports/espressif/boards/m5stack_stick_c_plus/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/busio/I2C.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/board/__init__.h" @@ -165,14 +165,14 @@ static bool pmic_init(busio_i2c_obj_t *i2c) { } static bool display_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO13, &pin_GPIO15, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO23, // DC @@ -183,10 +183,10 @@ static bool display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 135, // width (after rotation) diff --git a/ports/espressif/boards/maker_badge/board.c b/ports/espressif/boards/maker_badge/board.c index 45a7be2380..69b742cad2 100644 --- a/ports/espressif/boards/maker_badge/board.c +++ b/ports/espressif/boards/maker_badge/board.c @@ -27,7 +27,7 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "supervisor/shared/board.h" diff --git a/ports/espressif/boards/morpheans_morphesp-240/board.c b/ports/espressif/boards/morpheans_morphesp-240/board.c index b4c0db304a..cd3e0c6103 100644 --- a/ports/espressif/boards/morpheans_morphesp-240/board.c +++ b/ports/espressif/boards/morpheans_morphesp-240/board.c @@ -141,7 +141,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { // Display - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct( @@ -153,9 +153,9 @@ void board_init(void) { common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO14, // DC @@ -166,9 +166,9 @@ void board_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct( + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/espressif/boards/waveshare_esp32_s2_pico_lcd/board.c b/ports/espressif/boards/waveshare_esp32_s2_pico_lcd/board.c index c49e1b8d45..97d3bcabbe 100644 --- a/ports/espressif/boards/waveshare_esp32_s2_pico_lcd/board.c +++ b/ports/espressif/boards/waveshare_esp32_s2_pico_lcd/board.c @@ -64,7 +64,7 @@ uint8_t display_init_sequence[] = { }; static void display_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct( @@ -76,9 +76,9 @@ static void display_init(void) { common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO18, // DC @@ -89,10 +89,10 @@ static void display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 160, // width (after rotation) diff --git a/ports/espressif/common-hal/paralleldisplay/ParallelBus.c b/ports/espressif/common-hal/paralleldisplaybus/ParallelBus.c similarity index 83% rename from ports/espressif/common-hal/paralleldisplay/ParallelBus.c rename to ports/espressif/common-hal/paralleldisplaybus/ParallelBus.c index 49008948b7..352c6d4a9b 100644 --- a/ports/espressif/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/espressif/common-hal/paralleldisplaybus/ParallelBus.c @@ -27,7 +27,7 @@ #include #include -#include "shared-bindings/paralleldisplay/ParallelBus.h" +#include "shared-bindings/paralleldisplaybus/ParallelBus.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/__init__.h" @@ -43,7 +43,7 @@ * - data0 pin must be byte aligned */ -void common_hal_paralleldisplay_parallelbus_construct_nonsequential(paralleldisplay_parallelbus_obj_t *self, +void common_hal_paralleldisplaybus_parallelbus_construct_nonsequential(paralleldisplaybus_parallelbus_obj_t *self, uint8_t n_pins, const mcu_pin_obj_t **data_pins, 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) { @@ -111,7 +111,7 @@ void common_hal_paralleldisplay_parallelbus_construct_nonsequential(paralleldisp } -void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, +void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_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) { char buf[7]; @@ -121,11 +121,11 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu data_pins[i] = validate_obj_is_free_pin( mp_obj_dict_get(MP_OBJ_FROM_PTR(&mcu_pin_globals), mp_obj_new_str(buf, strlen(buf))), MP_QSTR_pin); } - common_hal_paralleldisplay_parallelbus_construct_nonsequential(self, 8, data_pins, command, chip_select, write, read, reset, frequency); + common_hal_paralleldisplaybus_parallelbus_construct_nonsequential(self, 8, data_pins, command, chip_select, write, read, reset, frequency); } -void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { +void common_hal_paralleldisplaybus_parallelbus_deinit(paralleldisplaybus_parallelbus_obj_t *self) { if (!self->handle) { return; } @@ -145,9 +145,9 @@ void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_o port_i2s_reset_instance(0); } -bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { +bool common_hal_paralleldisplaybus_parallelbus_reset(mp_obj_t obj) { /* SNIP - same as from SAMD and NRF ports */ - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplaybus_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->reset_pin_number == NO_PIN) { return false; } @@ -159,13 +159,13 @@ bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { } -bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplaybus_parallelbus_bus_free(mp_obj_t obj) { /* SNIP - same as from SAMD and NRF ports */ return true; } -bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplaybus_parallelbus_begin_transaction(mp_obj_t obj) { + paralleldisplaybus_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); bool lock_acquired = false; i2s_lcd_acquire_nonblocking(self->handle, 1, &lock_acquired); if (lock_acquired) { @@ -174,17 +174,17 @@ bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { return lock_acquired; } -void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplaybus_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) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplaybus_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); if (data_length) { gpio_set_level(self->config.pin_num_rs, byte_type == DISPLAY_DATA); i2s_lcd_write(self->handle, data, data_length); } } -void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +void common_hal_paralleldisplaybus_parallelbus_end_transaction(mp_obj_t obj) { + paralleldisplaybus_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); i2s_lcd_release(self->handle); gpio_set_level(self->config.pin_num_cs, true); } diff --git a/ports/espressif/common-hal/paralleldisplay/ParallelBus.h b/ports/espressif/common-hal/paralleldisplaybus/ParallelBus.h similarity index 84% rename from ports/espressif/common-hal/paralleldisplay/ParallelBus.h rename to ports/espressif/common-hal/paralleldisplaybus/ParallelBus.h index c46d3cb0b8..87e6f0b057 100644 --- a/ports/espressif/common-hal/paralleldisplay/ParallelBus.h +++ b/ports/espressif/common-hal/paralleldisplaybus/ParallelBus.h @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H -#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H +#pragma once #include "common-hal/digitalio/DigitalInOut.h" #include "i2s_lcd_driver.h" @@ -36,6 +35,4 @@ typedef struct { gpio_num_t reset_pin_number; i2s_lcd_config_t config; i2s_lcd_handle_t handle; -} paralleldisplay_parallelbus_obj_t; - -#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H +} paralleldisplaybus_parallelbus_obj_t; diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index 5e94803d1d..cc92211fed 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -37,7 +37,7 @@ CIRCUITPY_IMAGECAPTURE = 0 CIRCUITPY_MEMORYMAP ?= 1 CIRCUITPY_NVM ?= 1 # Turn off because it uses the old I2S driver which conflicts with the new ADC driver. -CIRCUITPY_PARALLELDISPLAY ?= 0 +CIRCUITPY_PARALLELDISPLAYBUS ?= 0 CIRCUITPY_PS2IO ?= 1 CIRCUITPY_RGBMATRIX ?= 1 CIRCUITPY_ROTARYIO ?= 1 diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index b421b583be..20d802eb35 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -24,7 +24,7 @@ CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CTARGET = 0 CIRCUITPY_NVM = 0 -CIRCUITPY_PARALLELDISPLAY = 0 +CIRCUITPY_PARALLELDISPLAYBUS = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_ROTARYIO = 1 CIRCUITPY_ROTARYIO_SOFTENCODER = 1 diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c index 98ec033dc6..4478e0f3ba 100644 --- a/ports/nrf/boards/clue_nrf52840_express/board.c +++ b/ports/nrf/boards/clue_nrf52840_express/board.c @@ -28,11 +28,11 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -47,13 +47,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_P0_13, // TFT_DC Command or data &pin_P0_12, // TFT_CS Chip select @@ -62,9 +62,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 240, // Width (after rotation) 240, // Height (after rotation) diff --git a/ports/nrf/boards/espruino_banglejs2/board.c b/ports/nrf/boards/espruino_banglejs2/board.c index 49a37b7db5..dc741744c8 100644 --- a/ports/nrf/boards/espruino_banglejs2/board.c +++ b/ports/nrf/boards/espruino_banglejs2/board.c @@ -29,7 +29,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/framebufferio/FramebufferDisplay.h" #include "shared-bindings/sharpdisplay/SharpMemoryFramebuffer.h" #include "shared-module/displayio/__init__.h" diff --git a/ports/nrf/boards/hiibot_bluefi/board.c b/ports/nrf/boards/hiibot_bluefi/board.c index d2c9e732b2..d07b316733 100644 --- a/ports/nrf/boards/hiibot_bluefi/board.c +++ b/ports/nrf/boards/hiibot_bluefi/board.c @@ -28,11 +28,11 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -47,13 +47,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_P0_07, &pin_P1_08, NULL, false); // SCK, MOSI, MISO, not half-duplex common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_P0_27, // TFT_DC Command or data &pin_P0_05, // TFT_CS Chip select @@ -63,9 +63,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 240, // Width (after rotation) 240, // Height (after rotation) diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c index 1fea4b2b9f..a22d96e959 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c +++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c @@ -29,11 +29,11 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -48,13 +48,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_P0_08, // TFT_DC Command or data &pin_P0_06, // TFT_CS Chip select @@ -63,9 +63,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 240, // Width (after rotation) 240, // Height (after rotation) diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c index 568357eacb..7b48e1985d 100644 --- a/ports/nrf/boards/ohs2020_badge/board.c +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -28,11 +28,11 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -47,13 +47,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_P0_08, // TFT_DC Command or data &pin_P0_14, // TFT_CS Chip select @@ -62,9 +62,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 240, // Width (after rotation) 240, // Height (after rotation) diff --git a/ports/nrf/common-hal/paralleldisplay/ParallelBus.c b/ports/nrf/common-hal/paralleldisplaybus/ParallelBus.c similarity index 85% rename from ports/nrf/common-hal/paralleldisplay/ParallelBus.c rename to ports/nrf/common-hal/paralleldisplaybus/ParallelBus.c index 6f84ceb214..55a722f47e 100644 --- a/ports/nrf/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/nrf/common-hal/paralleldisplaybus/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/paralleldisplay/ParallelBus.h" +#include "shared-bindings/paralleldisplaybus/ParallelBus.h" #include @@ -33,7 +33,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/__init__.h" -void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, +void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_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_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu 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_paralleldisplay_parallelbus_reset(self); + common_hal_paralleldisplaybus_parallelbus_reset(self); } never_reset_pin_number(command->number); @@ -106,7 +106,7 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu } } -void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { +void common_hal_paralleldisplaybus_parallelbus_deinit(paralleldisplaybus_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_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_o reset_pin_number(self->reset.pin->number); } -bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplaybus_parallelbus_reset(mp_obj_t obj) { + paralleldisplaybus_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_paralleldisplay_parallelbus_reset(mp_obj_t obj) { return true; } -bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplaybus_parallelbus_bus_free(mp_obj_t obj) { return true; } -bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplaybus_parallelbus_begin_transaction(mp_obj_t obj) { + paralleldisplaybus_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_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplaybus_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) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplaybus_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_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type } } -void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +void common_hal_paralleldisplaybus_parallelbus_end_transaction(mp_obj_t obj) { + paralleldisplaybus_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/paralleldisplay/ParallelBus.h b/ports/nrf/common-hal/paralleldisplaybus/ParallelBus.h similarity index 86% rename from ports/nrf/common-hal/paralleldisplay/ParallelBus.h rename to ports/nrf/common-hal/paralleldisplaybus/ParallelBus.h index 14ba7bbc11..759bf88f37 100644 --- a/ports/nrf/common-hal/paralleldisplay/ParallelBus.h +++ b/ports/nrf/common-hal/paralleldisplaybus/ParallelBus.h @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H -#define MICROPY_INCLUDED_NRF_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H +#pragma once #include "common-hal/digitalio/DigitalInOut.h" @@ -40,6 +39,4 @@ typedef struct { uint8_t data0_pin; NRF_GPIO_Type *write_group; uint32_t write_mask; -} paralleldisplay_parallelbus_obj_t; - -#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H +} paralleldisplaybus_parallelbus_obj_t; diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c index 25d8dbe831..0006b80260 100644 --- a/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c @@ -25,7 +25,7 @@ */ #include "shared-bindings/board/__init__.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "shared-bindings/busio/SPI.h" @@ -34,7 +34,7 @@ #include "supervisor/board.h" #include "supervisor/shared/board.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -59,13 +59,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO26, &pin_GPIO27, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO24, // Command or data &pin_GPIO22, // Chip select @@ -74,9 +74,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 128, // Width 64, // Height diff --git a/ports/raspberrypi/boards/hack_club_sprig/board.c b/ports/raspberrypi/boards/hack_club_sprig/board.c index 819d7943dc..e101e26d3d 100644 --- a/ports/raspberrypi/boards/hack_club_sprig/board.c +++ b/ports/raspberrypi/boards/hack_club_sprig/board.c @@ -27,12 +27,12 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "supervisor/shared/board.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; // display init sequence from CircuitPython library https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/blob/dfae353330cf051d1f31db9e4b681c8d70900cc5/adafruit_st7735r.py uint8_t display_init_sequence[] = { @@ -78,13 +78,13 @@ uint8_t display_init_sequence[] = { void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO18, &pin_GPIO19, &pin_GPIO16, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO22, // DC &pin_GPIO20, // CS @@ -93,9 +93,9 @@ void board_init(void) { 0, 0); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 160, // Width 128, // Height diff --git a/ports/raspberrypi/boards/lilygo_t_display_rp2040/board.c b/ports/raspberrypi/boards/lilygo_t_display_rp2040/board.c index 4c4c659913..411f1cbfa7 100644 --- a/ports/raspberrypi/boards/lilygo_t_display_rp2040/board.c +++ b/ports/raspberrypi/boards/lilygo_t_display_rp2040/board.c @@ -66,7 +66,7 @@ uint8_t display_init_sequence[] = { }; static void display_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct( @@ -78,9 +78,9 @@ static void display_init(void) { common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO1, // DC @@ -91,10 +91,10 @@ static void display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; - common_hal_displayio_display_construct( + common_hal_busdisplay_busdisplay_construct( display, bus, 240, // width (after rotation) diff --git a/ports/raspberrypi/boards/pajenicko_picopad/board.c b/ports/raspberrypi/boards/pajenicko_picopad/board.c index e81525d0d8..c02c65d160 100644 --- a/ports/raspberrypi/boards/pajenicko_picopad/board.c +++ b/ports/raspberrypi/boards/pajenicko_picopad/board.c @@ -27,12 +27,12 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "supervisor/shared/board.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -64,13 +64,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO18, &pin_GPIO19, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO17, // TFT_DC Command or data &pin_GPIO21, // TFT_CS Chip select @@ -79,9 +79,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 320, // Width 240, // Height diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/board.c b/ports/raspberrypi/boards/pimoroni_badger2040/board.c index 6163919e97..b602f8cb65 100644 --- a/ports/raspberrypi/boards/pimoroni_badger2040/board.c +++ b/ports/raspberrypi/boards/pimoroni_badger2040/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "supervisor/shared/board.h" @@ -274,14 +274,14 @@ void board_init(void) { common_hal_digitalio_digitalinout_never_reset(&enable_pin_obj); // Set up the SPI object used to control the display - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO18, &pin_GPIO19, &pin_GPIO16, false); common_hal_busio_spi_never_reset(spi); // Set up the DisplayIO pin object - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO20, // EPD_DC Command or data &pin_GPIO17, // EPD_CS Chip select @@ -291,9 +291,9 @@ void board_init(void) { 0); // Phase // Set up the DisplayIO epaper object - displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; - display->base.type = &displayio_epaperdisplay_type; - common_hal_displayio_epaperdisplay_construct( + epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; + display->base.type = &epaperdisplay_epaperdisplay_type; + common_hal_epaperdisplay_epaperdisplay_construct( display, bus, display_start_sequence, sizeof(display_start_sequence), @@ -328,9 +328,9 @@ void board_init(void) { } void board_deinit(void) { - displayio_epaperdisplay_obj_t *display = &displays[0].epaper_display; - if (display->base.type == &displayio_epaperdisplay_type) { - while (common_hal_displayio_epaperdisplay_get_busy(display)) { + epaperdisplay_epaperdisplay_obj_t *display = &displays[0].epaper_display; + if (display->base.type == &epaperdisplay_epaperdisplay_type) { + while (common_hal_epaperdisplay_epaperdisplay_get_busy(display)) { RUN_BACKGROUND_TASKS; } } diff --git a/ports/raspberrypi/boards/pimoroni_badger2040w/board.c b/ports/raspberrypi/boards/pimoroni_badger2040w/board.c index e54e7edd43..770191e8ac 100644 --- a/ports/raspberrypi/boards/pimoroni_badger2040w/board.c +++ b/ports/raspberrypi/boards/pimoroni_badger2040w/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-bindings/board/__init__.h" @@ -279,9 +279,9 @@ void board_init(void) { common_hal_busio_spi_never_reset(spi); // Set up the DisplayIO pin object - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO20, // EPD_DC Command or data &pin_GPIO17, // EPD_CS Chip select @@ -291,9 +291,9 @@ void board_init(void) { 0); // Phase // Set up the DisplayIO epaper object - displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; - display->base.type = &displayio_epaperdisplay_type; - common_hal_displayio_epaperdisplay_construct( + epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; + display->base.type = &epaperdisplay_epaperdisplay_type; + common_hal_epaperdisplay_epaperdisplay_construct( display, bus, display_start_sequence, sizeof(display_start_sequence), @@ -328,9 +328,9 @@ void board_init(void) { } void board_deinit(void) { - displayio_epaperdisplay_obj_t *display = &displays[0].epaper_display; - if (display->base.type == &displayio_epaperdisplay_type) { - while (common_hal_displayio_epaperdisplay_get_busy(display)) { + epaperdisplay_epaperdisplay_obj_t *display = &displays[0].epaper_display; + if (display->base.type == &epaperdisplay_epaperdisplay_type) { + while (common_hal_epaperdisplay_epaperdisplay_get_busy(display)) { RUN_BACKGROUND_TASKS; } } diff --git a/ports/raspberrypi/boards/pimoroni_inky_frame_5_7/board.c b/ports/raspberrypi/boards/pimoroni_inky_frame_5_7/board.c index 53fd01b75a..d2400d243b 100644 --- a/ports/raspberrypi/boards/pimoroni_inky_frame_5_7/board.c +++ b/ports/raspberrypi/boards/pimoroni_inky_frame_5_7/board.c @@ -28,7 +28,7 @@ #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-bindings/board/__init__.h" @@ -62,11 +62,11 @@ const uint8_t refresh_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = common_hal_board_create_spi(0); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO28, // EPD_DC Command or data &pin_GPIO17, // EPD_CS Chip select @@ -75,9 +75,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; - display->base.type = &displayio_epaperdisplay_type; - common_hal_displayio_epaperdisplay_construct( + epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; + display->base.type = &epaperdisplay_epaperdisplay_type; + common_hal_epaperdisplay_epaperdisplay_construct( display, bus, display_start_sequence, sizeof(display_start_sequence), diff --git a/ports/raspberrypi/boards/pimoroni_picosystem/board.c b/ports/raspberrypi/boards/pimoroni_picosystem/board.c index 388c3f2417..5ee7971593 100644 --- a/ports/raspberrypi/boards/pimoroni_picosystem/board.c +++ b/ports/raspberrypi/boards/pimoroni_picosystem/board.c @@ -27,12 +27,12 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" #include "supervisor/shared/board.h" -displayio_fourwire_obj_t board_display_obj; +fourwire_fourwire_obj_t board_display_obj; #define DELAY 0x80 @@ -64,13 +64,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO6, &pin_GPIO7, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO9, // TFT_DC Command or data &pin_GPIO5, // TFT_CS Chip select @@ -79,9 +79,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 240, // Width 240, // Height diff --git a/ports/raspberrypi/boards/ugame22/board.c b/ports/raspberrypi/boards/ugame22/board.c index e816c5e100..48a26f9da0 100644 --- a/ports/raspberrypi/boards/ugame22/board.c +++ b/ports/raspberrypi/boards/ugame22/board.c @@ -30,7 +30,7 @@ #include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" @@ -64,13 +64,13 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct(spi, &pin_GPIO2, &pin_GPIO3, NULL, false); common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, + bus->base.type = &fourwire_fourwire_type; + common_hal_fourwire_fourwire_construct(bus, spi, &pin_GPIO4, // TFT_DC Command or data &pin_GPIO5, // TFT_CS Chip select @@ -79,9 +79,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 320, // Width (after rotation) 240, // Height (after rotation) diff --git a/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/board.c b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/board.c index 2c3ef18805..31750619da 100644 --- a/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/board.c +++ b/ports/raspberrypi/boards/waveshare_rp2040_lcd_0_96/board.c @@ -63,7 +63,7 @@ uint8_t display_init_sequence[] = { }; static void display_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; busio_spi_obj_t *spi = &bus->inline_bus; common_hal_busio_spi_construct( spi, @@ -75,9 +75,9 @@ static void display_init(void) { common_hal_busio_spi_never_reset(spi); - bus->base.type = &displayio_fourwire_type; + bus->base.type = &fourwire_fourwire_type; - common_hal_displayio_fourwire_construct( + common_hal_fourwire_fourwire_construct( bus, spi, &pin_GPIO8, // DC @@ -88,9 +88,9 @@ static void display_init(void) { 0 // phase ); - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct( + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct( display, bus, 160, // width (after rotation) diff --git a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c b/ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.c similarity index 85% rename from ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c rename to ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.c index 827b72ebd7..00ca844cf6 100644 --- a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/paralleldisplay/ParallelBus.h" +#include "shared-bindings/paralleldisplaybus/ParallelBus.h" #include @@ -43,7 +43,7 @@ static const uint16_t parallel_program[] = { // .wrap }; -void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, +void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_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) { @@ -84,7 +84,7 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu 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_paralleldisplay_parallelbus_reset(self); + common_hal_paralleldisplaybus_parallelbus_reset(self); } never_reset_pin_number(command->number); @@ -117,7 +117,7 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu common_hal_rp2pio_statemachine_never_reset(&self->state_machine); } -void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self) { +void common_hal_paralleldisplaybus_parallelbus_deinit(paralleldisplaybus_parallelbus_obj_t *self) { common_hal_rp2pio_statemachine_deinit(&self->state_machine); for (uint8_t i = 0; i < 8; i++) { @@ -135,8 +135,8 @@ void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_o } } -bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplaybus_parallelbus_reset(mp_obj_t obj) { + paralleldisplaybus_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->reset.base.type == &mp_type_NoneType) { return false; } @@ -147,26 +147,26 @@ bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { return true; } -bool common_hal_paralleldisplay_parallelbus_bus_free(mp_obj_t obj) { +bool common_hal_paralleldisplaybus_parallelbus_bus_free(mp_obj_t obj) { return true; } -bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_paralleldisplaybus_parallelbus_begin_transaction(mp_obj_t obj) { + paralleldisplaybus_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); return true; } -void common_hal_paralleldisplay_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, +void common_hal_paralleldisplaybus_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) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); + paralleldisplaybus_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, false); } -void common_hal_paralleldisplay_parallelbus_end_transaction(mp_obj_t obj) { - paralleldisplay_parallelbus_obj_t *self = MP_OBJ_TO_PTR(obj); +void common_hal_paralleldisplaybus_parallelbus_end_transaction(mp_obj_t obj) { + paralleldisplaybus_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/paralleldisplay/ParallelBus.h b/ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.h similarity index 85% rename from ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.h rename to ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.h index 87f149b9b8..55a70b0e0e 100644 --- a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.h +++ b/ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.h @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H -#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H +#pragma once #include "common-hal/digitalio/DigitalInOut.h" #include "bindings/rp2pio/StateMachine.h" @@ -40,6 +39,4 @@ typedef struct { uint8_t write; uint8_t data0_pin; rp2pio_statemachine_obj_t state_machine; -} paralleldisplay_parallelbus_obj_t; - -#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_PARALLELDISPLAY_PARALLELBUS_H +} paralleldisplaybus_parallelbus_obj_t; diff --git a/ports/silabs/mpconfigport.mk b/ports/silabs/mpconfigport.mk index b3a2d63724..b6189e1b87 100644 --- a/ports/silabs/mpconfigport.mk +++ b/ports/silabs/mpconfigport.mk @@ -1,6 +1,6 @@ LONGINT_IMPL ?= MPZ INTERNAL_LIBM ?= 1 -USB_NUM_ENDPOINT_PAIRS ?= 0 +USB_NUM_ENDPOINT_PAIRS = 0 CIRCUITPY_ANALOGIO ?= 1 CIRCUITPY_BLEIO ?= 1 @@ -27,11 +27,11 @@ ifeq ($(MCU_SERIES),MG24) CIRCUITPY_I2CTARGET ?= 0 CIRCUITPY_KEYPAD ?= 0 CIRCUITPY_NEOPIXEL_WRITE ?= 0 - CIRCUITPY_PARALLELDISPLAY ?= 0 + CIRCUITPY_PARALLELDISPLAYBUS ?= 0 CIRCUITPY_PULSEIO ?= 0 CIRCUITPY_ROTARYIO ?= 0 CIRCUITPY_TOUCHIO ?= 0 - CIRCUITPY_USB ?= 0 + CIRCUITPY_USB = 0 endif CIRCUITPY_BUILD_EXTENSIONS ?= bin diff --git a/ports/stm/boards/meowbit_v121/board.c b/ports/stm/boards/meowbit_v121/board.c index 2d67daf806..8c60479540 100644 --- a/ports/stm/boards/meowbit_v121/board.c +++ b/ports/stm/boards/meowbit_v121/board.c @@ -70,10 +70,10 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - bus->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; + bus->base.type = &fourwire_fourwire_type; busio_spi_obj_t *internal_spi = &supervisor_flash_spi_bus; - common_hal_displayio_fourwire_construct(bus, + common_hal_fourwire_fourwire_construct(bus, internal_spi, &pin_PA08, // Command or data &pin_PB12, // Chip select @@ -82,9 +82,9 @@ void board_init(void) { 0, // Polarity 0); // Phase - displayio_display_obj_t *display = &allocate_display()->display; - display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + busdisplay_busdisplay_obj_t *display = &allocate_display()->display; + display->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct(display, bus, 160, // Width 128, // Height diff --git a/ports/stm/mpconfigport.mk b/ports/stm/mpconfigport.mk index cb578e76e2..3266212962 100644 --- a/ports/stm/mpconfigport.mk +++ b/ports/stm/mpconfigport.mk @@ -87,5 +87,5 @@ ifeq ($(MCU_SERIES),L4) UF2_FAMILY_ID ?= 0x00ff6919 endif -CIRCUITPY_PARALLELDISPLAY := 0 +CIRCUITPY_PARALLELDISPLAYBUS := 0 CIRCUITPY_BUILD_EXTENSIONS ?= bin diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 5b87291485..614fae4064 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -152,6 +152,9 @@ endif ifeq ($(CIRCUITPY_BUSDEVICE),1) SRC_PATTERNS += adafruit_bus_device/% endif +ifeq ($(CIRCUITPY_BUSDISPLAY),1) +SRC_PATTERNS += busdisplay/% +endif ifeq ($(CIRCUITPY_BUSIO),1) SRC_PATTERNS += busio/% endif @@ -176,6 +179,9 @@ endif ifeq ($(CIRCUITPY__EVE),1) SRC_PATTERNS += _eve/% endif +ifeq ($(CIRCUITPY_EPAPERDISPLAY),1) +SRC_PATTERNS += epaperdisplay/% +endif ifeq ($(CIRCUITPY_ESPCAMERA),1) SRC_PATTERNS += espcamera/% endif @@ -191,6 +197,9 @@ endif ifeq ($(CIRCUITPY_FLOPPYIO),1) SRC_PATTERNS += floppyio/% endif +ifeq ($(CIRCUITPY_FOURWIRE),1) +SRC_PATTERNS += fourwire/% +endif ifeq ($(CIRCUITPY_FRAMEBUFFERIO),1) SRC_PATTERNS += framebufferio/% endif @@ -212,6 +221,9 @@ endif ifeq ($(CIRCUITPY_HASHLIB),1) SRC_PATTERNS += hashlib/% endif +ifeq ($(CIRCUITPY_I2CDISPLAYBUS),1) +SRC_PATTERNS += i2cdisplaybus/% +endif ifeq ($(CIRCUITPY_I2CTARGET),1) SRC_PATTERNS += i2ctarget/% endif @@ -260,8 +272,8 @@ endif ifeq ($(CIRCUITPY_DUALBANK),1) SRC_PATTERNS += dualbank/% endif -ifeq ($(CIRCUITPY_PARALLELDISPLAY),1) -SRC_PATTERNS += paralleldisplay/% +ifeq ($(CIRCUITPY_PARALLELDISPLAYBUS),1) +SRC_PATTERNS += paralleldisplaybus/% endif ifeq ($(CIRCUITPY_PEW),1) SRC_PATTERNS += _pew/% @@ -465,7 +477,7 @@ SRC_COMMON_HAL_ALL = \ nvm/ByteArray.c \ nvm/__init__.c \ os/__init__.c \ - paralleldisplay/ParallelBus.c \ + paralleldisplaybus/ParallelBus.c \ ps2io/Ps2.c \ ps2io/__init__.c \ pulseio/PulseIn.c \ @@ -534,8 +546,7 @@ $(filter $(SRC_PATTERNS), \ microcontroller/RunMode.c \ msgpack/__init__.c \ msgpack/ExtType.c \ - paralleldisplay/__init__.c \ - paralleldisplay/ParallelBus.c \ + paralleldisplaybus/__init__.c \ qrio/PixelPolicy.c \ qrio/QRInfo.c \ supervisor/RunReason.c \ @@ -587,32 +598,35 @@ SRC_SHARED_MODULE_ALL = \ adafruit_bus_device/__init__.c \ adafruit_bus_device/i2c_device/I2CDevice.c \ adafruit_bus_device/spi_device/SPIDevice.c \ + busdisplay/__init__.c \ + busdisplay/BusDisplay.c \ canio/Match.c \ canio/Message.c \ canio/RemoteTransmissionRequest.c \ displayio/Bitmap.c \ displayio/ColorConverter.c \ - displayio/Display.c \ - displayio/EPaperDisplay.c \ - displayio/FourWire.c \ displayio/Group.c \ - displayio/I2CDisplay.c \ displayio/OnDiskBitmap.c \ displayio/Palette.c \ - displayio/Shape.c \ displayio/TileGrid.c \ displayio/area.c \ displayio/__init__.c \ dotclockframebuffer/__init__.c \ + epaperdisplay/__init__.c \ + epaperdisplay/EPaperDisplay.c \ floppyio/__init__.c \ fontio/BuiltinFont.c \ fontio/__init__.c \ + fourwire/__init__.c \ + fourwire/FourWire.c \ framebufferio/FramebufferDisplay.c \ framebufferio/__init__.c \ getpass/__init__.c \ gifio/__init__.c \ gifio/GifWriter.c \ gifio/OnDiskGif.c \ + i2cdisplaybus/__init__.c \ + i2cdisplaybus/I2CDisplayBus.c \ imagecapture/ParallelImageCapture.c \ ipaddress/IPv4Address.c \ ipaddress/__init__.c \ @@ -633,7 +647,7 @@ SRC_SHARED_MODULE_ALL = \ onewireio/__init__.c \ onewireio/OneWire.c \ os/__init__.c \ - paralleldisplay/ParallelBus.c \ + paralleldisplaybus/ParallelBus.c \ qrio/__init__.c \ qrio/QRDecoder.c \ rainbowio/__init__.c \ @@ -745,6 +759,7 @@ endif # All possible sources are listed here, and are filtered by SRC_PATTERNS. SRC_SHARED_MODULE_INTERNAL = \ $(filter $(SRC_PATTERNS), \ + displayio/bus_core.c \ displayio/display_core.c \ os/getenv.c \ usb/utf16le.c \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 080008607b..84aacaecd3 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -203,12 +203,24 @@ CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO) +CIRCUITPY_BUSDISPLAY ?= $(CIRCUITPY_DISPLAYIO) +CFLAGS += -DCIRCUITPY_BUSDISPLAY=$(CIRCUITPY_BUSDISPLAY) + +CIRCUITPY_FOURWIRE ?= $(CIRCUITPY_DISPLAYIO) +CFLAGS += -DCIRCUITPY_FOURWIRE=$(CIRCUITPY_FOURWIRE) + +CIRCUITPY_EPAPERDISPLAY ?= $(CIRCUITPY_DISPLAYIO) +CFLAGS += -DCIRCUITPY_EPAPERDISPLAY=$(CIRCUITPY_EPAPERDISPLAY) + +CIRCUITPY_I2CDISPLAYBUS ?= $(CIRCUITPY_DISPLAYIO) +CFLAGS += -DCIRCUITPY_I2CDISPLAYBUS=$(CIRCUITPY_I2CDISPLAYBUS) + ifeq ($(CIRCUITPY_DISPLAYIO),1) -CIRCUITPY_PARALLELDISPLAY ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_PARALLELDISPLAYBUS ?= $(CIRCUITPY_FULL_BUILD) else -CIRCUITPY_PARALLELDISPLAY = 0 +CIRCUITPY_PARALLELDISPLAYBUS = 0 endif -CFLAGS += -DCIRCUITPY_PARALLELDISPLAY=$(CIRCUITPY_PARALLELDISPLAY) +CFLAGS += -DCIRCUITPY_PARALLELDISPLAYBUS=$(CIRCUITPY_PARALLELDISPLAYBUS) CIRCUITPY_DOTCLOCKFRAMEBUFFER ?= 0 CFLAGS += -DCIRCUITPY_DOTCLOCKFRAMEBUFFER=$(CIRCUITPY_DOTCLOCKFRAMEBUFFER) diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 46ae93f4ba..c5b139323d 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -28,7 +28,7 @@ #include "py/mperrno.h" #include "py/runtime.h" #include "shared-bindings/busio/SPI.h" -#include "shared-bindings/displayio/Display.h" +#include "shared-bindings/busdisplay/BusDisplay.h" #include "shared-module/_stage/__init__.h" #include "shared-module/displayio/display_core.h" #include "Layer.h" @@ -46,7 +46,7 @@ //| y1: int, //| layers: List[Layer], //| buffer: WriteableBuffer, -//| display: displayio.Display, +//| display: busdisplay.BusDisplay, //| scale: int, //| background: int, //| ) -> None: @@ -59,7 +59,7 @@ //| :param layers: A list of the :py:class:`~_stage.Layer` objects. //| :type layers: list[Layer] //| :param ~circuitpython_typing.WriteableBuffer buffer: A buffer to use for rendering. -//| :param ~displayio.Display display: The display to use. +//| :param ~busdisplay.BusDisplay display: The display to use. //| :param int scale: How many times should the image be scaled up. //| :param int background: What color to display when nothing is there. //| @@ -86,11 +86,11 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { size_t buffer_size = bufinfo.len / 2; // 16-bit indexing mp_obj_t native_display = mp_obj_cast_to_native_base(args[6], - &displayio_display_type); - if (!mp_obj_is_type(native_display, &displayio_display_type)) { + &busdisplay_busdisplay_type); + if (!mp_obj_is_type(native_display, &busdisplay_busdisplay_type)) { mp_raise_TypeError(translate("argument num/types mismatch")); } - displayio_display_obj_t *display = MP_OBJ_TO_PTR(native_display); + busdisplay_busdisplay_obj_t *display = MP_OBJ_TO_PTR(native_display); uint8_t scale = mp_obj_get_int(args[7]); int16_t vx = mp_obj_get_int(args[8]); int16_t vy = mp_obj_get_int(args[9]); diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/busdisplay/BusDisplay.c similarity index 72% rename from shared-bindings/displayio/Display.c rename to shared-bindings/busdisplay/BusDisplay.c index 6bb391960d..c216163ed4 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/busdisplay/BusDisplay.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/Display.h" +#include "shared-bindings/busdisplay/BusDisplay.h" #include @@ -38,15 +38,22 @@ #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -//| _DisplayBus = Union["FourWire", "paralleldisplay.ParallelBus", "I2CDisplay"] -//| """:py:class:`FourWire`, :py:class:`paralleldisplay.ParallelBus` or :py:class:`I2CDisplay`""" +//| import displayio +//| import fourwire +//| import i2cdisplaybus +//| import paralleldisplaybus +//| +//| _DisplayBus = Union[ +//| "fourwire.FourWire", "paralleldisplaybus.ParallelBus", "i2cdisplaybus.I2CDisplayBus" +//| ] +//| """:py:class:`fourwire.FourWire`, :py:class:`paralleldisplaybus.ParallelBus` or :py:class:`i2cdisplaybus.I2CDisplayBus`""" //| -//| class Display: +//| class BusDisplay: //| """Manage updating a display over a display bus //| //| This initializes a display and connects it into CircuitPython. Unlike other -//| objects in CircuitPython, Display objects live until `displayio.release_displays()` +//| objects in CircuitPython, display objects live until `displayio.release_displays()` //| is called. This is done so that CircuitPython can use the display itself. //| //| Most people should not use this class directly. Use a specific display driver instead that will @@ -80,7 +87,7 @@ //| backlight_on_high: bool = True, //| SH1107_addressing: bool = False //| ) -> None: -//| r"""Create a Display object on the given display bus (`FourWire`, `ParallelBus` or `I2CDisplay`). +//| r"""Create a Display object on the given display bus (`FourWire`, `ParallelBus` or `I2CDisplayBus`). //| //| The ``init_sequence`` is bitpacked to minimize the ram impact. Every command begins with a //| command byte followed by a byte to determine the parameter count and delay. When the top bit @@ -138,7 +145,7 @@ //| :param int backlight_pwm_frequency: The frequency to use to drive the PWM for backlight brightness control. Default is 50000. //| """ //| ... -STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, +STATIC mp_obj_t busdisplay_busdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, @@ -202,10 +209,10 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a } primary_display_t *disp = allocate_display_or_raise(); - displayio_display_obj_t *self = &disp->display; + busdisplay_busdisplay_obj_t *self = &disp->display; - self->base.type = &displayio_display_type; - common_hal_displayio_display_construct( + self->base.type = &busdisplay_busdisplay_type; + common_hal_busdisplay_busdisplay_construct( self, display_bus, args[ARG_width].u_int, args[ARG_height].u_int, args[ARG_colstart].u_int, args[ARG_rowstart].u_int, rotation, color_depth, args[ARG_grayscale].u_bool, @@ -232,8 +239,8 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a } // Helper to ensure we have the native super class instead of a subclass. -static displayio_display_obj_t *native_display(mp_obj_t display_obj) { - mp_obj_t native_display = mp_obj_cast_to_native_base(display_obj, &displayio_display_type); +static busdisplay_busdisplay_obj_t *native_display(mp_obj_t display_obj) { + mp_obj_t native_display = mp_obj_cast_to_native_base(display_obj, &busdisplay_busdisplay_type); mp_obj_assert_native_inited(native_display); return MP_OBJ_TO_PTR(native_display); } @@ -264,7 +271,7 @@ static displayio_display_obj_t *native_display(mp_obj_t display_obj) { //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second. //| """ //| ... -STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t busdisplay_busdisplay_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second }; static const mp_arg_t allowed_args[] = { { MP_QSTR_target_frames_per_second, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, @@ -274,7 +281,7 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - displayio_display_obj_t *self = native_display(pos_args[0]); + busdisplay_busdisplay_obj_t *self = native_display(pos_args[0]); uint32_t maximum_ms_per_real_frame = NO_FPS_LIMIT; mp_int_t minimum_frames_per_second = args[ARG_minimum_frames_per_second].u_int; if (minimum_frames_per_second > 0) { @@ -288,140 +295,140 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos target_ms_per_frame = 1000 / mp_obj_get_int(args[ARG_target_frames_per_second].u_obj); } - return mp_obj_new_bool(common_hal_displayio_display_refresh(self, target_ms_per_frame, maximum_ms_per_real_frame)); + return mp_obj_new_bool(common_hal_busdisplay_busdisplay_refresh(self, target_ms_per_frame, maximum_ms_per_real_frame)); } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_refresh_obj, 1, displayio_display_obj_refresh); +MP_DEFINE_CONST_FUN_OBJ_KW(busdisplay_busdisplay_refresh_obj, 1, busdisplay_busdisplay_obj_refresh); //| auto_refresh: bool //| """True when the display is refreshed automatically.""" -STATIC mp_obj_t displayio_display_obj_get_auto_refresh(mp_obj_t self_in) { - displayio_display_obj_t *self = native_display(self_in); - return mp_obj_new_bool(common_hal_displayio_display_get_auto_refresh(self)); +STATIC mp_obj_t busdisplay_busdisplay_obj_get_auto_refresh(mp_obj_t self_in) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); + return mp_obj_new_bool(common_hal_busdisplay_busdisplay_get_auto_refresh(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_auto_refresh_obj, displayio_display_obj_get_auto_refresh); +MP_DEFINE_CONST_FUN_OBJ_1(busdisplay_busdisplay_get_auto_refresh_obj, busdisplay_busdisplay_obj_get_auto_refresh); -STATIC mp_obj_t displayio_display_obj_set_auto_refresh(mp_obj_t self_in, mp_obj_t auto_refresh) { - displayio_display_obj_t *self = native_display(self_in); +STATIC mp_obj_t busdisplay_busdisplay_obj_set_auto_refresh(mp_obj_t self_in, mp_obj_t auto_refresh) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); - common_hal_displayio_display_set_auto_refresh(self, mp_obj_is_true(auto_refresh)); + common_hal_busdisplay_busdisplay_set_auto_refresh(self, mp_obj_is_true(auto_refresh)); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_auto_refresh_obj, displayio_display_obj_set_auto_refresh); +MP_DEFINE_CONST_FUN_OBJ_2(busdisplay_busdisplay_set_auto_refresh_obj, busdisplay_busdisplay_obj_set_auto_refresh); -MP_PROPERTY_GETSET(displayio_display_auto_refresh_obj, - (mp_obj_t)&displayio_display_get_auto_refresh_obj, - (mp_obj_t)&displayio_display_set_auto_refresh_obj); +MP_PROPERTY_GETSET(busdisplay_busdisplay_auto_refresh_obj, + (mp_obj_t)&busdisplay_busdisplay_get_auto_refresh_obj, + (mp_obj_t)&busdisplay_busdisplay_set_auto_refresh_obj); //| brightness: float //| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness.""" -STATIC mp_obj_t displayio_display_obj_get_brightness(mp_obj_t self_in) { - displayio_display_obj_t *self = native_display(self_in); - mp_float_t brightness = common_hal_displayio_display_get_brightness(self); +STATIC mp_obj_t busdisplay_busdisplay_obj_get_brightness(mp_obj_t self_in) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); + mp_float_t brightness = common_hal_busdisplay_busdisplay_get_brightness(self); if (brightness < 0) { mp_raise_RuntimeError(translate("Brightness not adjustable")); } return mp_obj_new_float(brightness); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_brightness_obj, displayio_display_obj_get_brightness); +MP_DEFINE_CONST_FUN_OBJ_1(busdisplay_busdisplay_get_brightness_obj, busdisplay_busdisplay_obj_get_brightness); -STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness_obj) { - displayio_display_obj_t *self = native_display(self_in); +STATIC mp_obj_t busdisplay_busdisplay_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness_obj) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); mp_float_t brightness = mp_obj_get_float(brightness_obj); if (brightness < 0 || brightness > 1.0) { mp_raise_ValueError_varg(translate("%q must be %d-%d"), MP_QSTR_brightness, 0, 1); } - bool ok = common_hal_displayio_display_set_brightness(self, brightness); + bool ok = common_hal_busdisplay_busdisplay_set_brightness(self, brightness); if (!ok) { mp_raise_RuntimeError(translate("Brightness not adjustable")); } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_brightness_obj, displayio_display_obj_set_brightness); +MP_DEFINE_CONST_FUN_OBJ_2(busdisplay_busdisplay_set_brightness_obj, busdisplay_busdisplay_obj_set_brightness); -MP_PROPERTY_GETSET(displayio_display_brightness_obj, - (mp_obj_t)&displayio_display_get_brightness_obj, - (mp_obj_t)&displayio_display_set_brightness_obj); +MP_PROPERTY_GETSET(busdisplay_busdisplay_brightness_obj, + (mp_obj_t)&busdisplay_busdisplay_get_brightness_obj, + (mp_obj_t)&busdisplay_busdisplay_set_brightness_obj); //| width: int //| """Gets the width of the board""" -STATIC mp_obj_t displayio_display_obj_get_width(mp_obj_t self_in) { - displayio_display_obj_t *self = native_display(self_in); - return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_width(self)); +STATIC mp_obj_t busdisplay_busdisplay_obj_get_width(mp_obj_t self_in) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_busdisplay_busdisplay_get_width(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_width_obj, displayio_display_obj_get_width); +MP_DEFINE_CONST_FUN_OBJ_1(busdisplay_busdisplay_get_width_obj, busdisplay_busdisplay_obj_get_width); -MP_PROPERTY_GETTER(displayio_display_width_obj, - (mp_obj_t)&displayio_display_get_width_obj); +MP_PROPERTY_GETTER(busdisplay_busdisplay_width_obj, + (mp_obj_t)&busdisplay_busdisplay_get_width_obj); //| height: int //| """Gets the height of the board""" -STATIC mp_obj_t displayio_display_obj_get_height(mp_obj_t self_in) { - displayio_display_obj_t *self = native_display(self_in); - return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_height(self)); +STATIC mp_obj_t busdisplay_busdisplay_obj_get_height(mp_obj_t self_in) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_busdisplay_busdisplay_get_height(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_height_obj, displayio_display_obj_get_height); +MP_DEFINE_CONST_FUN_OBJ_1(busdisplay_busdisplay_get_height_obj, busdisplay_busdisplay_obj_get_height); -MP_PROPERTY_GETTER(displayio_display_height_obj, - (mp_obj_t)&displayio_display_get_height_obj); +MP_PROPERTY_GETTER(busdisplay_busdisplay_height_obj, + (mp_obj_t)&busdisplay_busdisplay_get_height_obj); //| rotation: int //| """The rotation of the display as an int in degrees.""" -STATIC mp_obj_t displayio_display_obj_get_rotation(mp_obj_t self_in) { - displayio_display_obj_t *self = native_display(self_in); - return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_rotation(self)); +STATIC mp_obj_t busdisplay_busdisplay_obj_get_rotation(mp_obj_t self_in) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_busdisplay_busdisplay_get_rotation(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_rotation_obj, displayio_display_obj_get_rotation); -STATIC mp_obj_t displayio_display_obj_set_rotation(mp_obj_t self_in, mp_obj_t value) { - displayio_display_obj_t *self = native_display(self_in); - common_hal_displayio_display_set_rotation(self, mp_obj_get_int(value)); +MP_DEFINE_CONST_FUN_OBJ_1(busdisplay_busdisplay_get_rotation_obj, busdisplay_busdisplay_obj_get_rotation); +STATIC mp_obj_t busdisplay_busdisplay_obj_set_rotation(mp_obj_t self_in, mp_obj_t value) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); + common_hal_busdisplay_busdisplay_set_rotation(self, mp_obj_get_int(value)); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_rotation_obj, displayio_display_obj_set_rotation); +MP_DEFINE_CONST_FUN_OBJ_2(busdisplay_busdisplay_set_rotation_obj, busdisplay_busdisplay_obj_set_rotation); -MP_PROPERTY_GETSET(displayio_display_rotation_obj, - (mp_obj_t)&displayio_display_get_rotation_obj, - (mp_obj_t)&displayio_display_set_rotation_obj); +MP_PROPERTY_GETSET(busdisplay_busdisplay_rotation_obj, + (mp_obj_t)&busdisplay_busdisplay_get_rotation_obj, + (mp_obj_t)&busdisplay_busdisplay_set_rotation_obj); //| bus: _DisplayBus //| """The bus being used by the display""" -STATIC mp_obj_t displayio_display_obj_get_bus(mp_obj_t self_in) { - displayio_display_obj_t *self = native_display(self_in); - return common_hal_displayio_display_get_bus(self); +STATIC mp_obj_t busdisplay_busdisplay_obj_get_bus(mp_obj_t self_in) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); + return common_hal_busdisplay_busdisplay_get_bus(self); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_bus_obj, displayio_display_obj_get_bus); +MP_DEFINE_CONST_FUN_OBJ_1(busdisplay_busdisplay_get_bus_obj, busdisplay_busdisplay_obj_get_bus); -MP_PROPERTY_GETTER(displayio_display_bus_obj, - (mp_obj_t)&displayio_display_get_bus_obj); +MP_PROPERTY_GETTER(busdisplay_busdisplay_bus_obj, + (mp_obj_t)&busdisplay_busdisplay_get_bus_obj); -//| root_group: Group +//| root_group: displayio.Group //| """The root group on the display. //| If the root group is set to `displayio.CIRCUITPYTHON_TERMINAL`, the default CircuitPython terminal will be shown. //| If the root group is set to ``None``, no output will be shown. //| """ -STATIC mp_obj_t displayio_display_obj_get_root_group(mp_obj_t self_in) { - displayio_display_obj_t *self = native_display(self_in); - return common_hal_displayio_display_get_root_group(self); +STATIC mp_obj_t busdisplay_busdisplay_obj_get_root_group(mp_obj_t self_in) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); + return common_hal_busdisplay_busdisplay_get_root_group(self); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_root_group_obj, displayio_display_obj_get_root_group); +MP_DEFINE_CONST_FUN_OBJ_1(busdisplay_busdisplay_get_root_group_obj, busdisplay_busdisplay_obj_get_root_group); -STATIC mp_obj_t displayio_display_obj_set_root_group(mp_obj_t self_in, mp_obj_t group_in) { - displayio_display_obj_t *self = native_display(self_in); +STATIC mp_obj_t busdisplay_busdisplay_obj_set_root_group(mp_obj_t self_in, mp_obj_t group_in) { + busdisplay_busdisplay_obj_t *self = native_display(self_in); displayio_group_t *group = NULL; if (group_in != mp_const_none) { group = MP_OBJ_TO_PTR(native_group(group_in)); } - common_hal_displayio_display_set_root_group(self, group); + common_hal_busdisplay_busdisplay_set_root_group(self, group); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_root_group_obj, displayio_display_obj_set_root_group); +MP_DEFINE_CONST_FUN_OBJ_2(busdisplay_busdisplay_set_root_group_obj, busdisplay_busdisplay_obj_set_root_group); -MP_PROPERTY_GETSET(displayio_display_root_group_obj, - (mp_obj_t)&displayio_display_get_root_group_obj, - (mp_obj_t)&displayio_display_set_root_group_obj); +MP_PROPERTY_GETSET(busdisplay_busdisplay_root_group_obj, + (mp_obj_t)&busdisplay_busdisplay_get_root_group_obj, + (mp_obj_t)&busdisplay_busdisplay_set_root_group_obj); //| def fill_row(self, y: int, buffer: WriteableBuffer) -> WriteableBuffer: @@ -432,7 +439,7 @@ MP_PROPERTY_GETSET(displayio_display_root_group_obj, //| """ //| ... //| -STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t busdisplay_busdisplay_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_y, ARG_buffer }; static const mp_arg_t allowed_args[] = { { MP_QSTR_y, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = -1} }, @@ -440,7 +447,7 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - displayio_display_obj_t *self = native_display(pos_args[0]); + busdisplay_busdisplay_obj_t *self = native_display(pos_args[0]); mp_int_t y = args[ARG_y].u_int; mp_obj_t *result = args[ARG_buffer].u_obj; @@ -481,28 +488,28 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po mp_raise_ValueError(translate("Buffer too small")); } } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row); +MP_DEFINE_CONST_FUN_OBJ_KW(busdisplay_busdisplay_fill_row_obj, 1, busdisplay_busdisplay_obj_fill_row); -STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&displayio_display_refresh_obj) }, - { MP_ROM_QSTR(MP_QSTR_fill_row), MP_ROM_PTR(&displayio_display_fill_row_obj) }, +STATIC const mp_rom_map_elem_t busdisplay_busdisplay_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&busdisplay_busdisplay_refresh_obj) }, + { MP_ROM_QSTR(MP_QSTR_fill_row), MP_ROM_PTR(&busdisplay_busdisplay_fill_row_obj) }, - { MP_ROM_QSTR(MP_QSTR_auto_refresh), MP_ROM_PTR(&displayio_display_auto_refresh_obj) }, + { MP_ROM_QSTR(MP_QSTR_auto_refresh), MP_ROM_PTR(&busdisplay_busdisplay_auto_refresh_obj) }, - { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&displayio_display_brightness_obj) }, + { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&busdisplay_busdisplay_brightness_obj) }, - { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_display_width_obj) }, - { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) }, - { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_display_rotation_obj) }, - { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) }, - { MP_ROM_QSTR(MP_QSTR_root_group), MP_ROM_PTR(&displayio_display_root_group_obj) }, + { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&busdisplay_busdisplay_width_obj) }, + { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&busdisplay_busdisplay_height_obj) }, + { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&busdisplay_busdisplay_rotation_obj) }, + { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&busdisplay_busdisplay_bus_obj) }, + { MP_ROM_QSTR(MP_QSTR_root_group), MP_ROM_PTR(&busdisplay_busdisplay_root_group_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(displayio_display_locals_dict, displayio_display_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(busdisplay_busdisplay_locals_dict, busdisplay_busdisplay_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( - displayio_display_type, - MP_QSTR_Display, + busdisplay_busdisplay_type, + MP_QSTR_BusDisplay, MP_TYPE_FLAG_NONE, - make_new, displayio_display_make_new, - locals_dict, &displayio_display_locals_dict + make_new, busdisplay_busdisplay_make_new, + locals_dict, &busdisplay_busdisplay_locals_dict ); diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/busdisplay/BusDisplay.h similarity index 56% rename from shared-bindings/displayio/Display.h rename to shared-bindings/busdisplay/BusDisplay.h index af813866ed..2b2b537672 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/busdisplay/BusDisplay.h @@ -24,20 +24,19 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_DISPLAY_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_DISPLAY_H +#pragma once #include "common-hal/microcontroller/Pin.h" -#include "shared-module/displayio/Display.h" +#include "shared-module/busdisplay/BusDisplay.h" #include "shared-module/displayio/Group.h" -extern const mp_obj_type_t displayio_display_type; +extern const mp_obj_type_t busdisplay_busdisplay_type; #define NO_BRIGHTNESS_COMMAND 0x100 #define NO_FPS_LIMIT 0xffffffff -void common_hal_displayio_display_construct(displayio_display_obj_t *self, +void common_hal_busdisplay_busdisplay_construct(busdisplay_busdisplay_obj_t *self, mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word, @@ -47,24 +46,22 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self, bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool backlight_on_high, bool SH1107_addressing, uint16_t backlight_pwm_frequency); -bool common_hal_displayio_display_refresh(displayio_display_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame); +bool common_hal_busdisplay_busdisplay_refresh(busdisplay_busdisplay_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame); -bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t *self); -void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t *self, bool auto_refresh); +bool common_hal_busdisplay_busdisplay_get_auto_refresh(busdisplay_busdisplay_obj_t *self); +void common_hal_busdisplay_busdisplay_set_auto_refresh(busdisplay_busdisplay_obj_t *self, bool auto_refresh); -uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t *self); -uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t *self); -uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t *self); -void common_hal_displayio_display_set_rotation(displayio_display_obj_t *self, int rotation); +uint16_t common_hal_busdisplay_busdisplay_get_width(busdisplay_busdisplay_obj_t *self); +uint16_t common_hal_busdisplay_busdisplay_get_height(busdisplay_busdisplay_obj_t *self); +uint16_t common_hal_busdisplay_busdisplay_get_rotation(busdisplay_busdisplay_obj_t *self); +void common_hal_busdisplay_busdisplay_set_rotation(busdisplay_busdisplay_obj_t *self, int rotation); -bool common_hal_displayio_display_get_dither(displayio_display_obj_t *self); -void common_hal_displayio_display_set_dither(displayio_display_obj_t *self, bool dither); +bool common_hal_busdisplay_busdisplay_get_dither(busdisplay_busdisplay_obj_t *self); +void common_hal_busdisplay_busdisplay_set_dither(busdisplay_busdisplay_obj_t *self, bool dither); -mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t *self); -bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self, mp_float_t brightness); +mp_float_t common_hal_busdisplay_busdisplay_get_brightness(busdisplay_busdisplay_obj_t *self); +bool common_hal_busdisplay_busdisplay_set_brightness(busdisplay_busdisplay_obj_t *self, mp_float_t brightness); -mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t *self); -mp_obj_t common_hal_displayio_display_get_root_group(displayio_display_obj_t *self); -mp_obj_t common_hal_displayio_display_set_root_group(displayio_display_obj_t *self, displayio_group_t *root_group); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_DISPLAY_H +mp_obj_t common_hal_busdisplay_busdisplay_get_bus(busdisplay_busdisplay_obj_t *self); +mp_obj_t common_hal_busdisplay_busdisplay_get_root_group(busdisplay_busdisplay_obj_t *self); +mp_obj_t common_hal_busdisplay_busdisplay_set_root_group(busdisplay_busdisplay_obj_t *self, displayio_group_t *root_group); diff --git a/shared-bindings/busdisplay/__init__.c b/shared-bindings/busdisplay/__init__.c new file mode 100644 index 0000000000..3b93e07c26 --- /dev/null +++ b/shared-bindings/busdisplay/__init__.c @@ -0,0 +1,53 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 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/busdisplay/__init__.h" +#include "shared-bindings/busdisplay/BusDisplay.h" + +//| """Displays a `displayio` object tree on an external device with a built-in +//| framebuffer +//| +//| """ + +STATIC const mp_rom_map_elem_t busdisplay_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, + + { MP_ROM_QSTR(MP_QSTR_BusDisplay), MP_ROM_PTR(&busdisplay_busdisplay_type) }, +}; +STATIC MP_DEFINE_CONST_DICT(busdisplay_module_globals, busdisplay_module_globals_table); + +const mp_obj_module_t busdisplay_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&busdisplay_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_busdisplay, busdisplay_module); diff --git a/shared-bindings/paralleldisplay/__init__.h b/shared-bindings/busdisplay/__init__.h similarity index 100% rename from shared-bindings/paralleldisplay/__init__.h rename to shared-bindings/busdisplay/__init__.h diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c deleted file mode 100644 index 767185f6c9..0000000000 --- a/shared-bindings/displayio/Shape.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of the Micro Python project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 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 "shared-bindings/displayio/Shape.h" - -#include - -#include "py/binary.h" -#include "py/objproperty.h" -#include "py/runtime.h" -#include "shared-bindings/util.h" - -//| class Shape: -//| """Represents a shape made by defining boundaries that may be mirrored.""" -//| -//| def __init__( -//| self, width: int, height: int, *, mirror_x: bool = False, mirror_y: bool = False -//| ) -> None: -//| """Create a Shape object with the given fixed size. Each pixel is one bit and is stored by the -//| column boundaries of the shape on each row. Each row's boundary defaults to the full row. -//| -//| :param int width: The number of pixels wide -//| :param int height: The number of pixels high -//| :param bool mirror_x: When true the left boundary is mirrored to the right. -//| :param bool mirror_y: When true the top boundary is mirrored to the bottom.""" -//| ... -STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_width, ARG_height, ARG_mirror_x, ARG_mirror_y }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_width, MP_ARG_REQUIRED | MP_ARG_INT }, - { MP_QSTR_height, MP_ARG_REQUIRED | MP_ARG_INT }, - { MP_QSTR_mirror_x, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, - { MP_QSTR_mirror_y, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, - }; - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - mp_int_t width = mp_arg_validate_int_min(args[ARG_width].u_int, 1, MP_QSTR_width); - mp_int_t height = mp_arg_validate_int_min(args[ARG_height].u_int, 1, MP_QSTR_height); - - displayio_shape_t *self = mp_obj_malloc(displayio_shape_t, &displayio_shape_type); - common_hal_displayio_shape_construct(self, - width, - height, - args[ARG_mirror_x].u_bool, - args[ARG_mirror_y].u_bool); - - return MP_OBJ_FROM_PTR(self); -} - - -//| def set_boundary(self, y: int, start_x: int, end_x: int) -> None: -//| """Loads pre-packed data into the given row.""" -//| ... -//| -STATIC mp_obj_t displayio_shape_obj_set_boundary(size_t n_args, const mp_obj_t *args) { - (void)n_args; - displayio_shape_t *self = MP_OBJ_TO_PTR(args[0]); - mp_int_t y = mp_arg_validate_type_int(args[1], MP_QSTR_y); - mp_int_t start_x = mp_arg_validate_type_int(args[2], MP_QSTR_start_x); - mp_int_t end_x = mp_arg_validate_type_int(args[3], MP_QSTR_end_x); - common_hal_displayio_shape_set_boundary(self, y, start_x, end_x); - - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(displayio_shape_set_boundary_obj, 4, 4, displayio_shape_obj_set_boundary); - -STATIC const mp_rom_map_elem_t displayio_shape_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_set_boundary), MP_ROM_PTR(&displayio_shape_set_boundary_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(displayio_shape_locals_dict, displayio_shape_locals_dict_table); - -MP_DEFINE_CONST_OBJ_TYPE( - displayio_shape_type, - MP_QSTR_Shape, - MP_TYPE_FLAG_NONE, - make_new, displayio_shape_make_new, - locals_dict, &displayio_shape_locals_dict - ); diff --git a/shared-bindings/displayio/Shape.h b/shared-bindings/displayio/Shape.h deleted file mode 100644 index 961b57c674..0000000000 --- a/shared-bindings/displayio/Shape.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the Micro Python project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 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. - */ - -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_SHAPE_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_SHAPE_H - -#include "shared-module/displayio/Shape.h" - -extern const mp_obj_type_t displayio_shape_type; - -void common_hal_displayio_shape_construct(displayio_shape_t *self, uint32_t width, - uint32_t height, bool mirror_x, bool mirror_y); - -void common_hal_displayio_shape_set_boundary(displayio_shape_t *self, uint16_t y, uint16_t start_x, - uint16_t end_x); -uint32_t common_hal_displayio_shape_get_pixel(void *shape, int16_t x, int16_t y); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_SHAPE_H diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index ed19fd34d7..4bc81a20dd 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -37,7 +37,6 @@ #include "shared-bindings/displayio/ColorConverter.h" #include "shared-bindings/displayio/OnDiskBitmap.h" #include "shared-bindings/displayio/Palette.h" -#include "shared-bindings/displayio/Shape.h" //| class TileGrid: //| """A grid of tiles sourced out of one bitmap @@ -49,7 +48,7 @@ //| //| def __init__( //| self, -//| bitmap: Union[Bitmap, OnDiskBitmap, Shape], +//| bitmap: Union[Bitmap, OnDiskBitmap], //| *, //| pixel_shader: Union[ColorConverter, Palette], //| width: int = 1, @@ -68,7 +67,7 @@ //| //| tile_width and tile_height match the height of the bitmap by default. //| -//| :param Bitmap,OnDiskBitmap,Shape bitmap: The bitmap storing one or more tiles. +//| :param Bitmap,OnDiskBitmap bitmap: The bitmap storing one or more tiles. //| :param ColorConverter,Palette pixel_shader: The pixel shader that produces colors from values //| :param int width: Width of the grid in tiles. //| :param int height: Height of the grid in tiles. @@ -97,19 +96,12 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_ uint16_t bitmap_width; uint16_t bitmap_height; - mp_obj_t native = mp_obj_cast_to_native_base(bitmap, &displayio_shape_type); - if (native != MP_OBJ_NULL) { - displayio_shape_t *bmp = MP_OBJ_TO_PTR(native); - bitmap_width = bmp->width; - bitmap_height = bmp->height; - } else if (mp_obj_is_type(bitmap, &displayio_bitmap_type)) { + if (mp_obj_is_type(bitmap, &displayio_bitmap_type)) { displayio_bitmap_t *bmp = MP_OBJ_TO_PTR(bitmap); - native = bitmap; bitmap_width = bmp->width; bitmap_height = bmp->height; } else if (mp_obj_is_type(bitmap, &displayio_ondiskbitmap_type)) { displayio_ondiskbitmap_t *bmp = MP_OBJ_TO_PTR(bitmap); - native = bitmap; bitmap_width = bmp->width; bitmap_height = bmp->height; } else { @@ -139,7 +131,7 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_ int16_t y = args[ARG_y].u_int; displayio_tilegrid_t *self = mp_obj_malloc(displayio_tilegrid_t, &displayio_tilegrid_type); - common_hal_displayio_tilegrid_construct(self, native, + common_hal_displayio_tilegrid_construct(self, bitmap, bitmap_width / tile_width, bitmap_height / tile_height, pixel_shader, args[ARG_width].u_int, args[ARG_height].u_int, tile_width, tile_height, x, y, args[ARG_default_tile].u_int); @@ -362,7 +354,7 @@ MP_PROPERTY_GETSET(displayio_tilegrid_pixel_shader_obj, (mp_obj_t)&displayio_tilegrid_get_pixel_shader_obj, (mp_obj_t)&displayio_tilegrid_set_pixel_shader_obj); -//| bitmap: Union[Bitmap, OnDiskBitmap, Shape] +//| bitmap: Union[Bitmap, OnDiskBitmap] //| """The bitmap of the tilegrid.""" STATIC mp_obj_t displayio_tilegrid_obj_get_bitmap(mp_obj_t self_in) { displayio_tilegrid_t *self = native_tilegrid(self_in); @@ -375,40 +367,25 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_bitmap(mp_obj_t self_in, mp_obj_t bit uint16_t new_bitmap_width; uint16_t new_bitmap_height; - mp_obj_t native = mp_obj_cast_to_native_base(bitmap, &displayio_shape_type); - if (native != MP_OBJ_NULL) { - displayio_shape_t *bmp = MP_OBJ_TO_PTR(native); - new_bitmap_width = bmp->width; - new_bitmap_height = bmp->height; - } else if (mp_obj_is_type(bitmap, &displayio_bitmap_type)) { + if (mp_obj_is_type(bitmap, &displayio_bitmap_type)) { displayio_bitmap_t *bmp = MP_OBJ_TO_PTR(bitmap); - native = bitmap; new_bitmap_width = bmp->width; new_bitmap_height = bmp->height; } else if (mp_obj_is_type(bitmap, &displayio_ondiskbitmap_type)) { displayio_ondiskbitmap_t *bmp = MP_OBJ_TO_PTR(bitmap); - native = bitmap; new_bitmap_width = bmp->width; new_bitmap_height = bmp->height; } else { mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_bitmap); } - mp_obj_t old_native = mp_obj_cast_to_native_base(self->bitmap, &displayio_shape_type); - if (old_native != MP_OBJ_NULL) { - displayio_shape_t *old_bmp = MP_OBJ_TO_PTR(old_native); - if (old_bmp->width != new_bitmap_width || old_bmp->height != new_bitmap_height) { - mp_raise_ValueError(translate("New bitmap must be same size as old bitmap")); - } - } else if (mp_obj_is_type(self->bitmap, &displayio_bitmap_type)) { + if (mp_obj_is_type(self->bitmap, &displayio_bitmap_type)) { displayio_bitmap_t *old_bmp = MP_OBJ_TO_PTR(self->bitmap); - old_native = self->bitmap; if (old_bmp->width != new_bitmap_width || old_bmp->height != new_bitmap_height) { mp_raise_ValueError(translate("New bitmap must be same size as old bitmap")); } } else if (mp_obj_is_type(self->bitmap, &displayio_ondiskbitmap_type)) { displayio_ondiskbitmap_t *old_bmp = MP_OBJ_TO_PTR(self->bitmap); - old_native = self->bitmap; if (old_bmp->width != new_bitmap_width || old_bmp->height != new_bitmap_height) { mp_raise_ValueError(translate("New bitmap must be same size as old bitmap")); } diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index e377a49dea..1b151fb8c6 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -30,27 +30,34 @@ #include "py/obj.h" #include "py/runtime.h" +#if CIRCUITPY_BUSDISPLAY +#include "shared-bindings/busdisplay/BusDisplay.h" +#endif #include "shared-bindings/displayio/__init__.h" #include "shared-bindings/displayio/Bitmap.h" #include "shared-bindings/displayio/ColorConverter.h" -#include "shared-bindings/displayio/Display.h" -#include "shared-bindings/displayio/EPaperDisplay.h" -#include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/Group.h" -#include "shared-bindings/displayio/I2CDisplay.h" #include "shared-bindings/displayio/OnDiskBitmap.h" #include "shared-bindings/displayio/Palette.h" -#if CIRCUITPY_PARALLELDISPLAY -#include "shared-bindings/paralleldisplay/ParallelBus.h" -#endif -#include "shared-bindings/displayio/Shape.h" #include "shared-bindings/displayio/TileGrid.h" +#if CIRCUITPY_EPAPERDISPLAY +#include "shared-bindings/epaperdisplay/EPaperDisplay.h" +#endif +#if CIRCUITPY_FOURWIRE +#include "shared-bindings/fourwire/FourWire.h" +#endif +#if CIRCUITPY_I2CDISPLAYBUS +#include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" +#endif #include "shared-module/displayio/__init__.h" -//| """Native helpers for driving displays +//| """High level, display object compositing system //| -//| The `displayio` module contains classes to manage display output -//| including synchronizing with refresh rates and partial updating. +//| The `displayio` module contains classes to define what objects to display. +//| It is optimized for low memory use and, therefore, computes final pixel +//| values for dirty regions as needed. +//| +//| Separate modules manage transmitting the display contents to a display. //| //| For more a more thorough explanation and guide for using `displayio`, please //| refer to `this Learn guide @@ -61,7 +68,10 @@ //| """The `displayio.Group` that is the displayed serial terminal (REPL).""" //| -//| import paralleldisplay +//| from busdisplay import BusDisplay as Display +//| from epaperdisplay import EPaperDisplay +//| from fourwire import FourWire +//| from i2cdisplaybus import I2CDisplayBus as I2CDisplay //| //| def release_displays() -> None: @@ -85,18 +95,23 @@ STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_Bitmap), MP_ROM_PTR(&displayio_bitmap_type) }, { MP_ROM_QSTR(MP_QSTR_ColorConverter), MP_ROM_PTR(&displayio_colorconverter_type) }, { MP_ROM_QSTR(MP_QSTR_Colorspace), MP_ROM_PTR(&displayio_colorspace_type) }, - { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&displayio_display_type) }, - { MP_ROM_QSTR(MP_QSTR_EPaperDisplay), MP_ROM_PTR(&displayio_epaperdisplay_type) }, { MP_ROM_QSTR(MP_QSTR_Group), MP_ROM_PTR(&displayio_group_type) }, { MP_ROM_QSTR(MP_QSTR_OnDiskBitmap), MP_ROM_PTR(&displayio_ondiskbitmap_type) }, { MP_ROM_QSTR(MP_QSTR_Palette), MP_ROM_PTR(&displayio_palette_type) }, - { MP_ROM_QSTR(MP_QSTR_Shape), MP_ROM_PTR(&displayio_shape_type) }, { MP_ROM_QSTR(MP_QSTR_TileGrid), MP_ROM_PTR(&displayio_tilegrid_type) }, - { MP_ROM_QSTR(MP_QSTR_FourWire), MP_ROM_PTR(&displayio_fourwire_type) }, - { MP_ROM_QSTR(MP_QSTR_I2CDisplay), MP_ROM_PTR(&displayio_i2cdisplay_type) }, - #if CIRCUITPY_PARALLELDISPLAY - { MP_ROM_QSTR(MP_QSTR_ParallelBus), MP_ROM_PTR(¶lleldisplay_parallelbus_type) }, + // Remove these in CircuitPython 10 + #if CIRCUITPY_BUSDISPLAY + { MP_ROM_QSTR(MP_QSTR_Display), MP_ROM_PTR(&busdisplay_busdisplay_type) }, + #endif + #if CIRCUITPY_EPAPERDISPLAY + { MP_ROM_QSTR(MP_QSTR_EPaperDisplay), MP_ROM_PTR(&epaperdisplay_epaperdisplay_type) }, + #endif + #if CIRCUITPY_FOURWIRE + { MP_ROM_QSTR(MP_QSTR_FourWire), MP_ROM_PTR(&fourwire_fourwire_type) }, + #endif + #if CIRCUITPY_I2CDISPLAYBUS + { MP_ROM_QSTR(MP_QSTR_I2CDisplay), MP_ROM_PTR(&i2cdisplaybus_i2cdisplaybus_type) }, #endif { MP_ROM_QSTR(MP_QSTR_release_displays), MP_ROM_PTR(&displayio_release_displays_obj) }, diff --git a/shared-bindings/displayio/__init__.h b/shared-bindings/displayio/__init__.h index b297e4d755..3f975dd6e2 100644 --- a/shared-bindings/displayio/__init__.h +++ b/shared-bindings/displayio/__init__.h @@ -24,22 +24,11 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO___INIT___H +#pragma once #include "py/enum.h" #include "py/obj.h" -typedef enum { - DISPLAY_COMMAND, - DISPLAY_DATA -} display_byte_type_t; - -typedef enum { - CHIP_SELECT_UNTOUCHED, - CHIP_SELECT_TOGGLE_EVERY_BYTE -} display_chip_select_behavior_t; - typedef enum displayio_colorspace { DISPLAYIO_COLORSPACE_RGB888, DISPLAYIO_COLORSPACE_RGB565, @@ -53,16 +42,27 @@ typedef enum displayio_colorspace { DISPLAYIO_COLORSPACE_L8, } displayio_colorspace_t; +void common_hal_displayio_release_displays(void); + +extern const mp_obj_type_t displayio_colorspace_type; +extern const cp_enum_obj_t displayio_colorspace_RGB888_obj; + + +// Used in the various bus displays: BusDisplay, EPaperDisplay and ParallelDisplay +// Supported by shared-module/displayio/bus_core.c +typedef enum { + DISPLAY_COMMAND, + DISPLAY_DATA +} display_byte_type_t; + +typedef enum { + CHIP_SELECT_UNTOUCHED, + CHIP_SELECT_TOGGLE_EVERY_BYTE +} display_chip_select_behavior_t; + typedef bool (*display_bus_bus_reset)(mp_obj_t bus); typedef bool (*display_bus_bus_free)(mp_obj_t bus); typedef bool (*display_bus_begin_transaction)(mp_obj_t bus); typedef void (*display_bus_send)(mp_obj_t bus, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length); typedef void (*display_bus_end_transaction)(mp_obj_t bus); - -void common_hal_displayio_release_displays(void); - -extern const mp_obj_type_t displayio_colorspace_type; -extern const cp_enum_obj_t displayio_colorspace_RGB888_obj; - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO___INIT___H diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/epaperdisplay/EPaperDisplay.c similarity index 70% rename from shared-bindings/displayio/EPaperDisplay.c rename to shared-bindings/epaperdisplay/EPaperDisplay.c index 0263538cf7..eae82627c2 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/epaperdisplay/EPaperDisplay.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/EPaperDisplay.h" +#include "shared-bindings/epaperdisplay/EPaperDisplay.h" #include @@ -38,6 +38,8 @@ #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" +//| from busdisplay import _DisplayBus +//| //| class EPaperDisplay: //| """Manage updating an epaper display over a display bus //| @@ -82,7 +84,7 @@ //| start_up_time: float = 0, //| address_little_endian: bool = False //| ) -> None: -//| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `paralleldisplay.ParallelBus`). +//| """Create a EPaperDisplay object on the given display bus (`fourwire.FourWire` or `paralleldisplaybus.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 @@ -93,7 +95,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 paralleldisplay.ParallelBus +//| :type _DisplayBus: fourwire.FourWire or paralleldisplaybus.ParallelBus //| :param ~circuitpython_typing.ReadableBuffer start_sequence: Byte-packed command sequence. //| :param ~circuitpython_typing.ReadableBuffer stop_sequence: Byte-packed command sequence. //| :param int width: Width in pixels @@ -125,7 +127,7 @@ //| :param bool address_little_endian: Send the least significant byte (not bit) of multi-byte addresses first. Ignored when ram is addressed with one byte //| """ //| ... -STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { +STATIC mp_obj_t epaperdisplay_epaperdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_display_bus, ARG_start_sequence, ARG_stop_sequence, ARG_width, ARG_height, ARG_ram_width, ARG_ram_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_set_column_window_command, ARG_set_row_window_command, ARG_set_current_column_command, @@ -185,7 +187,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size } primary_display_t *disp = allocate_display_or_raise(); - displayio_epaperdisplay_obj_t *self = &disp->epaper_display; + epaperdisplay_epaperdisplay_obj_t *self = &disp->epaper_display; mp_float_t refresh_time = mp_obj_get_float(args[ARG_refresh_time].u_obj); mp_float_t seconds_per_frame = mp_obj_get_float(args[ARG_seconds_per_frame].u_obj); @@ -218,8 +220,8 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_refresh_display_command); } - self->base.type = &displayio_epaperdisplay_type; - common_hal_displayio_epaperdisplay_construct( + self->base.type = &epaperdisplay_epaperdisplay_type; + common_hal_epaperdisplay_epaperdisplay_construct( self, display_bus, start_bufinfo.buf, start_bufinfo.len, start_up_time, stop_bufinfo.buf, stop_bufinfo.len, @@ -238,8 +240,8 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size } // Helper to ensure we have the native super class instead of a subclass. -static displayio_epaperdisplay_obj_t *native_display(mp_obj_t display_obj) { - mp_obj_t native_display = mp_obj_cast_to_native_base(display_obj, &displayio_epaperdisplay_type); +static epaperdisplay_epaperdisplay_obj_t *native_display(mp_obj_t display_obj) { + mp_obj_t native_display = mp_obj_cast_to_native_base(display_obj, &epaperdisplay_epaperdisplay_type); mp_obj_assert_native_inited(native_display); return MP_OBJ_TO_PTR(native_display); } @@ -249,13 +251,13 @@ static displayio_epaperdisplay_obj_t *native_display(mp_obj_t display_obj) { //| ) -> None: //| """Updates the ``start_sequence`` and ``seconds_per_frame`` parameters to enable //| varying the refresh mode of the display.""" -STATIC mp_obj_t displayio_epaperdisplay_update_refresh_mode(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t epaperdisplay_epaperdisplay_update_refresh_mode(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_start_sequence, ARG_seconds_per_frame }; static const mp_arg_t allowed_args[] = { { MP_QSTR_start_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_seconds_per_frame, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(180)} }, }; - displayio_epaperdisplay_obj_t *self = native_display(pos_args[0]); + epaperdisplay_epaperdisplay_obj_t *self = native_display(pos_args[0]); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -265,147 +267,147 @@ STATIC mp_obj_t displayio_epaperdisplay_update_refresh_mode(size_t n_args, const float seconds_per_frame = mp_obj_get_float(args[ARG_seconds_per_frame].u_obj); // Update parameters - displayio_epaperdisplay_change_refresh_mode_parameters(self, &start_sequence, seconds_per_frame); + epaperdisplay_epaperdisplay_change_refresh_mode_parameters(self, &start_sequence, seconds_per_frame); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_epaperdisplay_update_refresh_mode_obj, 1, displayio_epaperdisplay_update_refresh_mode); +MP_DEFINE_CONST_FUN_OBJ_KW(epaperdisplay_epaperdisplay_update_refresh_mode_obj, 1, epaperdisplay_epaperdisplay_update_refresh_mode); //| def refresh(self) -> None: //| """Refreshes the display immediately or raises an exception if too soon. Use //| ``time.sleep(display.time_to_refresh)`` to sleep until a refresh can occur.""" //| ... -STATIC mp_obj_t displayio_epaperdisplay_obj_refresh(mp_obj_t self_in) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); - bool ok = common_hal_displayio_epaperdisplay_refresh(self); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_refresh(mp_obj_t self_in) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); + bool ok = common_hal_epaperdisplay_epaperdisplay_refresh(self); if (!ok) { mp_raise_RuntimeError(translate("Refresh too soon")); } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_refresh_obj, displayio_epaperdisplay_obj_refresh); +MP_DEFINE_CONST_FUN_OBJ_1(epaperdisplay_epaperdisplay_refresh_obj, epaperdisplay_epaperdisplay_obj_refresh); //| time_to_refresh: float //| """Time, in fractional seconds, until the ePaper display can be refreshed.""" -STATIC mp_obj_t displayio_epaperdisplay_obj_get_time_to_refresh(mp_obj_t self_in) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); - return mp_obj_new_float(common_hal_displayio_epaperdisplay_get_time_to_refresh(self) / 1000.0); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_get_time_to_refresh(mp_obj_t self_in) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); + return mp_obj_new_float(common_hal_epaperdisplay_epaperdisplay_get_time_to_refresh(self) / 1000.0); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_time_to_refresh_obj, displayio_epaperdisplay_obj_get_time_to_refresh); +MP_DEFINE_CONST_FUN_OBJ_1(epaperdisplay_epaperdisplay_get_time_to_refresh_obj, epaperdisplay_epaperdisplay_obj_get_time_to_refresh); -MP_PROPERTY_GETTER(displayio_epaperdisplay_time_to_refresh_obj, - (mp_obj_t)&displayio_epaperdisplay_get_time_to_refresh_obj); +MP_PROPERTY_GETTER(epaperdisplay_epaperdisplay_time_to_refresh_obj, + (mp_obj_t)&epaperdisplay_epaperdisplay_get_time_to_refresh_obj); //| busy: bool //| """True when the display is refreshing. This uses the ``busy_pin`` when available or the //| ``refresh_time`` otherwise.""" -STATIC mp_obj_t displayio_epaperdisplay_obj_get_busy(mp_obj_t self_in) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); - return mp_obj_new_bool(common_hal_displayio_epaperdisplay_get_busy(self)); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_get_busy(mp_obj_t self_in) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); + return mp_obj_new_bool(common_hal_epaperdisplay_epaperdisplay_get_busy(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_busy_obj, displayio_epaperdisplay_obj_get_busy); +MP_DEFINE_CONST_FUN_OBJ_1(epaperdisplay_epaperdisplay_get_busy_obj, epaperdisplay_epaperdisplay_obj_get_busy); -MP_PROPERTY_GETTER(displayio_epaperdisplay_busy_obj, - (mp_obj_t)&displayio_epaperdisplay_get_busy_obj); +MP_PROPERTY_GETTER(epaperdisplay_epaperdisplay_busy_obj, + (mp_obj_t)&epaperdisplay_epaperdisplay_get_busy_obj); //| width: int //| """Gets the width of the display in pixels""" -STATIC mp_obj_t displayio_epaperdisplay_obj_get_width(mp_obj_t self_in) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); - return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_epaperdisplay_get_width(self)); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_get_width(mp_obj_t self_in) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_epaperdisplay_epaperdisplay_get_width(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_width_obj, displayio_epaperdisplay_obj_get_width); +MP_DEFINE_CONST_FUN_OBJ_1(epaperdisplay_epaperdisplay_get_width_obj, epaperdisplay_epaperdisplay_obj_get_width); -MP_PROPERTY_GETTER(displayio_epaperdisplay_width_obj, - (mp_obj_t)&displayio_epaperdisplay_get_width_obj); +MP_PROPERTY_GETTER(epaperdisplay_epaperdisplay_width_obj, + (mp_obj_t)&epaperdisplay_epaperdisplay_get_width_obj); //| height: int //| """Gets the height of the display in pixels""" -STATIC mp_obj_t displayio_epaperdisplay_obj_get_height(mp_obj_t self_in) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); - return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_epaperdisplay_get_height(self)); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_get_height(mp_obj_t self_in) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_epaperdisplay_epaperdisplay_get_height(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_height_obj, displayio_epaperdisplay_obj_get_height); +MP_DEFINE_CONST_FUN_OBJ_1(epaperdisplay_epaperdisplay_get_height_obj, epaperdisplay_epaperdisplay_obj_get_height); -MP_PROPERTY_GETTER(displayio_epaperdisplay_height_obj, - (mp_obj_t)&displayio_epaperdisplay_get_height_obj); +MP_PROPERTY_GETTER(epaperdisplay_epaperdisplay_height_obj, + (mp_obj_t)&epaperdisplay_epaperdisplay_get_height_obj); //| rotation: int //| """The rotation of the display as an int in degrees.""" -STATIC mp_obj_t displayio_epaperdisplay_obj_get_rotation(mp_obj_t self_in) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); - return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_epaperdisplay_get_rotation(self)); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_get_rotation(mp_obj_t self_in) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_epaperdisplay_epaperdisplay_get_rotation(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_rotation_obj, displayio_epaperdisplay_obj_get_rotation); -STATIC mp_obj_t displayio_epaperdisplay_obj_set_rotation(mp_obj_t self_in, mp_obj_t value) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); - common_hal_displayio_epaperdisplay_set_rotation(self, mp_obj_get_int(value)); +MP_DEFINE_CONST_FUN_OBJ_1(epaperdisplay_epaperdisplay_get_rotation_obj, epaperdisplay_epaperdisplay_obj_get_rotation); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_set_rotation(mp_obj_t self_in, mp_obj_t value) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); + common_hal_epaperdisplay_epaperdisplay_set_rotation(self, mp_obj_get_int(value)); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(displayio_epaperdisplay_set_rotation_obj, displayio_epaperdisplay_obj_set_rotation); +MP_DEFINE_CONST_FUN_OBJ_2(epaperdisplay_epaperdisplay_set_rotation_obj, epaperdisplay_epaperdisplay_obj_set_rotation); -MP_PROPERTY_GETSET(displayio_epaperdisplay_rotation_obj, - (mp_obj_t)&displayio_epaperdisplay_get_rotation_obj, - (mp_obj_t)&displayio_epaperdisplay_set_rotation_obj); +MP_PROPERTY_GETSET(epaperdisplay_epaperdisplay_rotation_obj, + (mp_obj_t)&epaperdisplay_epaperdisplay_get_rotation_obj, + (mp_obj_t)&epaperdisplay_epaperdisplay_set_rotation_obj); //| bus: _DisplayBus //| """The bus being used by the display""" //| -STATIC mp_obj_t displayio_epaperdisplay_obj_get_bus(mp_obj_t self_in) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); - return common_hal_displayio_epaperdisplay_get_bus(self); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_get_bus(mp_obj_t self_in) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); + return common_hal_epaperdisplay_epaperdisplay_get_bus(self); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_bus_obj, displayio_epaperdisplay_obj_get_bus); +MP_DEFINE_CONST_FUN_OBJ_1(epaperdisplay_epaperdisplay_get_bus_obj, epaperdisplay_epaperdisplay_obj_get_bus); -MP_PROPERTY_GETTER(displayio_epaperdisplay_bus_obj, - (mp_obj_t)&displayio_epaperdisplay_get_bus_obj); +MP_PROPERTY_GETTER(epaperdisplay_epaperdisplay_bus_obj, + (mp_obj_t)&epaperdisplay_epaperdisplay_get_bus_obj); -//| root_group: Group +//| root_group: displayio.Group //| """The root group on the epaper display. //| If the root group is set to `displayio.CIRCUITPYTHON_TERMINAL`, the default CircuitPython terminal will be shown. //| If the root group is set to ``None``, no output will be shown. //| """ //| -STATIC mp_obj_t displayio_epaperdisplay_obj_get_root_group(mp_obj_t self_in) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); - return common_hal_displayio_epaperdisplay_get_root_group(self); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_get_root_group(mp_obj_t self_in) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); + return common_hal_epaperdisplay_epaperdisplay_get_root_group(self); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_root_group_obj, displayio_epaperdisplay_obj_get_root_group); +MP_DEFINE_CONST_FUN_OBJ_1(epaperdisplay_epaperdisplay_get_root_group_obj, epaperdisplay_epaperdisplay_obj_get_root_group); -STATIC mp_obj_t displayio_epaperdisplay_obj_set_root_group(mp_obj_t self_in, mp_obj_t group_in) { - displayio_epaperdisplay_obj_t *self = native_display(self_in); +STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_set_root_group(mp_obj_t self_in, mp_obj_t group_in) { + epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); displayio_group_t *group = NULL; if (group_in != mp_const_none) { group = MP_OBJ_TO_PTR(native_group(group_in)); } - common_hal_displayio_epaperdisplay_set_root_group(self, group); + common_hal_epaperdisplay_epaperdisplay_set_root_group(self, group); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(displayio_epaperdisplay_set_root_group_obj, displayio_epaperdisplay_obj_set_root_group); +MP_DEFINE_CONST_FUN_OBJ_2(epaperdisplay_epaperdisplay_set_root_group_obj, epaperdisplay_epaperdisplay_obj_set_root_group); -MP_PROPERTY_GETSET(displayio_epaperdisplay_root_group_obj, - (mp_obj_t)&displayio_epaperdisplay_get_root_group_obj, - (mp_obj_t)&displayio_epaperdisplay_set_root_group_obj); +MP_PROPERTY_GETSET(epaperdisplay_epaperdisplay_root_group_obj, + (mp_obj_t)&epaperdisplay_epaperdisplay_get_root_group_obj, + (mp_obj_t)&epaperdisplay_epaperdisplay_set_root_group_obj); -STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_update_refresh_mode), MP_ROM_PTR(&displayio_epaperdisplay_update_refresh_mode_obj) }, - { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&displayio_epaperdisplay_refresh_obj) }, +STATIC const mp_rom_map_elem_t epaperdisplay_epaperdisplay_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_update_refresh_mode), MP_ROM_PTR(&epaperdisplay_epaperdisplay_update_refresh_mode_obj) }, + { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&epaperdisplay_epaperdisplay_refresh_obj) }, - { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_epaperdisplay_width_obj) }, - { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_epaperdisplay_height_obj) }, - { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_epaperdisplay_rotation_obj) }, - { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_epaperdisplay_bus_obj) }, - { MP_ROM_QSTR(MP_QSTR_busy), MP_ROM_PTR(&displayio_epaperdisplay_busy_obj) }, - { MP_ROM_QSTR(MP_QSTR_time_to_refresh), MP_ROM_PTR(&displayio_epaperdisplay_time_to_refresh_obj) }, - { MP_ROM_QSTR(MP_QSTR_root_group), MP_ROM_PTR(&displayio_epaperdisplay_root_group_obj) }, + { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&epaperdisplay_epaperdisplay_width_obj) }, + { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&epaperdisplay_epaperdisplay_height_obj) }, + { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&epaperdisplay_epaperdisplay_rotation_obj) }, + { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&epaperdisplay_epaperdisplay_bus_obj) }, + { MP_ROM_QSTR(MP_QSTR_busy), MP_ROM_PTR(&epaperdisplay_epaperdisplay_busy_obj) }, + { MP_ROM_QSTR(MP_QSTR_time_to_refresh), MP_ROM_PTR(&epaperdisplay_epaperdisplay_time_to_refresh_obj) }, + { MP_ROM_QSTR(MP_QSTR_root_group), MP_ROM_PTR(&epaperdisplay_epaperdisplay_root_group_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(displayio_epaperdisplay_locals_dict, displayio_epaperdisplay_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(epaperdisplay_epaperdisplay_locals_dict, epaperdisplay_epaperdisplay_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( - displayio_epaperdisplay_type, + epaperdisplay_epaperdisplay_type, MP_QSTR_EPaperDisplay, MP_TYPE_FLAG_NONE, - make_new, displayio_epaperdisplay_make_new, - locals_dict, &displayio_epaperdisplay_locals_dict + make_new, epaperdisplay_epaperdisplay_make_new, + locals_dict, &epaperdisplay_epaperdisplay_locals_dict ); diff --git a/shared-bindings/displayio/EPaperDisplay.h b/shared-bindings/epaperdisplay/EPaperDisplay.h similarity index 62% rename from shared-bindings/displayio/EPaperDisplay.h rename to shared-bindings/epaperdisplay/EPaperDisplay.h index ba0b6d0695..7c780326db 100644 --- a/shared-bindings/displayio/EPaperDisplay.h +++ b/shared-bindings/epaperdisplay/EPaperDisplay.h @@ -24,19 +24,18 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_EPAPERDISPLAY_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_EPAPERDISPLAY_H +#pragma once #include "common-hal/microcontroller/Pin.h" -#include "shared-module/displayio/EPaperDisplay.h" +#include "shared-module/epaperdisplay/EPaperDisplay.h" #include "shared-module/displayio/Group.h" -extern const mp_obj_type_t displayio_epaperdisplay_type; +extern const mp_obj_type_t epaperdisplay_epaperdisplay_type; #define NO_COMMAND 0x100 -void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t *self, +void common_hal_epaperdisplay_epaperdisplay_construct(epaperdisplay_epaperdisplay_obj_t *self, mp_obj_t bus, const uint8_t *start_sequence, uint16_t start_sequence_len, mp_float_t start_up_time, const uint8_t *stop_sequence, uint16_t stop_sequence_len, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, @@ -50,20 +49,18 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t bool always_toggle_chip_select, bool grayscale, bool acep, bool two_byte_sequence_length, bool address_little_endian); -bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *self); +bool common_hal_epaperdisplay_epaperdisplay_refresh(epaperdisplay_epaperdisplay_obj_t *self); -mp_obj_t common_hal_displayio_epaperdisplay_get_root_group(displayio_epaperdisplay_obj_t *self); -bool common_hal_displayio_epaperdisplay_set_root_group(displayio_epaperdisplay_obj_t *self, displayio_group_t *root_group); +mp_obj_t common_hal_epaperdisplay_epaperdisplay_get_root_group(epaperdisplay_epaperdisplay_obj_t *self); +bool common_hal_epaperdisplay_epaperdisplay_set_root_group(epaperdisplay_epaperdisplay_obj_t *self, displayio_group_t *root_group); // Returns time in milliseconds. -uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaperdisplay_obj_t *self); -bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t *self); +uint32_t common_hal_epaperdisplay_epaperdisplay_get_time_to_refresh(epaperdisplay_epaperdisplay_obj_t *self); +bool common_hal_epaperdisplay_epaperdisplay_get_busy(epaperdisplay_epaperdisplay_obj_t *self); -uint16_t common_hal_displayio_epaperdisplay_get_width(displayio_epaperdisplay_obj_t *self); -uint16_t common_hal_displayio_epaperdisplay_get_height(displayio_epaperdisplay_obj_t *self); -uint16_t common_hal_displayio_epaperdisplay_get_rotation(displayio_epaperdisplay_obj_t *self); -void common_hal_displayio_epaperdisplay_set_rotation(displayio_epaperdisplay_obj_t *self, int rotation); +uint16_t common_hal_epaperdisplay_epaperdisplay_get_width(epaperdisplay_epaperdisplay_obj_t *self); +uint16_t common_hal_epaperdisplay_epaperdisplay_get_height(epaperdisplay_epaperdisplay_obj_t *self); +uint16_t common_hal_epaperdisplay_epaperdisplay_get_rotation(epaperdisplay_epaperdisplay_obj_t *self); +void common_hal_epaperdisplay_epaperdisplay_set_rotation(epaperdisplay_epaperdisplay_obj_t *self, int rotation); -mp_obj_t common_hal_displayio_epaperdisplay_get_bus(displayio_epaperdisplay_obj_t *self); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_EPAPERDISPLAY_H +mp_obj_t common_hal_epaperdisplay_epaperdisplay_get_bus(epaperdisplay_epaperdisplay_obj_t *self); diff --git a/shared-bindings/epaperdisplay/__init__.c b/shared-bindings/epaperdisplay/__init__.c new file mode 100644 index 0000000000..e7ad194353 --- /dev/null +++ b/shared-bindings/epaperdisplay/__init__.c @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 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/epaperdisplay/__init__.h" +#include "shared-bindings/epaperdisplay/EPaperDisplay.h" + +//| """Displays a `displayio` object tree on an e-paper display +//| +//| """ + +STATIC const mp_rom_map_elem_t epaperdisplay_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, + + { MP_ROM_QSTR(MP_QSTR_EPaperDisplay), MP_ROM_PTR(&epaperdisplay_epaperdisplay_type) }, +}; +STATIC MP_DEFINE_CONST_DICT(epaperdisplay_module_globals, epaperdisplay_module_globals_table); + +const mp_obj_module_t epaperdisplay_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&epaperdisplay_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_epaperdisplay, epaperdisplay_module); diff --git a/shared-bindings/epaperdisplay/__init__.h b/shared-bindings/epaperdisplay/__init__.h new file mode 100644 index 0000000000..f7b42875a1 --- /dev/null +++ b/shared-bindings/epaperdisplay/__init__.h @@ -0,0 +1,27 @@ +/* + * 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. + */ + +#pragma once diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/fourwire/FourWire.c similarity index 81% rename from shared-bindings/displayio/FourWire.c rename to shared-bindings/fourwire/FourWire.c index 42f7dc352c..23c032ff31 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/fourwire/FourWire.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include @@ -74,7 +74,7 @@ //| :param int phase: the edge of the clock that data is captured. First (0) //| or second (1). Rising or falling depends on clock polarity.""" //| ... -STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { +STATIC mp_obj_t fourwire_fourwire_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_spi_bus, ARG_command, ARG_chip_select, ARG_reset, ARG_baudrate, ARG_polarity, ARG_phase }; static const mp_arg_t allowed_args[] = { { MP_QSTR_spi_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -94,13 +94,13 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ mp_obj_t spi = mp_arg_validate_type(args[ARG_spi_bus].u_obj, &busio_spi_type, MP_QSTR_spi_bus); - displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus; - self->base.type = &displayio_fourwire_type; + fourwire_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus; + self->base.type = &fourwire_fourwire_type; uint8_t polarity = (uint8_t)mp_arg_validate_int_range(args[ARG_polarity].u_int, 0, 1, MP_QSTR_polarity); uint8_t phase = (uint8_t)mp_arg_validate_int_range(args[ARG_phase].u_int, 0, 1, MP_QSTR_phase); - common_hal_displayio_fourwire_construct(self, + common_hal_fourwire_fourwire_construct(self, MP_OBJ_TO_PTR(spi), command, chip_select, reset, args[ARG_baudrate].u_int, polarity, phase); return self; } @@ -109,15 +109,15 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ //| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin //| is available.""" //| ... -STATIC mp_obj_t displayio_fourwire_obj_reset(mp_obj_t self_in) { - displayio_fourwire_obj_t *self = self_in; +STATIC mp_obj_t fourwire_fourwire_obj_reset(mp_obj_t self_in) { + fourwire_fourwire_obj_t *self = self_in; - if (!common_hal_displayio_fourwire_reset(self)) { + if (!common_hal_fourwire_fourwire_reset(self)) { mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset); } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_fourwire_reset_obj, displayio_fourwire_obj_reset); +MP_DEFINE_CONST_FUN_OBJ_1(fourwire_fourwire_reset_obj, fourwire_fourwire_obj_reset); //| def send( //| self, command: int, data: ReadableBuffer, *, toggle_every_byte: bool = False @@ -126,7 +126,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_fourwire_reset_obj, displayio_fourwire_obj_r //| vertical scroll, set via ``send`` may or may not be reset once the code is done.""" //| ... //| -STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t fourwire_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_command, ARG_data, ARG_toggle_every_byte }; static const mp_arg_t allowed_args[] = { { MP_QSTR_command, MP_ARG_INT | MP_ARG_REQUIRED }, @@ -138,37 +138,37 @@ STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_a mp_int_t command_int = mp_arg_validate_int_range(args[ARG_command].u_int, 0, 255, MP_QSTR_command); - displayio_fourwire_obj_t *self = pos_args[0]; + fourwire_fourwire_obj_t *self = pos_args[0]; uint8_t command = command_int; mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ); // Wait for display bus to be available. - while (!common_hal_displayio_fourwire_begin_transaction(self)) { + while (!common_hal_fourwire_fourwire_begin_transaction(self)) { RUN_BACKGROUND_TASKS; } display_chip_select_behavior_t chip_select = CHIP_SELECT_UNTOUCHED; if (args[ARG_toggle_every_byte].u_bool) { chip_select = CHIP_SELECT_TOGGLE_EVERY_BYTE; } - common_hal_displayio_fourwire_send(self, DISPLAY_COMMAND, chip_select, &command, 1); - common_hal_displayio_fourwire_send(self, DISPLAY_DATA, chip_select, ((uint8_t *)bufinfo.buf), bufinfo.len); - common_hal_displayio_fourwire_end_transaction(self); + common_hal_fourwire_fourwire_send(self, DISPLAY_COMMAND, chip_select, &command, 1); + common_hal_fourwire_fourwire_send(self, DISPLAY_DATA, chip_select, ((uint8_t *)bufinfo.buf), bufinfo.len); + common_hal_fourwire_fourwire_end_transaction(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_fourwire_send_obj, 1, displayio_fourwire_obj_send); +MP_DEFINE_CONST_FUN_OBJ_KW(fourwire_fourwire_send_obj, 1, fourwire_fourwire_obj_send); -STATIC const mp_rom_map_elem_t displayio_fourwire_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&displayio_fourwire_reset_obj) }, - { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&displayio_fourwire_send_obj) }, +STATIC const mp_rom_map_elem_t fourwire_fourwire_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&fourwire_fourwire_reset_obj) }, + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&fourwire_fourwire_send_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(displayio_fourwire_locals_dict, displayio_fourwire_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(fourwire_fourwire_locals_dict, fourwire_fourwire_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( - displayio_fourwire_type, + fourwire_fourwire_type, MP_QSTR_FourWire, MP_TYPE_FLAG_NONE, - make_new, displayio_fourwire_make_new, - locals_dict, &displayio_fourwire_locals_dict + make_new, fourwire_fourwire_make_new, + locals_dict, &fourwire_fourwire_locals_dict ); diff --git a/shared-bindings/displayio/FourWire.h b/shared-bindings/fourwire/FourWire.h similarity index 66% rename from shared-bindings/displayio/FourWire.h rename to shared-bindings/fourwire/FourWire.h index 300327f7a2..ae9628d160 100644 --- a/shared-bindings/displayio/FourWire.h +++ b/shared-bindings/fourwire/FourWire.h @@ -24,33 +24,30 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_FOURWIRE_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_FOURWIRE_H +#pragma once -#include "shared-module/displayio/FourWire.h" +#include "shared-module/fourwire/FourWire.h" #include "shared-bindings/displayio/__init__.h" +#include "shared-bindings/fourwire/__init__.h" #include "common-hal/microcontroller/Pin.h" -#include "shared-module/displayio/Group.h" -extern const mp_obj_type_t displayio_fourwire_type; +extern const mp_obj_type_t fourwire_fourwire_type; -void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t *self, +void common_hal_fourwire_fourwire_construct(fourwire_fourwire_obj_t *self, busio_spi_obj_t *spi, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *reset, uint32_t baudrate, uint8_t polarity, uint8_t phase); -void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t *self); +void common_hal_fourwire_fourwire_deinit(fourwire_fourwire_obj_t *self); -bool common_hal_displayio_fourwire_reset(mp_obj_t self); -bool common_hal_displayio_fourwire_bus_free(mp_obj_t self); +bool common_hal_fourwire_fourwire_reset(mp_obj_t self); +bool common_hal_fourwire_fourwire_bus_free(mp_obj_t self); -bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t self); +bool common_hal_fourwire_fourwire_begin_transaction(mp_obj_t self); -void common_hal_displayio_fourwire_send(mp_obj_t self, display_byte_type_t byte_type, +void common_hal_fourwire_fourwire_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_fourwire_end_transaction(mp_obj_t self); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_FOURWIRE_H +void common_hal_fourwire_fourwire_end_transaction(mp_obj_t self); diff --git a/shared-bindings/fourwire/__init__.c b/shared-bindings/fourwire/__init__.c new file mode 100644 index 0000000000..7563682ce6 --- /dev/null +++ b/shared-bindings/fourwire/__init__.c @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 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/fourwire/__init__.h" +#include "shared-bindings/fourwire/FourWire.h" + +//| """Connects to a BusDisplay over a four wire bus +//| +//| """ + +STATIC const mp_rom_map_elem_t fourwire_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_busdisplay) }, + + { MP_ROM_QSTR(MP_QSTR_FourWire), MP_ROM_PTR(&fourwire_fourwire_type) }, +}; +STATIC MP_DEFINE_CONST_DICT(fourwire_module_globals, fourwire_module_globals_table); + +const mp_obj_module_t fourwire_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&fourwire_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_fourwire, fourwire_module); diff --git a/shared-bindings/fourwire/__init__.h b/shared-bindings/fourwire/__init__.h new file mode 100644 index 0000000000..253132b64e --- /dev/null +++ b/shared-bindings/fourwire/__init__.h @@ -0,0 +1,27 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 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. + */ + +#pragma once diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/i2cdisplaybus/I2CDisplayBus.c similarity index 71% rename from shared-bindings/displayio/I2CDisplay.c rename to shared-bindings/i2cdisplaybus/I2CDisplayBus.c index 3356333688..2d8b003938 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/i2cdisplaybus/I2CDisplayBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/I2CDisplay.h" +#include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" #include #include @@ -38,7 +38,7 @@ #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -//| class I2CDisplay: +//| class I2CDisplayBus: //| """Manage updating a display over I2C in the background while Python code runs. //| It doesn't handle display initialization.""" //| @@ -49,7 +49,7 @@ //| device_address: int, //| reset: Optional[microcontroller.Pin] = None //| ) -> None: -//| """Create a I2CDisplay object associated with the given I2C bus and reset pin. +//| """Create a I2CDisplayBus object associated with the given I2C bus and reset pin. //| //| The I2C bus and pins are then in use by the display until `displayio.release_displays()` is //| called even after a reload. (It does this so CircuitPython can use the display after your code @@ -61,7 +61,7 @@ //| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used //| """ //| ... -STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { +STATIC mp_obj_t i2cdisplaybus_i2cdisplaybus_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_i2c_bus, ARG_device_address, ARG_reset }; static const mp_arg_t allowed_args[] = { { MP_QSTR_i2c_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -74,10 +74,10 @@ STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t const mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj, MP_QSTR_reset); mp_obj_t i2c = mp_arg_validate_type(args[ARG_i2c_bus].u_obj, &busio_i2c_type, MP_QSTR_i2c_bus); - displayio_i2cdisplay_obj_t *self = &allocate_display_bus_or_raise()->i2cdisplay_bus; - self->base.type = &displayio_i2cdisplay_type; + i2cdisplaybus_i2cdisplaybus_obj_t *self = &allocate_display_bus_or_raise()->i2cdisplay_bus; + self->base.type = &i2cdisplaybus_i2cdisplaybus_type; - common_hal_displayio_i2cdisplay_construct(self, + common_hal_i2cdisplaybus_i2cdisplaybus_construct(self, MP_OBJ_TO_PTR(i2c), args[ARG_device_address].u_int, reset); return self; } @@ -86,22 +86,22 @@ STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t //| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin //| is available.""" //| ... -STATIC mp_obj_t displayio_i2cdisplay_obj_reset(mp_obj_t self_in) { - displayio_i2cdisplay_obj_t *self = self_in; +STATIC mp_obj_t i2cdisplaybus_i2cdisplaybus_obj_reset(mp_obj_t self_in) { + i2cdisplaybus_i2cdisplaybus_obj_t *self = self_in; - if (!common_hal_displayio_i2cdisplay_reset(self)) { + if (!common_hal_i2cdisplaybus_i2cdisplaybus_reset(self)) { mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset); } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_i2cdisplay_reset_obj, displayio_i2cdisplay_obj_reset); +MP_DEFINE_CONST_FUN_OBJ_1(i2cdisplaybus_i2cdisplaybus_reset_obj, i2cdisplaybus_i2cdisplaybus_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_i2cdisplay_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { +STATIC mp_obj_t i2cdisplaybus_i2cdisplaybus_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { mp_int_t command_int = mp_obj_get_int(command_obj); mp_arg_validate_int_range(command_int, 0, 255, MP_QSTR_command); @@ -110,29 +110,29 @@ STATIC mp_obj_t displayio_i2cdisplay_obj_send(mp_obj_t self, mp_obj_t command_ob mp_get_buffer_raise(data_obj, &bufinfo, MP_BUFFER_READ); // Wait for display bus to be available. - while (!common_hal_displayio_i2cdisplay_begin_transaction(self)) { + while (!common_hal_i2cdisplaybus_i2cdisplaybus_begin_transaction(self)) { RUN_BACKGROUND_TASKS; } uint8_t full_command[bufinfo.len + 1]; full_command[0] = command; memcpy(full_command + 1, ((uint8_t *)bufinfo.buf), bufinfo.len); - common_hal_displayio_i2cdisplay_send(self, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, full_command, bufinfo.len + 1); - common_hal_displayio_i2cdisplay_end_transaction(self); + common_hal_i2cdisplaybus_i2cdisplaybus_send(self, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, full_command, bufinfo.len + 1); + common_hal_i2cdisplaybus_i2cdisplaybus_end_transaction(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_3(displayio_i2cdisplay_send_obj, displayio_i2cdisplay_obj_send); +MP_DEFINE_CONST_FUN_OBJ_3(i2cdisplaybus_i2cdisplaybus_send_obj, i2cdisplaybus_i2cdisplaybus_obj_send); -STATIC const mp_rom_map_elem_t displayio_i2cdisplay_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&displayio_i2cdisplay_reset_obj) }, - { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&displayio_i2cdisplay_send_obj) }, +STATIC const mp_rom_map_elem_t i2cdisplaybus_i2cdisplaybus_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&i2cdisplaybus_i2cdisplaybus_reset_obj) }, + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&i2cdisplaybus_i2cdisplaybus_send_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(displayio_i2cdisplay_locals_dict, displayio_i2cdisplay_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(i2cdisplaybus_i2cdisplaybus_locals_dict, i2cdisplaybus_i2cdisplaybus_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( - displayio_i2cdisplay_type, - MP_QSTR_I2CDisplay, + i2cdisplaybus_i2cdisplaybus_type, + MP_QSTR_I2CDisplayBus, MP_TYPE_FLAG_NONE, - make_new, displayio_i2cdisplay_make_new, - locals_dict, &displayio_i2cdisplay_locals_dict + make_new, i2cdisplaybus_i2cdisplaybus_make_new, + locals_dict, &i2cdisplaybus_i2cdisplaybus_locals_dict ); diff --git a/shared-bindings/displayio/I2CDisplay.h b/shared-bindings/i2cdisplaybus/I2CDisplayBus.h similarity index 65% rename from shared-bindings/displayio/I2CDisplay.h rename to shared-bindings/i2cdisplaybus/I2CDisplayBus.h index d40cd19d8d..1fa52bc408 100644 --- a/shared-bindings/displayio/I2CDisplay.h +++ b/shared-bindings/i2cdisplaybus/I2CDisplayBus.h @@ -24,29 +24,26 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_I2CDISPLAY_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_I2CDISPLAY_H +#pragma once -#include "shared-module/displayio/I2CDisplay.h" +#include "shared-module/i2cdisplaybus/I2CDisplayBus.h" #include "shared-bindings/displayio/__init__.h" #include "common-hal/microcontroller/Pin.h" -extern const mp_obj_type_t displayio_i2cdisplay_type; +extern const mp_obj_type_t i2cdisplaybus_i2cdisplaybus_type; -void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t *self, +void common_hal_i2cdisplaybus_i2cdisplaybus_construct(i2cdisplaybus_i2cdisplaybus_obj_t *self, busio_i2c_obj_t *i2c, uint16_t device_address, const mcu_pin_obj_t *reset); -void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t *self); +void common_hal_i2cdisplaybus_i2cdisplaybus_deinit(i2cdisplaybus_i2cdisplaybus_obj_t *self); -bool common_hal_displayio_i2cdisplay_reset(mp_obj_t self); -bool common_hal_displayio_i2cdisplay_bus_free(mp_obj_t self); +bool common_hal_i2cdisplaybus_i2cdisplaybus_reset(mp_obj_t self); +bool common_hal_i2cdisplaybus_i2cdisplaybus_bus_free(mp_obj_t self); -bool common_hal_displayio_i2cdisplay_begin_transaction(mp_obj_t self); +bool common_hal_i2cdisplaybus_i2cdisplaybus_begin_transaction(mp_obj_t self); -void common_hal_displayio_i2cdisplay_send(mp_obj_t self, display_byte_type_t byte_type, +void common_hal_i2cdisplaybus_i2cdisplaybus_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_i2cdisplay_end_transaction(mp_obj_t self); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_I2CDISPLAY_H +void common_hal_i2cdisplaybus_i2cdisplaybus_end_transaction(mp_obj_t self); diff --git a/shared-bindings/i2cdisplaybus/__init__.c b/shared-bindings/i2cdisplaybus/__init__.c new file mode 100644 index 0000000000..e7cdd11729 --- /dev/null +++ b/shared-bindings/i2cdisplaybus/__init__.c @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2023 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/i2cdisplaybus/__init__.h" +#include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" + +//| """Communicates to a display IC over I2C +//| +//| """ + +STATIC const mp_rom_map_elem_t i2cdisplaybus_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_i2cdisplaybus) }, + + { MP_ROM_QSTR(MP_QSTR_I2CDisplayBus), MP_ROM_PTR(&i2cdisplaybus_i2cdisplaybus_type) }, +}; +STATIC MP_DEFINE_CONST_DICT(i2cdisplaybus_module_globals, i2cdisplaybus_module_globals_table); + +const mp_obj_module_t i2cdisplaybus_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&i2cdisplaybus_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_i2cdisplaybus, i2cdisplaybus_module); diff --git a/shared-bindings/i2cdisplaybus/__init__.h b/shared-bindings/i2cdisplaybus/__init__.h new file mode 100644 index 0000000000..f7b42875a1 --- /dev/null +++ b/shared-bindings/i2cdisplaybus/__init__.h @@ -0,0 +1,27 @@ +/* + * 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. + */ + +#pragma once diff --git a/shared-bindings/paralleldisplay/ParallelBus.c b/shared-bindings/paralleldisplaybus/ParallelBus.c similarity index 75% rename from shared-bindings/paralleldisplay/ParallelBus.c rename to shared-bindings/paralleldisplaybus/ParallelBus.c index 890c06c60a..84afa22343 100644 --- a/shared-bindings/paralleldisplay/ParallelBus.c +++ b/shared-bindings/paralleldisplaybus/ParallelBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/paralleldisplay/ParallelBus.h" +#include "shared-bindings/paralleldisplaybus/ParallelBus.h" #include @@ -69,7 +69,7 @@ //| :param microcontroller.Pin reset: Reset pin, optional //| :param int frequency: The communication frequency in Hz for the display on the bus""" //| ... -STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { +STATIC mp_obj_t paralleldisplaybus_parallelbus_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_data0, ARG_data_pins, 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, {.u_obj = mp_const_none } }, @@ -90,8 +90,8 @@ STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, const mcu_pin_obj_t *read = validate_obj_is_free_pin_or_none(args[ARG_read].u_obj, MP_QSTR_read); const mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj, MP_QSTR_reset); - paralleldisplay_parallelbus_obj_t *self = &allocate_display_bus_or_raise()->parallel_bus; - self->base.type = ¶lleldisplay_parallelbus_type; + paralleldisplaybus_parallelbus_obj_t *self = &allocate_display_bus_or_raise()->parallel_bus; + self->base.type = ¶lleldisplaybus_parallelbus_type; bool specified_data0 = args[ARG_data0].u_obj != mp_const_none; bool specified_data_pins = args[ARG_data_pins].u_obj != mp_const_none; @@ -102,12 +102,12 @@ STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, if (specified_data0) { const mcu_pin_obj_t *data0 = validate_obj_is_free_pin(args[ARG_data0].u_obj, MP_QSTR_data0); - common_hal_paralleldisplay_parallelbus_construct(self, data0, command, chip_select, write, read, reset, args[ARG_frequency].u_int); + common_hal_paralleldisplaybus_parallelbus_construct(self, data0, command, chip_select, write, read, reset, args[ARG_frequency].u_int); } else { uint8_t num_pins; const mcu_pin_obj_t *data_pins[16]; validate_list_is_free_pins(MP_QSTR_data_pins, data_pins, (mp_int_t)MP_ARRAY_SIZE(data_pins), args[ARG_data_pins].u_obj, &num_pins); - common_hal_paralleldisplay_parallelbus_construct_nonsequential(self, num_pins, data_pins, command, chip_select, write, read, reset, args[ARG_frequency].u_int); + common_hal_paralleldisplaybus_parallelbus_construct_nonsequential(self, num_pins, data_pins, command, chip_select, write, read, reset, args[ARG_frequency].u_int); } return self; } @@ -117,22 +117,22 @@ STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, //| is available.""" //| ... -STATIC mp_obj_t paralleldisplay_parallelbus_obj_reset(mp_obj_t self_in) { - paralleldisplay_parallelbus_obj_t *self = self_in; +STATIC mp_obj_t paralleldisplaybus_parallelbus_obj_reset(mp_obj_t self_in) { + paralleldisplaybus_parallelbus_obj_t *self = self_in; - if (!common_hal_paralleldisplay_parallelbus_reset(self)) { + if (!common_hal_paralleldisplaybus_parallelbus_reset(self)) { mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset); } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(paralleldisplay_parallelbus_reset_obj, paralleldisplay_parallelbus_obj_reset); +MP_DEFINE_CONST_FUN_OBJ_1(paralleldisplaybus_parallelbus_reset_obj, paralleldisplaybus_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 paralleldisplay_parallelbus_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { +STATIC mp_obj_t paralleldisplaybus_parallelbus_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { mp_int_t command_int = mp_arg_validate_int_range(mp_obj_get_int(command_obj), 0, 255, MP_QSTR_command); uint8_t command = command_int; @@ -140,27 +140,27 @@ STATIC mp_obj_t paralleldisplay_parallelbus_obj_send(mp_obj_t self, mp_obj_t com mp_get_buffer_raise(data_obj, &bufinfo, MP_BUFFER_READ); // Wait for display bus to be available. - while (!common_hal_paralleldisplay_parallelbus_begin_transaction(self)) { + while (!common_hal_paralleldisplaybus_parallelbus_begin_transaction(self)) { RUN_BACKGROUND_TASKS; } - 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); + common_hal_paralleldisplaybus_parallelbus_send(self, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, &command, 1); + common_hal_paralleldisplaybus_parallelbus_send(self, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, ((uint8_t *)bufinfo.buf), bufinfo.len); + common_hal_paralleldisplaybus_parallelbus_end_transaction(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_3(paralleldisplay_parallelbus_send_obj, paralleldisplay_parallelbus_obj_send); +MP_DEFINE_CONST_FUN_OBJ_3(paralleldisplaybus_parallelbus_send_obj, paralleldisplaybus_parallelbus_obj_send); -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 const mp_rom_map_elem_t paralleldisplaybus_parallelbus_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(¶lleldisplaybus_parallelbus_reset_obj) }, + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(¶lleldisplaybus_parallelbus_send_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(paralleldisplay_parallelbus_locals_dict, paralleldisplay_parallelbus_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(paralleldisplaybus_parallelbus_locals_dict, paralleldisplaybus_parallelbus_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( - paralleldisplay_parallelbus_type, + paralleldisplaybus_parallelbus_type, MP_QSTR_ParallelBus, MP_TYPE_FLAG_NONE, - make_new, paralleldisplay_parallelbus_make_new, - locals_dict, ¶lleldisplay_parallelbus_locals_dict + make_new, paralleldisplaybus_parallelbus_make_new, + locals_dict, ¶lleldisplaybus_parallelbus_locals_dict ); diff --git a/shared-bindings/paralleldisplay/ParallelBus.h b/shared-bindings/paralleldisplaybus/ParallelBus.h similarity index 70% rename from shared-bindings/paralleldisplay/ParallelBus.h rename to shared-bindings/paralleldisplaybus/ParallelBus.h index e890683934..866468bad0 100644 --- a/shared-bindings/paralleldisplay/ParallelBus.h +++ b/shared-bindings/paralleldisplaybus/ParallelBus.h @@ -26,30 +26,30 @@ #pragma once -#include "common-hal/paralleldisplay/ParallelBus.h" +#include "common-hal/paralleldisplaybus/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 paralleldisplay_parallelbus_type; +extern const mp_obj_type_t paralleldisplaybus_parallelbus_type; -void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbus_obj_t *self, +void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_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_paralleldisplay_parallelbus_construct_nonsequential(paralleldisplay_parallelbus_obj_t *self, +void common_hal_paralleldisplaybus_parallelbus_construct_nonsequential(paralleldisplaybus_parallelbus_obj_t *self, uint8_t n_pins, const mcu_pin_obj_t **data_pins, 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_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_obj_t *self); +void common_hal_paralleldisplaybus_parallelbus_deinit(paralleldisplaybus_parallelbus_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_paralleldisplaybus_parallelbus_reset(mp_obj_t self); +bool common_hal_paralleldisplaybus_parallelbus_bus_free(mp_obj_t self); -bool common_hal_paralleldisplay_parallelbus_begin_transaction(mp_obj_t self); +bool common_hal_paralleldisplaybus_parallelbus_begin_transaction(mp_obj_t self); -void common_hal_paralleldisplay_parallelbus_send(mp_obj_t self, display_byte_type_t byte_type, +void common_hal_paralleldisplaybus_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_paralleldisplay_parallelbus_end_transaction(mp_obj_t self); +void common_hal_paralleldisplaybus_parallelbus_end_transaction(mp_obj_t self); diff --git a/shared-bindings/paralleldisplay/__init__.c b/shared-bindings/paralleldisplaybus/__init__.c similarity index 70% rename from shared-bindings/paralleldisplay/__init__.c rename to shared-bindings/paralleldisplaybus/__init__.c index de4492f550..379eeb5857 100644 --- a/shared-bindings/paralleldisplay/__init__.c +++ b/shared-bindings/paralleldisplaybus/__init__.c @@ -30,22 +30,25 @@ #include "py/obj.h" #include "py/runtime.h" -#include "shared-bindings/paralleldisplay/__init__.h" -#include "shared-bindings/paralleldisplay/ParallelBus.h" +#include "shared-bindings/paralleldisplaybus/__init__.h" +#include "shared-bindings/paralleldisplaybus/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 const mp_rom_map_elem_t paralleldisplaybus_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_paralleldisplaybus) }, + { MP_ROM_QSTR(MP_QSTR_ParallelBus), MP_ROM_PTR(¶lleldisplaybus_parallelbus_type) }, }; -STATIC MP_DEFINE_CONST_DICT(paralleldisplay_module_globals, paralleldisplay_module_globals_table); +STATIC MP_DEFINE_CONST_DICT(paralleldisplaybus_module_globals, paralleldisplaybus_module_globals_table); -const mp_obj_module_t paralleldisplay_module = { +const mp_obj_module_t paralleldisplaybus_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)¶lleldisplay_module_globals, + .globals = (mp_obj_dict_t *)¶lleldisplaybus_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_paralleldisplay, paralleldisplay_module); +MP_REGISTER_MODULE(MP_QSTR_paralleldisplaybus, paralleldisplaybus_module); + +// Remove in CircuitPython 10 +MP_REGISTER_MODULE(MP_QSTR_paralleldisplay, paralleldisplaybus_module); diff --git a/shared-bindings/paralleldisplaybus/__init__.h b/shared-bindings/paralleldisplaybus/__init__.h new file mode 100644 index 0000000000..f7b42875a1 --- /dev/null +++ b/shared-bindings/paralleldisplaybus/__init__.h @@ -0,0 +1,27 @@ +/* + * 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. + */ + +#pragma once diff --git a/shared-module/_stage/__init__.c b/shared-module/_stage/__init__.c index 0a18635562..36562232c5 100644 --- a/shared-module/_stage/__init__.c +++ b/shared-module/_stage/__init__.c @@ -37,7 +37,7 @@ void render_stage( int16_t vx, int16_t vy, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, - displayio_display_obj_t *display, + busdisplay_busdisplay_obj_t *display, uint8_t scale, uint16_t background) { @@ -46,12 +46,12 @@ void render_stage( area.y1 = y0 * scale; area.x2 = x1 * scale; area.y2 = y1 * scale; - displayio_display_core_set_region_to_update(&display->core, &area); + displayio_display_bus_set_region_to_update(&display->bus, &display->core, &area); - while (!displayio_display_core_begin_transaction(&display->core)) { + while (!displayio_display_bus_begin_transaction(&display->bus)) { RUN_BACKGROUND_TASKS; } - display->core.send(display->core.bus, DISPLAY_COMMAND, + display->bus.send(display->bus.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, &display->write_ram_command, 1); size_t index = 0; @@ -78,7 +78,7 @@ void render_stage( index += 1; // The buffer is full, send it. if (index >= buffer_size) { - display->core.send(display->core.bus, DISPLAY_DATA, + display->bus.send(display->bus.bus, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, ((uint8_t *)buffer), buffer_size * 2); index = 0; @@ -89,10 +89,10 @@ void render_stage( } // Send the remaining data. if (index) { - display->core.send(display->core.bus, DISPLAY_DATA, + display->bus.send(display->bus.bus, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, ((uint8_t *)buffer), index * 2); } - displayio_display_core_end_transaction(&display->core); + displayio_display_bus_end_transaction(&display->bus); } diff --git a/shared-module/_stage/__init__.h b/shared-module/_stage/__init__.h index 596752bee5..d7e1467945 100644 --- a/shared-module/_stage/__init__.h +++ b/shared-module/_stage/__init__.h @@ -24,10 +24,9 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE__STAGE_H -#define MICROPY_INCLUDED_SHARED_MODULE__STAGE_H +#pragma once -#include "shared-bindings/displayio/Display.h" +#include "shared-bindings/busdisplay/BusDisplay.h" #include #include #include "py/obj.h" @@ -40,7 +39,5 @@ void render_stage( int16_t vx, int16_t vy, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, - displayio_display_obj_t *display, + busdisplay_busdisplay_obj_t *display, uint8_t scale, uint16_t background); - -#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 4c096a25a6..08a9761ed5 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -190,9 +190,9 @@ void reset_board_buses(void) { #if CIRCUITPY_BOARD_I2C for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_I2C; instance++) { bool display_using_i2c = false; - #if CIRCUITPY_DISPLAYIO + #if CIRCUITPY_I2CDISPLAYBUS for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { - if (display_buses[i].bus_base.type == &displayio_i2cdisplay_type && display_buses[i].i2cdisplay_bus.bus == &i2c_obj[instance]) { + if (display_buses[i].bus_base.type == &i2cdisplaybus_i2cdisplaybus_type && display_buses[i].i2cdisplay_bus.bus == &i2c_obj[instance]) { display_using_i2c = true; break; } @@ -211,13 +211,15 @@ void reset_board_buses(void) { #if CIRCUITPY_BOARD_SPI for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_SPI; instance++) { bool display_using_spi = false; - #if CIRCUITPY_DISPLAYIO + #if CIRCUITPY_FOURWIRE || CIRCUITPY_SHARPDISPLAY for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { mp_const_obj_t bus_type = display_buses[i].bus_base.type; - if (bus_type == &displayio_fourwire_type && display_buses[i].fourwire_bus.bus == &spi_obj[instance]) { + #if CIRCUITPY_FOURWIRE + if (bus_type == &fourwire_fourwire_type && display_buses[i].fourwire_bus.bus == &spi_obj[instance]) { display_using_spi = true; break; } + #endif #if CIRCUITPY_SHARPDISPLAY if (bus_type == &sharpdisplay_framebuffer_type && display_buses[i].sharpdisplay.bus == &spi_obj[instance]) { display_using_spi = true; diff --git a/shared-module/displayio/Display.c b/shared-module/busdisplay/BusDisplay.c similarity index 75% rename from shared-module/displayio/Display.c rename to shared-module/busdisplay/BusDisplay.c index 94f29d2c93..7b39d33db0 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/busdisplay/BusDisplay.c @@ -24,13 +24,17 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/Display.h" +#include "shared-bindings/busdisplay/BusDisplay.h" #include "py/runtime.h" -#include "shared-bindings/displayio/FourWire.h" -#include "shared-bindings/displayio/I2CDisplay.h" -#if CIRCUITPY_PARALLELDISPLAY -#include "shared-bindings/paralleldisplay/ParallelBus.h" +#if CIRCUITPY_FOURWIRE +#include "shared-bindings/fourwire/FourWire.h" +#endif +#if CIRCUITPY_I2CDISPLAYBUS +#include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" +#endif +#if CIRCUITPY_PARALLELDISPLAYBUS +#include "shared-bindings/paralleldisplaybus/ParallelBus.h" #endif #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/time/__init__.h" @@ -45,7 +49,7 @@ #define DELAY 0x80 -void common_hal_displayio_display_construct(displayio_display_obj_t *self, +void common_hal_busdisplay_busdisplay_construct(busdisplay_busdisplay_obj_t *self, mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word, uint8_t set_column_command, @@ -63,8 +67,9 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self, ram_width = 0xff; ram_height = 0xff; } - displayio_display_core_construct(&self->core, bus, width, height, ram_width, ram_height, colstart, rowstart, rotation, - color_depth, grayscale, pixels_in_byte_share_row, bytes_per_cell, reverse_pixels_in_byte, reverse_bytes_in_word, + displayio_display_core_construct(&self->core, width, height, rotation, + color_depth, grayscale, pixels_in_byte_share_row, bytes_per_cell, reverse_pixels_in_byte, reverse_bytes_in_word); + displayio_display_bus_construct(&self->bus, bus, ram_width, ram_height, colstart, rowstart, set_column_command, set_row_command, NO_COMMAND, NO_COMMAND, data_as_commands, false /* always_toggle_chip_select */, SH1107_addressing && color_depth == 1, false /*address_little_endian */); @@ -83,19 +88,19 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self, bool delay = (data_size & DELAY) != 0; data_size &= ~DELAY; uint8_t *data = cmd + 2; - while (!displayio_display_core_begin_transaction(&self->core)) { + while (!displayio_display_bus_begin_transaction(&self->bus)) { RUN_BACKGROUND_TASKS; } - if (self->core.data_as_commands) { + if (self->bus.data_as_commands) { uint8_t full_command[data_size + 1]; full_command[0] = cmd[0]; memcpy(full_command + 1, data, data_size); - self->core.send(self->core.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, full_command, data_size + 1); + self->bus.send(self->bus.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, full_command, data_size + 1); } else { - self->core.send(self->core.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, cmd, 1); - self->core.send(self->core.bus, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, data, data_size); + self->bus.send(self->bus.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, cmd, 1); + self->bus.send(self->bus.bus, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, data, data_size); } - displayio_display_core_end_transaction(&self->core); + displayio_display_bus_end_transaction(&self->bus); uint16_t delay_length_ms = 10; if (delay) { data_size++; @@ -130,29 +135,29 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self, #endif } - common_hal_displayio_display_set_brightness(self, brightness); + common_hal_busdisplay_busdisplay_set_brightness(self, brightness); // Set the group after initialization otherwise we may send pixels while we delay in // initialization. if (!circuitpython_splash.in_group) { - common_hal_displayio_display_set_root_group(self, &circuitpython_splash); + common_hal_busdisplay_busdisplay_set_root_group(self, &circuitpython_splash); } - common_hal_displayio_display_set_auto_refresh(self, auto_refresh); + common_hal_busdisplay_busdisplay_set_auto_refresh(self, auto_refresh); } -uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t *self) { +uint16_t common_hal_busdisplay_busdisplay_get_width(busdisplay_busdisplay_obj_t *self) { return displayio_display_core_get_width(&self->core); } -uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t *self) { +uint16_t common_hal_busdisplay_busdisplay_get_height(busdisplay_busdisplay_obj_t *self) { return displayio_display_core_get_height(&self->core); } -mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t *self) { +mp_float_t common_hal_busdisplay_busdisplay_get_brightness(busdisplay_busdisplay_obj_t *self) { return self->current_brightness; } -bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self, mp_float_t brightness) { +bool common_hal_busdisplay_busdisplay_set_brightness(busdisplay_busdisplay_obj_t *self, mp_float_t brightness) { if (!self->backlight_on_high) { brightness = 1.0 - brightness; } @@ -176,18 +181,18 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self, common_hal_digitalio_digitalinout_set_value(&self->backlight_inout, brightness > 0.99); ok = true; } else if (self->brightness_command != NO_BRIGHTNESS_COMMAND) { - ok = displayio_display_core_begin_transaction(&self->core); + ok = displayio_display_bus_begin_transaction(&self->bus); if (ok) { - if (self->core.data_as_commands) { + if (self->bus.data_as_commands) { uint8_t set_brightness[2] = {self->brightness_command, (uint8_t)(0xff * brightness)}; - self->core.send(self->core.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, set_brightness, 2); + self->bus.send(self->bus.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, set_brightness, 2); } else { uint8_t command = self->brightness_command; uint8_t hex_brightness = 0xff * brightness; - self->core.send(self->core.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, &command, 1); - self->core.send(self->core.bus, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, &hex_brightness, 1); + self->bus.send(self->bus.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, &command, 1); + self->bus.send(self->bus.bus, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, &hex_brightness, 1); } - displayio_display_core_end_transaction(&self->core); + displayio_display_bus_end_transaction(&self->bus); } } @@ -197,18 +202,18 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self, return ok; } -mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t *self) { - return self->core.bus; +mp_obj_t common_hal_busdisplay_busdisplay_get_bus(busdisplay_busdisplay_obj_t *self) { + return self->bus.bus; } -mp_obj_t common_hal_displayio_display_get_root_group(displayio_display_obj_t *self) { +mp_obj_t common_hal_busdisplay_busdisplay_get_root_group(busdisplay_busdisplay_obj_t *self) { if (self->core.current_group == NULL) { return mp_const_none; } return self->core.current_group; } -STATIC const displayio_area_t *_get_refresh_areas(displayio_display_obj_t *self) { +STATIC const displayio_area_t *_get_refresh_areas(busdisplay_busdisplay_obj_t *self) { if (self->core.full_refresh) { self->core.area.next = NULL; return &self->core.area; @@ -218,14 +223,14 @@ STATIC const displayio_area_t *_get_refresh_areas(displayio_display_obj_t *self) return NULL; } -STATIC void _send_pixels(displayio_display_obj_t *self, uint8_t *pixels, uint32_t length) { - if (!self->core.data_as_commands) { - self->core.send(self->core.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, &self->write_ram_command, 1); +STATIC void _send_pixels(busdisplay_busdisplay_obj_t *self, uint8_t *pixels, uint32_t length) { + if (!self->bus.data_as_commands) { + self->bus.send(self->bus.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, &self->write_ram_command, 1); } - self->core.send(self->core.bus, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, pixels, length); + self->bus.send(self->bus.bus, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, pixels, length); } -STATIC bool _refresh_area(displayio_display_obj_t *self, const displayio_area_t *area) { +STATIC bool _refresh_area(busdisplay_busdisplay_obj_t *self, const displayio_area_t *area) { uint16_t buffer_size = 128; // In uint32_ts displayio_area_t clipped; @@ -240,7 +245,7 @@ STATIC bool _refresh_area(displayio_display_obj_t *self, const displayio_area_t uint16_t subrectangles = 1; // for SH1107 and other boundary constrained controllers // write one single row at a time - if (self->core.SH1107_addressing) { + if (self->bus.SH1107_addressing) { subrectangles = rows_per_buffer / 8; // page addressing mode writes 8 rows at a time rows_per_buffer = 8; } else if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) { @@ -285,7 +290,7 @@ STATIC bool _refresh_area(displayio_display_obj_t *self, const displayio_area_t } remaining_rows -= rows_per_buffer; - displayio_display_core_set_region_to_update(&self->core, &subrectangle); + displayio_display_bus_set_region_to_update(&self->bus, &self->core, &subrectangle); uint16_t subrectangle_size_bytes; if (self->core.colorspace.depth >= 8) { @@ -300,13 +305,13 @@ STATIC bool _refresh_area(displayio_display_obj_t *self, const displayio_area_t displayio_display_core_fill_area(&self->core, &subrectangle, mask, buffer); // Can't acquire display bus; skip the rest of the data. - if (!displayio_display_core_bus_free(&self->core)) { + if (!displayio_display_bus_is_free(&self->bus)) { return false; } - displayio_display_core_begin_transaction(&self->core); + displayio_display_bus_begin_transaction(&self->bus); _send_pixels(self, (uint8_t *)buffer, subrectangle_size_bytes); - displayio_display_core_end_transaction(&self->core); + displayio_display_bus_end_transaction(&self->bus); // TODO(tannewt): Make refresh displays faster so we don't starve other // background tasks. @@ -317,11 +322,12 @@ STATIC bool _refresh_area(displayio_display_obj_t *self, const displayio_area_t return true; } -STATIC void _refresh_display(displayio_display_obj_t *self) { - if (!displayio_display_core_start_refresh(&self->core)) { +STATIC void _refresh_display(busdisplay_busdisplay_obj_t *self) { + if (!displayio_display_bus_is_free(&self->bus)) { // A refresh on this bus is already in progress. Try next display. return; } + displayio_display_core_start_refresh(&self->core); const displayio_area_t *current_area = _get_refresh_areas(self); while (current_area != NULL) { _refresh_area(self, current_area); @@ -330,7 +336,7 @@ STATIC void _refresh_display(displayio_display_obj_t *self) { displayio_display_core_finish_refresh(&self->core); } -void common_hal_displayio_display_set_rotation(displayio_display_obj_t *self, int rotation) { +void common_hal_busdisplay_busdisplay_set_rotation(busdisplay_busdisplay_obj_t *self, int rotation) { bool transposed = (self->core.rotation == 90 || self->core.rotation == 270); bool will_transposed = (rotation == 90 || rotation == 270); if (transposed != will_transposed) { @@ -348,12 +354,12 @@ void common_hal_displayio_display_set_rotation(displayio_display_obj_t *self, in } } -uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t *self) { +uint16_t common_hal_busdisplay_busdisplay_get_rotation(busdisplay_busdisplay_obj_t *self) { return self->core.rotation; } -bool common_hal_displayio_display_refresh(displayio_display_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame) { +bool common_hal_busdisplay_busdisplay_refresh(busdisplay_busdisplay_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame) { if (!self->auto_refresh && !self->first_manual_refresh && (target_ms_per_frame != NO_FPS_LIMIT)) { uint64_t current_time = supervisor_ticks_ms64(); uint32_t current_ms_since_real_refresh = current_time - self->core.last_refresh; @@ -378,11 +384,11 @@ bool common_hal_displayio_display_refresh(displayio_display_obj_t *self, uint32_ return true; } -bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t *self) { +bool common_hal_busdisplay_busdisplay_get_auto_refresh(busdisplay_busdisplay_obj_t *self) { return self->auto_refresh; } -void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t *self, +void common_hal_busdisplay_busdisplay_set_auto_refresh(busdisplay_busdisplay_obj_t *self, bool auto_refresh) { self->first_manual_refresh = !auto_refresh; if (auto_refresh != self->auto_refresh) { @@ -395,7 +401,7 @@ void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t *self self->auto_refresh = auto_refresh; } -mp_obj_t common_hal_displayio_display_set_root_group(displayio_display_obj_t *self, displayio_group_t *root_group) { +mp_obj_t common_hal_busdisplay_busdisplay_set_root_group(busdisplay_busdisplay_obj_t *self, displayio_group_t *root_group) { bool ok = displayio_display_core_set_root_group(&self->core, root_group); if (!ok) { mp_raise_ValueError(translate("Group already used")); @@ -403,14 +409,14 @@ mp_obj_t common_hal_displayio_display_set_root_group(displayio_display_obj_t *se return mp_const_none; } -void displayio_display_background(displayio_display_obj_t *self) { +void busdisplay_busdisplay_background(busdisplay_busdisplay_obj_t *self) { if (self->auto_refresh && (supervisor_ticks_ms64() - self->core.last_refresh) > self->native_ms_per_frame) { _refresh_display(self); } } -void release_display(displayio_display_obj_t *self) { - common_hal_displayio_display_set_auto_refresh(self, false); +void release_busdisplay(busdisplay_busdisplay_obj_t *self) { + common_hal_busdisplay_busdisplay_set_auto_refresh(self, false); release_display_core(&self->core); #if (CIRCUITPY_PWMIO) if (self->backlight_pwm.base.type == &pwmio_pwmout_type) { @@ -423,16 +429,16 @@ void release_display(displayio_display_obj_t *self) { #endif } -void reset_display(displayio_display_obj_t *self) { - common_hal_displayio_display_set_auto_refresh(self, true); +void reset_busdisplay(busdisplay_busdisplay_obj_t *self) { + common_hal_busdisplay_busdisplay_set_auto_refresh(self, true); circuitpython_splash.x = 0; // reset position in case someone moved it. circuitpython_splash.y = 0; supervisor_start_terminal(self->core.width, self->core.height); if (!circuitpython_splash.in_group) { - common_hal_displayio_display_set_root_group(self, &circuitpython_splash); + common_hal_busdisplay_busdisplay_set_root_group(self, &circuitpython_splash); } } -void displayio_display_collect_ptrs(displayio_display_obj_t *self) { +void busdisplay_busdisplay_collect_ptrs(busdisplay_busdisplay_obj_t *self) { displayio_display_core_collect_ptrs(&self->core); } diff --git a/shared-module/displayio/Display.h b/shared-module/busdisplay/BusDisplay.h similarity index 82% rename from shared-module/displayio/Display.h rename to shared-module/busdisplay/BusDisplay.h index e56aa87a5f..88778089a0 100644 --- a/shared-module/displayio/Display.h +++ b/shared-module/busdisplay/BusDisplay.h @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_DISPLAY_H -#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_DISPLAY_H +#pragma once #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/displayio/Group.h" @@ -34,11 +33,13 @@ #endif #include "shared-module/displayio/area.h" +#include "shared-module/displayio/bus_core.h" #include "shared-module/displayio/display_core.h" typedef struct { mp_obj_base_t base; displayio_display_core_t core; + displayio_display_bus_t bus; union { digitalio_digitalinout_obj_t backlight_inout; #if CIRCUITPY_PWMIO @@ -54,11 +55,9 @@ typedef struct { bool auto_refresh; bool first_manual_refresh; bool backlight_on_high; -} displayio_display_obj_t; +} busdisplay_busdisplay_obj_t; -void displayio_display_background(displayio_display_obj_t *self); -void release_display(displayio_display_obj_t *self); -void reset_display(displayio_display_obj_t *self); -void displayio_display_collect_ptrs(displayio_display_obj_t *self); - -#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_DISPLAY_H +void busdisplay_busdisplay_background(busdisplay_busdisplay_obj_t *self); +void release_busdisplay(busdisplay_busdisplay_obj_t *self); +void reset_busdisplay(busdisplay_busdisplay_obj_t *self); +void busdisplay_busdisplay_collect_ptrs(busdisplay_busdisplay_obj_t *self); diff --git a/shared-module/busdisplay/__init__.c b/shared-module/busdisplay/__init__.c new file mode 100644 index 0000000000..674343c533 --- /dev/null +++ b/shared-module/busdisplay/__init__.c @@ -0,0 +1,27 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft + * + * 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. + */ + +// Nothing now. diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c index d1e2389c23..d027e12834 100644 --- a/shared-module/displayio/TileGrid.c +++ b/shared-module/displayio/TileGrid.c @@ -31,7 +31,6 @@ #include "shared-bindings/displayio/ColorConverter.h" #include "shared-bindings/displayio/OnDiskBitmap.h" #include "shared-bindings/displayio/Palette.h" -#include "shared-bindings/displayio/Shape.h" void common_hal_displayio_tilegrid_construct(displayio_tilegrid_t *self, mp_obj_t bitmap, uint16_t bitmap_width_in_tiles, uint16_t bitmap_height_in_tiles, @@ -503,8 +502,6 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, // buffer because most bitmaps are row associated. if (mp_obj_is_type(self->bitmap, &displayio_bitmap_type)) { input_pixel.pixel = common_hal_displayio_bitmap_get_pixel(self->bitmap, input_pixel.tile_x, input_pixel.tile_y); - } else if (mp_obj_is_type(self->bitmap, &displayio_shape_type)) { - input_pixel.pixel = common_hal_displayio_shape_get_pixel(self->bitmap, input_pixel.tile_x, input_pixel.tile_y); } else if (mp_obj_is_type(self->bitmap, &displayio_ondiskbitmap_type)) { input_pixel.pixel = common_hal_displayio_ondiskbitmap_get_pixel(self->bitmap, input_pixel.tile_x, input_pixel.tile_y); } @@ -573,8 +570,6 @@ void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self) { } if (mp_obj_is_type(self->bitmap, &displayio_bitmap_type)) { displayio_bitmap_finish_refresh(self->bitmap); - } else if (mp_obj_is_type(self->bitmap, &displayio_shape_type)) { - displayio_shape_finish_refresh(self->bitmap); } else if (mp_obj_is_type(self->bitmap, &displayio_ondiskbitmap_type)) { // OnDiskBitmap changes will trigger a complete reload so no need to // track changes. @@ -619,12 +614,6 @@ displayio_area_t *displayio_tilegrid_get_refresh_areas(displayio_tilegrid_t *sel self->full_change = true; } } - } else if (mp_obj_is_type(self->bitmap, &displayio_shape_type)) { - displayio_area_t *refresh_area = displayio_shape_get_refresh_areas(self->bitmap, tail); - if (refresh_area != tail) { - displayio_area_copy(refresh_area, &self->dirty_area); - self->partial_change = true; - } } self->full_change = self->full_change || diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index c81dcb18c1..4f565226d2 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -32,7 +32,6 @@ #include "py/runtime.h" #include "shared-bindings/board/__init__.h" #include "shared-bindings/displayio/Bitmap.h" -#include "shared-bindings/displayio/Display.h" #include "shared-bindings/displayio/Group.h" #include "shared-bindings/displayio/Palette.h" #include "shared-module/displayio/area.h" @@ -43,6 +42,10 @@ #include "supervisor/spi_flash_api.h" #include "py/mpconfig.h" +#if CIRCUITPY_BUSDISPLAY +#include "shared-bindings/busdisplay/BusDisplay.h" +#endif + #if CIRCUITPY_DOTCLOCKFRAMEBUFFER #include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h" #endif @@ -93,19 +96,24 @@ void displayio_background(void) { } for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { - mp_const_obj_t display_type = displays[i].display.base.type; + mp_const_obj_t display_type = displays[i].display_base.type; if (display_type == NULL || display_type == &mp_type_NoneType) { // Skip null display. continue; } - if (display_type == &displayio_display_type) { - displayio_display_background(&displays[i].display); + if (false) { + #if CIRCUITPY_BUSDISPLAY + } else if (display_type == &busdisplay_busdisplay_type) { + busdisplay_busdisplay_background(&displays[i].display); + #endif #if CIRCUITPY_FRAMEBUFFERIO } else if (display_type == &framebufferio_framebufferdisplay_type) { framebufferio_framebufferdisplay_background(&displays[i].framebuffer_display); #endif - } else if (display_type == &displayio_epaperdisplay_type) { - displayio_epaperdisplay_background(&displays[i].epaper_display); + #if CIRCUITPY_EPAPERDISPLAY + } else if (display_type == &epaperdisplay_epaperdisplay_type) { + epaperdisplay_epaperdisplay_background(&displays[i].epaper_display); + #endif } } @@ -118,32 +126,40 @@ void common_hal_displayio_release_displays(void) { mp_const_obj_t display_type = displays[i].display_base.type; if (display_type == NULL || display_type == &mp_type_NoneType) { continue; - } else if (display_type == &displayio_display_type) { - release_display(&displays[i].display); - } else if (display_type == &displayio_epaperdisplay_type) { + #if CIRCUITPY_BUSDISPLAY + } else if (display_type == &busdisplay_busdisplay_type) { + release_busdisplay(&displays[i].display); + #endif + #if CIRCUITPY_EPAPERDISPLAY + } else if (display_type == &epaperdisplay_epaperdisplay_type) { release_epaperdisplay(&displays[i].epaper_display); + #endif #if CIRCUITPY_FRAMEBUFFERIO } else if (display_type == &framebufferio_framebufferdisplay_type) { release_framebufferdisplay(&displays[i].framebuffer_display); #endif } - displays[i].display.base.type = &mp_type_NoneType; + displays[i].display_base.type = &mp_type_NoneType; } for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { mp_const_obj_t bus_type = display_buses[i].bus_base.type; if (bus_type == NULL || bus_type == &mp_type_NoneType) { continue; - } else if (bus_type == &displayio_fourwire_type) { - common_hal_displayio_fourwire_deinit(&display_buses[i].fourwire_bus); - } else if (bus_type == &displayio_i2cdisplay_type) { - common_hal_displayio_i2cdisplay_deinit(&display_buses[i].i2cdisplay_bus); + #if CIRCUITPY_FOURWIRE + } else if (bus_type == &fourwire_fourwire_type) { + common_hal_fourwire_fourwire_deinit(&display_buses[i].fourwire_bus); + #endif + #if CIRCUITPY_I2CDISPLAYBUS + } else if (bus_type == &i2cdisplaybus_i2cdisplaybus_type) { + common_hal_i2cdisplaybus_i2cdisplaybus_deinit(&display_buses[i].i2cdisplay_bus); + #endif #if CIRCUITPY_DOTCLOCKFRAMEBUFFER } else if (bus_type == &dotclockframebuffer_framebuffer_type) { common_hal_dotclockframebuffer_framebuffer_deinit(&display_buses[i].dotclock); #endif - #if CIRCUITPY_PARALLELDISPLAY - } else if (bus_type == ¶lleldisplay_parallelbus_type) { - common_hal_paralleldisplay_parallelbus_deinit(&display_buses[i].parallel_bus); + #if CIRCUITPY_PARALLELDISPLAYBUS + } else if (bus_type == ¶lleldisplaybus_parallelbus_type) { + common_hal_paralleldisplaybus_parallelbus_deinit(&display_buses[i].parallel_bus); #endif #if CIRCUITPY_RGBMATRIX } else if (bus_type == &rgbmatrix_RGBMatrix_type) { @@ -176,8 +192,11 @@ void reset_displays(void) { // The SPI buses used by FourWires may be allocated on the heap so we need to move them inline. for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { mp_const_obj_t display_bus_type = display_buses[i].bus_base.type; - if (display_bus_type == &displayio_fourwire_type) { - displayio_fourwire_obj_t *fourwire = &display_buses[i].fourwire_bus; + if (display_bus_type == NULL || display_bus_type == &mp_type_NoneType) { + continue; + #if CIRCUITPY_FOURWIRE + } else if (display_bus_type == &fourwire_fourwire_type) { + fourwire_fourwire_obj_t *fourwire = &display_buses[i].fourwire_bus; if (((size_t)fourwire->bus) < ((size_t)&display_buses) || ((size_t)fourwire->bus) > ((size_t)&display_buses + CIRCUITPY_DISPLAY_LIMIT * sizeof(primary_display_bus_t))) { busio_spi_obj_t *original_spi = fourwire->bus; @@ -198,14 +217,16 @@ void reset_displays(void) { fourwire->bus = &fourwire->inline_bus; // Check for other display buses that use the same spi bus and swap them too. for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) { - if (display_buses[j].fourwire_bus.base.type == &displayio_fourwire_type && + if (display_buses[j].fourwire_bus.base.type == &fourwire_fourwire_type && display_buses[j].fourwire_bus.bus == original_spi) { display_buses[j].fourwire_bus.bus = &fourwire->inline_bus; } } } - } else if (display_bus_type == &displayio_i2cdisplay_type) { - displayio_i2cdisplay_obj_t *i2c = &display_buses[i].i2cdisplay_bus; + #endif + #if CIRCUITPY_I2CDISPLAYBUS + } else if (display_bus_type == &i2cdisplaybus_i2cdisplaybus_type) { + i2cdisplaybus_i2cdisplaybus_obj_t *i2c = &display_buses[i].i2cdisplay_bus; // Check to see if we need to inline the I2C bus. if (((size_t)i2c->bus) < ((size_t)&display_buses) || ((size_t)i2c->bus) > ((size_t)&display_buses + CIRCUITPY_DISPLAY_LIMIT * sizeof(primary_display_bus_t))) { @@ -222,12 +243,13 @@ void reset_displays(void) { i2c->bus = &i2c->inline_bus; // Check for other displays that use the same i2c bus and swap them too. for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) { - if (display_buses[j].i2cdisplay_bus.base.type == &displayio_i2cdisplay_type && + if (display_buses[j].i2cdisplay_bus.base.type == &i2cdisplaybus_i2cdisplaybus_type && display_buses[j].i2cdisplay_bus.bus == original_i2c) { display_buses[j].i2cdisplay_bus.bus = &i2c->inline_bus; } } } + #endif #if CIRCUITPY_RGBMATRIX } else if (display_bus_type == &rgbmatrix_RGBMatrix_type) { rgbmatrix_rgbmatrix_obj_t *pm = &display_buses[i].rgbmatrix; @@ -298,11 +320,17 @@ void reset_displays(void) { // Reset the displayed group. Only the first will get the terminal but // that's ok. mp_const_obj_t display_type = displays[i].display_base.type; - if (display_type == &displayio_display_type) { - reset_display(&displays[i].display); - } else if (display_type == &displayio_epaperdisplay_type) { - displayio_epaperdisplay_obj_t *display = &displays[i].epaper_display; - displayio_epaperdisplay_reset(display); + if (display_type == NULL || display_type == &mp_type_NoneType) { + continue; + #if CIRCUITPY_BUSDISPLAY + } else if (display_type == &busdisplay_busdisplay_type) { + reset_busdisplay(&displays[i].display); + #endif + #if CIRCUITPY_EPAPERDISPLAY + } else if (display_type == &epaperdisplay_epaperdisplay_type) { + epaperdisplay_epaperdisplay_obj_t *display = &displays[i].epaper_display; + epaperdisplay_epaperdisplay_reset(display); + #endif #if CIRCUITPY_FRAMEBUFFERIO } else if (display_type == &framebufferio_framebufferdisplay_type) { framebufferio_framebufferdisplay_reset(&displays[i].framebuffer_display); @@ -338,25 +366,28 @@ void displayio_gc_collect(void) { mp_const_obj_t display_type = displays[i].display_base.type; if (display_type == NULL || display_type == &mp_type_NoneType) { continue; - } - // Alternatively, we could use gc_collect_root over the whole object, - // but this is more precise, and is the only field that needs marking. - if (display_type == &displayio_display_type) { - displayio_display_collect_ptrs(&displays[i].display); + // Alternatively, we could use gc_collect_root over the whole object, + // but this is more precise, and is the only field that needs marking. + #if CIRCUITPY_BUSDISPLAY + } else if (display_type == &busdisplay_busdisplay_type) { + busdisplay_busdisplay_collect_ptrs(&displays[i].display); + #endif #if CIRCUITPY_FRAMEBUFFERIO } else if (display_type == &framebufferio_framebufferdisplay_type) { framebufferio_framebufferdisplay_collect_ptrs(&displays[i].framebuffer_display); #endif - } else if (display_type == &displayio_epaperdisplay_type) { - displayio_epaperdisplay_collect_ptrs(&displays[i].epaper_display); + #if CIRCUITPY_EPAPERDISPLAY + } else if (display_type == &epaperdisplay_epaperdisplay_type) { + epaperdisplay_epaperdisplay_collect_ptrs(&displays[i].epaper_display); + #endif } } } primary_display_t *allocate_display(void) { for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { - mp_const_obj_t display_type = displays[i].display.base.type; + mp_const_obj_t display_type = displays[i].display_base.type; if (display_type == NULL || display_type == &mp_type_NoneType) { // Clear this memory so it is in a known state before init. memset(&displays[i], 0, sizeof(displays[i])); diff --git a/shared-module/displayio/__init__.h b/shared-module/displayio/__init__.h index 0695b950ac..7b240e186a 100644 --- a/shared-module/displayio/__init__.h +++ b/shared-module/displayio/__init__.h @@ -24,19 +24,24 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO___INIT___H -#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO___INIT___H - -#include "shared-bindings/displayio/Display.h" -#include "shared-bindings/displayio/EPaperDisplay.h" +#if CIRCUITPY_BUSDISPLAY +#include "shared-bindings/busdisplay/BusDisplay.h" +#endif +#include "shared-bindings/displayio/Group.h" +#if CIRCUITPY_EPAPERDISPLAY +#include "shared-bindings/epaperdisplay/EPaperDisplay.h" +#endif #if CIRCUITPY_FRAMEBUFFERIO #include "shared-bindings/framebufferio/FramebufferDisplay.h" #endif -#include "shared-bindings/displayio/FourWire.h" -#include "shared-bindings/displayio/Group.h" -#include "shared-bindings/displayio/I2CDisplay.h" -#if CIRCUITPY_PARALLELDISPLAY -#include "shared-bindings/paralleldisplay/ParallelBus.h" +#if CIRCUITPY_FOURWIRE +#include "shared-bindings/fourwire/FourWire.h" +#endif +#if CIRCUITPY_I2CDISPLAYBUS +#include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" +#endif +#if CIRCUITPY_PARALLELDISPLAYBUS +#include "shared-bindings/paralleldisplaybus/ParallelBus.h" #endif #if CIRCUITPY_RGBMATRIX #include "shared-bindings/rgbmatrix/RGBMatrix.h" @@ -58,13 +63,19 @@ #include "bindings/picodvi/Framebuffer.h" #endif +#pragma once + typedef struct { union { mp_obj_base_t bus_base; - displayio_fourwire_obj_t fourwire_bus; - displayio_i2cdisplay_obj_t i2cdisplay_bus; - #if CIRCUITPY_PARALLELDISPLAY - paralleldisplay_parallelbus_obj_t parallel_bus; + #if CIRCUITPY_FOURWIRE + fourwire_fourwire_obj_t fourwire_bus; + #endif + #if CIRCUITPY_I2CDISPLAYBUS + i2cdisplaybus_i2cdisplaybus_obj_t i2cdisplay_bus; + #endif + #if CIRCUITPY_PARALLELDISPLAYBUS + paralleldisplaybus_parallelbus_obj_t parallel_bus; #endif #if CIRCUITPY_RGBMATRIX rgbmatrix_rgbmatrix_obj_t rgbmatrix; @@ -90,8 +101,12 @@ typedef struct { typedef struct { union { mp_obj_base_t display_base; - displayio_display_obj_t display; - displayio_epaperdisplay_obj_t epaper_display; + #if CIRCUITPY_BUSDISPLAY + busdisplay_busdisplay_obj_t display; + #endif + #if CIRCUITPY_EPAPERDISPLAY + epaperdisplay_epaperdisplay_obj_t epaper_display; + #endif #if CIRCUITPY_FRAMEBUFFERIO framebufferio_framebufferdisplay_obj_t framebuffer_display; #endif @@ -111,5 +126,3 @@ primary_display_t *allocate_display(void); primary_display_t *allocate_display_or_raise(void); primary_display_bus_t *allocate_display_bus(void); primary_display_bus_t *allocate_display_bus_or_raise(void); - -#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO___INIT___H diff --git a/shared-module/displayio/bus_core.c b/shared-module/displayio/bus_core.c new file mode 100644 index 0000000000..87173c27eb --- /dev/null +++ b/shared-module/displayio/bus_core.c @@ -0,0 +1,233 @@ +/* + * 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 "shared-module/displayio/bus_core.h" + +#include "py/gc.h" +#include "py/runtime.h" +#if CIRCUITPY_FOURWIRE +#include "shared-bindings/fourwire/FourWire.h" +#endif +#if CIRCUITPY_I2CDISPLAYBUS +#include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" +#endif +#if CIRCUITPY_PARALLELDISPLAYBUS +#include "shared-bindings/paralleldisplaybus/ParallelBus.h" +#endif +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/time/__init__.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/display_core.h" +#include "supervisor/shared/display.h" +#include "supervisor/shared/tick.h" + +#include +#include + +#define DISPLAYIO_CORE_DEBUG(...) (void)0 +// #define DISPLAYIO_CORE_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) + +void displayio_display_bus_construct(displayio_display_bus_t *self, + mp_obj_t bus, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, + uint16_t column_command, uint16_t row_command, uint16_t set_current_column_command, uint16_t set_current_row_command, + bool data_as_commands, bool always_toggle_chip_select, bool SH1107_addressing, bool address_little_endian) { + + self->ram_width = ram_width; + self->ram_height = ram_height; + self->colstart = colstart; + self->rowstart = rowstart; + + self->column_command = column_command; + self->row_command = row_command; + self->set_current_column_command = set_current_column_command; + self->set_current_row_command = set_current_row_command; + self->data_as_commands = data_as_commands; + self->always_toggle_chip_select = always_toggle_chip_select; + self->SH1107_addressing = SH1107_addressing; + self->address_little_endian = address_little_endian; + + #if CIRCUITPY_PARALLELDISPLAYBUS + if (mp_obj_is_type(bus, ¶lleldisplaybus_parallelbus_type)) { + self->bus_reset = common_hal_paralleldisplaybus_parallelbus_reset; + self->bus_free = common_hal_paralleldisplaybus_parallelbus_bus_free; + self->begin_transaction = common_hal_paralleldisplaybus_parallelbus_begin_transaction; + self->send = common_hal_paralleldisplaybus_parallelbus_send; + self->end_transaction = common_hal_paralleldisplaybus_parallelbus_end_transaction; + } else + #endif + #if CIRCUITPY_FOURWIRE + if (mp_obj_is_type(bus, &fourwire_fourwire_type)) { + self->bus_reset = common_hal_fourwire_fourwire_reset; + self->bus_free = common_hal_fourwire_fourwire_bus_free; + self->begin_transaction = common_hal_fourwire_fourwire_begin_transaction; + self->send = common_hal_fourwire_fourwire_send; + self->end_transaction = common_hal_fourwire_fourwire_end_transaction; + } else + #endif + #if CIRCUITPY_I2CDISPLAYBUS + if (mp_obj_is_type(bus, &i2cdisplaybus_i2cdisplaybus_type)) { + self->bus_reset = common_hal_i2cdisplaybus_i2cdisplaybus_reset; + self->bus_free = common_hal_i2cdisplaybus_i2cdisplaybus_bus_free; + self->begin_transaction = common_hal_i2cdisplaybus_i2cdisplaybus_begin_transaction; + self->send = common_hal_i2cdisplaybus_i2cdisplaybus_send; + self->end_transaction = common_hal_i2cdisplaybus_i2cdisplaybus_end_transaction; + } else + #endif + { + mp_raise_ValueError(translate("Unsupported display bus type")); + } + self->bus = bus; +} + +bool displayio_display_bus_is_free(displayio_display_bus_t *self) { + return !self->bus || self->bus_free(self->bus); +} + +bool displayio_display_bus_begin_transaction(displayio_display_bus_t *self) { + return self->begin_transaction(self->bus); +} + +void displayio_display_bus_end_transaction(displayio_display_bus_t *self) { + self->end_transaction(self->bus); +} + +void displayio_display_bus_set_region_to_update(displayio_display_bus_t *self, displayio_display_core_t *display, displayio_area_t *area) { + uint16_t x1 = area->x1 + self->colstart; + uint16_t x2 = area->x2 + self->colstart; + uint16_t y1 = area->y1 + self->rowstart; + uint16_t y2 = area->y2 + self->rowstart; + + // Collapse down the dimension where multiple pixels are in a byte. + if (display->colorspace.depth < 8) { + uint8_t pixels_per_byte = 8 / display->colorspace.depth; + if (display->colorspace.pixels_in_byte_share_row) { + x1 /= pixels_per_byte * display->colorspace.bytes_per_cell; + x2 /= pixels_per_byte * display->colorspace.bytes_per_cell; + } else { + y1 /= pixels_per_byte * display->colorspace.bytes_per_cell; + y2 /= pixels_per_byte * display->colorspace.bytes_per_cell; + } + } + + x2 -= 1; + y2 -= 1; + + display_chip_select_behavior_t chip_select = CHIP_SELECT_UNTOUCHED; + if (self->always_toggle_chip_select || self->data_as_commands) { + chip_select = CHIP_SELECT_TOGGLE_EVERY_BYTE; + } + + // Set column. + displayio_display_bus_begin_transaction(self); + uint8_t data[5]; + data[0] = self->column_command; + uint8_t data_length = 1; + display_byte_type_t data_type = DISPLAY_DATA; + if (!self->data_as_commands) { + self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, data, 1); + data_length = 0; + } else { + data_type = DISPLAY_COMMAND; + } + + if (self->ram_width < 0x100) { + data[data_length++] = x1; + data[data_length++] = x2; + } else { + if (self->address_little_endian) { + x1 = __builtin_bswap16(x1); + x2 = __builtin_bswap16(x2); + } + data[data_length++] = x1 >> 8; + data[data_length++] = x1 & 0xff; + data[data_length++] = x2 >> 8; + data[data_length++] = x2 & 0xff; + } + + // Quirk for SH1107 "SH1107_addressing" + // Column lower command = 0x00, Column upper command = 0x10 + if (self->SH1107_addressing) { + data[0] = ((x1 >> 4) & 0x0F) | 0x10; // 0x10 to 0x17 + data[1] = x1 & 0x0F; // 0x00 to 0x0F + data_length = 2; + } + + self->send(self->bus, data_type, chip_select, data, data_length); + displayio_display_bus_end_transaction(self); + + if (self->set_current_column_command != NO_COMMAND) { + uint8_t command = self->set_current_column_command; + displayio_display_bus_begin_transaction(self); + self->send(self->bus, DISPLAY_COMMAND, chip_select, &command, 1); + // Only send the first half of data because it is the first coordinate. + self->send(self->bus, DISPLAY_DATA, chip_select, data, data_length / 2); + displayio_display_bus_end_transaction(self); + } + + + // Set row. + displayio_display_bus_begin_transaction(self); + data[0] = self->row_command; + data_length = 1; + if (!self->data_as_commands) { + self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, data, 1); + data_length = 0; + } + + if (self->ram_height < 0x100) { + data[data_length++] = y1; + data[data_length++] = y2; + } else { + if (self->address_little_endian) { + y1 = __builtin_bswap16(y1); + y2 = __builtin_bswap16(y2); + } + data[data_length++] = y1 >> 8; + data[data_length++] = y1 & 0xff; + data[data_length++] = y2 >> 8; + data[data_length++] = y2 & 0xff; + } + + // Quirk for SH1107 "SH1107_addressing" + // Page address command = 0xB0 + if (self->SH1107_addressing) { + // set the page to our y value + data[0] = 0xB0 | y1; + data_length = 1; + } + + self->send(self->bus, data_type, chip_select, data, data_length); + displayio_display_bus_end_transaction(self); + + if (self->set_current_row_command != NO_COMMAND) { + uint8_t command = self->set_current_row_command; + displayio_display_bus_begin_transaction(self); + self->send(self->bus, DISPLAY_COMMAND, chip_select, &command, 1); + // Only send the first half of data because it is the first coordinate. + self->send(self->bus, DISPLAY_DATA, chip_select, data, data_length / 2); + displayio_display_bus_end_transaction(self); + } +} diff --git a/shared-module/displayio/bus_core.h b/shared-module/displayio/bus_core.h new file mode 100644 index 0000000000..e055d52d7b --- /dev/null +++ b/shared-module/displayio/bus_core.h @@ -0,0 +1,73 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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. + */ + +#pragma once + +#include "shared-bindings/displayio/__init__.h" +#include "shared-bindings/displayio/Group.h" + +#include "shared-module/displayio/area.h" +#include "shared-module/displayio/display_core.h" + +#define NO_COMMAND 0x100 + +typedef struct { + mp_obj_t bus; + display_bus_bus_reset bus_reset; + display_bus_bus_free bus_free; + display_bus_begin_transaction begin_transaction; + display_bus_send send; + display_bus_end_transaction end_transaction; + uint16_t ram_width; + uint16_t ram_height; + int16_t colstart; + int16_t rowstart; + + // Refresh area related. + uint16_t column_command; + uint16_t row_command; + uint16_t set_current_column_command; + uint16_t set_current_row_command; + bool data_as_commands; + bool always_toggle_chip_select; + bool SH1107_addressing; + bool address_little_endian; +} displayio_display_bus_t; + +void displayio_display_bus_construct(displayio_display_bus_t *self, + mp_obj_t bus, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, + uint16_t column_command, uint16_t row_command, uint16_t set_current_column_command, uint16_t set_current_row_command, + bool data_as_commands, bool always_toggle_chip_select, bool SH1107_addressing, bool address_little_endian); + +bool displayio_display_bus_is_free(displayio_display_bus_t *self); +bool displayio_display_bus_begin_transaction(displayio_display_bus_t *self); +void displayio_display_bus_end_transaction(displayio_display_bus_t *self); + +void displayio_display_bus_set_region_to_update(displayio_display_bus_t *self, displayio_display_core_t *display, displayio_area_t *area); + +void release_display_bus(displayio_display_bus_t *self); + +void displayio_display_bus_collect_ptrs(displayio_display_bus_t *self); diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 2af9b19fdb..a2771c4def 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -24,15 +24,10 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/Display.h" +#include "shared-module/displayio/display_core.h" #include "py/gc.h" #include "py/runtime.h" -#include "shared-bindings/displayio/FourWire.h" -#include "shared-bindings/displayio/I2CDisplay.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" @@ -46,10 +41,8 @@ // #define DISPLAYIO_CORE_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) void displayio_display_core_construct(displayio_display_core_t *self, - mp_obj_t bus, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation, - uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word, - uint16_t column_command, uint16_t row_command, uint16_t set_current_column_command, uint16_t set_current_row_command, - bool data_as_commands, bool always_toggle_chip_select, bool SH1107_addressing, bool address_little_endian) { + uint16_t width, uint16_t height, uint16_t rotation, + uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word) { self->colorspace.depth = color_depth; self->colorspace.grayscale = grayscale; self->colorspace.grayscale_bit = 8 - color_depth; @@ -59,58 +52,12 @@ void displayio_display_core_construct(displayio_display_core_t *self, self->colorspace.reverse_bytes_in_word = reverse_bytes_in_word; self->colorspace.dither = false; self->current_group = NULL; - self->colstart = colstart; - self->rowstart = rowstart; self->last_refresh = 0; - self->column_command = column_command; - self->row_command = row_command; - self->set_current_column_command = set_current_column_command; - self->set_current_row_command = set_current_row_command; - self->data_as_commands = data_as_commands; - self->always_toggle_chip_select = always_toggle_chip_select; - self->SH1107_addressing = SH1107_addressing; - self->address_little_endian = address_little_endian; - - // (framebufferdisplay already validated its 'bus' is a buffer-protocol object) - if (bus) { - #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; - self->send = common_hal_displayio_fourwire_send; - self->end_transaction = common_hal_displayio_fourwire_end_transaction; - } else if (mp_obj_is_type(bus, &displayio_i2cdisplay_type)) { - self->bus_reset = common_hal_displayio_i2cdisplay_reset; - self->bus_free = common_hal_displayio_i2cdisplay_bus_free; - self->begin_transaction = common_hal_displayio_i2cdisplay_begin_transaction; - self->send = common_hal_displayio_i2cdisplay_send; - self->end_transaction = common_hal_displayio_i2cdisplay_end_transaction; - } else { - mp_raise_ValueError(translate("Unsupported display bus type")); - } - } - self->bus = bus; - - - // (offsetof core is equal in all display types) - if (self == &displays[0].display.core) { - supervisor_start_terminal(width, height); - } + supervisor_start_terminal(width, height); self->width = width; self->height = height; - self->ram_width = ram_width; - self->ram_height = ram_height; displayio_display_core_set_rotation(self, rotation); } @@ -213,141 +160,7 @@ bool displayio_display_core_get_dither(displayio_display_core_t *self) { return self->colorspace.dither; } -bool displayio_display_core_bus_free(displayio_display_core_t *self) { - return !self->bus || self->bus_free(self->bus); -} - -bool displayio_display_core_begin_transaction(displayio_display_core_t *self) { - return self->begin_transaction(self->bus); -} - -void displayio_display_core_end_transaction(displayio_display_core_t *self) { - self->end_transaction(self->bus); -} - -void displayio_display_core_set_region_to_update(displayio_display_core_t *self, displayio_area_t *area) { - uint16_t x1 = area->x1 + self->colstart; - uint16_t x2 = area->x2 + self->colstart; - uint16_t y1 = area->y1 + self->rowstart; - uint16_t y2 = area->y2 + self->rowstart; - - // Collapse down the dimension where multiple pixels are in a byte. - if (self->colorspace.depth < 8) { - uint8_t pixels_per_byte = 8 / self->colorspace.depth; - if (self->colorspace.pixels_in_byte_share_row) { - x1 /= pixels_per_byte * self->colorspace.bytes_per_cell; - x2 /= pixels_per_byte * self->colorspace.bytes_per_cell; - } else { - y1 /= pixels_per_byte * self->colorspace.bytes_per_cell; - y2 /= pixels_per_byte * self->colorspace.bytes_per_cell; - } - } - - x2 -= 1; - y2 -= 1; - - display_chip_select_behavior_t chip_select = CHIP_SELECT_UNTOUCHED; - if (self->always_toggle_chip_select || self->data_as_commands) { - chip_select = CHIP_SELECT_TOGGLE_EVERY_BYTE; - } - - // Set column. - displayio_display_core_begin_transaction(self); - uint8_t data[5]; - data[0] = self->column_command; - uint8_t data_length = 1; - display_byte_type_t data_type = DISPLAY_DATA; - if (!self->data_as_commands) { - self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, data, 1); - data_length = 0; - } else { - data_type = DISPLAY_COMMAND; - } - - if (self->ram_width < 0x100) { - data[data_length++] = x1; - data[data_length++] = x2; - } else { - if (self->address_little_endian) { - x1 = __builtin_bswap16(x1); - x2 = __builtin_bswap16(x2); - } - data[data_length++] = x1 >> 8; - data[data_length++] = x1 & 0xff; - data[data_length++] = x2 >> 8; - data[data_length++] = x2 & 0xff; - } - - // Quirk for SH1107 "SH1107_addressing" - // Column lower command = 0x00, Column upper command = 0x10 - if (self->SH1107_addressing) { - data[0] = ((x1 >> 4) & 0x0F) | 0x10; // 0x10 to 0x17 - data[1] = x1 & 0x0F; // 0x00 to 0x0F - data_length = 2; - } - - self->send(self->bus, data_type, chip_select, data, data_length); - displayio_display_core_end_transaction(self); - - if (self->set_current_column_command != NO_COMMAND) { - uint8_t command = self->set_current_column_command; - displayio_display_core_begin_transaction(self); - self->send(self->bus, DISPLAY_COMMAND, chip_select, &command, 1); - // Only send the first half of data because it is the first coordinate. - self->send(self->bus, DISPLAY_DATA, chip_select, data, data_length / 2); - displayio_display_core_end_transaction(self); - } - - - // Set row. - displayio_display_core_begin_transaction(self); - data[0] = self->row_command; - data_length = 1; - if (!self->data_as_commands) { - self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, data, 1); - data_length = 0; - } - - if (self->ram_height < 0x100) { - data[data_length++] = y1; - data[data_length++] = y2; - } else { - if (self->address_little_endian) { - y1 = __builtin_bswap16(y1); - y2 = __builtin_bswap16(y2); - } - data[data_length++] = y1 >> 8; - data[data_length++] = y1 & 0xff; - data[data_length++] = y2 >> 8; - data[data_length++] = y2 & 0xff; - } - - // Quirk for SH1107 "SH1107_addressing" - // Page address command = 0xB0 - if (self->SH1107_addressing) { - // set the page to our y value - data[0] = 0xB0 | y1; - data_length = 1; - } - - self->send(self->bus, data_type, chip_select, data, data_length); - displayio_display_core_end_transaction(self); - - if (self->set_current_row_command != NO_COMMAND) { - uint8_t command = self->set_current_row_command; - displayio_display_core_begin_transaction(self); - self->send(self->bus, DISPLAY_COMMAND, chip_select, &command, 1); - // Only send the first half of data because it is the first coordinate. - self->send(self->bus, DISPLAY_DATA, chip_select, data, data_length / 2); - displayio_display_core_end_transaction(self); - } -} - bool displayio_display_core_start_refresh(displayio_display_core_t *self) { - if (!displayio_display_core_bus_free(self)) { - // Can't acquire display bus; skip updating this display. Try next display. - return false; - } if (self->refresh_in_progress) { return false; } diff --git a/shared-module/displayio/display_core.h b/shared-module/displayio/display_core.h index 07e57fbc6a..315c693e23 100644 --- a/shared-module/displayio/display_core.h +++ b/shared-module/displayio/display_core.h @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_DISPLAY_CORE_H -#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_DISPLAY_CORE_H +#pragma once #include "shared-bindings/displayio/__init__.h" #include "shared-bindings/displayio/Group.h" @@ -35,44 +34,22 @@ #define NO_COMMAND 0x100 typedef struct { - mp_obj_t bus; displayio_group_t *current_group; uint64_t last_refresh; - display_bus_bus_reset bus_reset; - display_bus_bus_free bus_free; - display_bus_begin_transaction begin_transaction; - display_bus_send send; - display_bus_end_transaction end_transaction; displayio_buffer_transform_t transform; displayio_area_t area; uint16_t width; uint16_t height; uint16_t rotation; - uint16_t ram_width; - uint16_t ram_height; _displayio_colorspace_t colorspace; - int16_t colstart; - int16_t rowstart; - - // Refresh area related. - uint16_t column_command; - uint16_t row_command; - uint16_t set_current_column_command; - uint16_t set_current_row_command; - bool data_as_commands; - bool always_toggle_chip_select; - bool SH1107_addressing; - bool address_little_endian; bool full_refresh; // New group means we need to refresh the whole display. bool refresh_in_progress; } displayio_display_core_t; void displayio_display_core_construct(displayio_display_core_t *self, - mp_obj_t bus, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation, - uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word, - uint16_t column_command, uint16_t row_command, uint16_t set_current_column_command, uint16_t set_current_row_command, - bool data_as_commands, bool always_toggle_chip_select, bool SH1107_addressing, bool address_little_endian); + uint16_t width, uint16_t height, uint16_t rotation, + uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word); bool displayio_display_core_set_root_group(displayio_display_core_t *self, displayio_group_t *root_group); @@ -84,12 +61,6 @@ bool displayio_display_core_get_dither(displayio_display_core_t *self); void displayio_display_core_set_rotation(displayio_display_core_t *self, int rotation); -bool displayio_display_core_bus_free(displayio_display_core_t *self); -bool displayio_display_core_begin_transaction(displayio_display_core_t *self); -void displayio_display_core_end_transaction(displayio_display_core_t *self); - -void displayio_display_core_set_region_to_update(displayio_display_core_t *self, displayio_area_t *area); - void release_display_core(displayio_display_core_t *self); bool displayio_display_core_start_refresh(displayio_display_core_t *self); @@ -100,5 +71,3 @@ void displayio_display_core_collect_ptrs(displayio_display_core_t *self); bool displayio_display_core_fill_area(displayio_display_core_t *self, displayio_area_t *area, uint32_t *mask, uint32_t *buffer); bool displayio_display_core_clip_area(displayio_display_core_t *self, const displayio_area_t *area, displayio_area_t *clipped); - -#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_DISPLAY_CORE_H diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/epaperdisplay/EPaperDisplay.c similarity index 76% rename from shared-module/displayio/EPaperDisplay.c rename to shared-module/epaperdisplay/EPaperDisplay.c index 4db1b7cb5c..1edf9b09f3 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/epaperdisplay/EPaperDisplay.c @@ -24,17 +24,12 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/EPaperDisplay.h" +#include "shared-bindings/epaperdisplay/EPaperDisplay.h" #include "py/gc.h" #include "py/runtime.h" #include "shared/runtime/interrupt_char.h" #include "shared-bindings/displayio/ColorConverter.h" -#include "shared-bindings/displayio/FourWire.h" -#include "shared-bindings/displayio/I2CDisplay.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" @@ -47,7 +42,7 @@ #define DELAY 0x80 -void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t *self, +void common_hal_epaperdisplay_epaperdisplay_construct(epaperdisplay_epaperdisplay_obj_t *self, mp_obj_t bus, const uint8_t *start_sequence, uint16_t start_sequence_len, mp_float_t start_up_time, const uint8_t *stop_sequence, uint16_t stop_sequence_len, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, @@ -76,8 +71,9 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t core_grayscale = false; } - displayio_display_core_construct(&self->core, bus, width, height, ram_width, ram_height, - colstart, rowstart, rotation, color_depth, core_grayscale, true, 1, true, true, + displayio_display_core_construct(&self->core, width, height, rotation, color_depth, core_grayscale, true, 1, true, true); + displayio_display_bus_construct(&self->bus, bus, ram_width, ram_height, + colstart, rowstart, set_column_window_command, set_row_window_command, set_current_column_command, set_current_row_command, false /* data_as_commands */, chip_select, false /* SH1107_addressing */, address_little_endian); @@ -116,14 +112,14 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t // Set the group after initialization otherwise we may send pixels while we delay in // initialization. - common_hal_displayio_epaperdisplay_set_root_group(self, &circuitpython_splash); + common_hal_epaperdisplay_epaperdisplay_set_root_group(self, &circuitpython_splash); } -bool common_hal_displayio_epaperdisplay_set_root_group(displayio_epaperdisplay_obj_t *self, displayio_group_t *root_group) { +bool common_hal_epaperdisplay_epaperdisplay_set_root_group(epaperdisplay_epaperdisplay_obj_t *self, displayio_group_t *root_group) { return displayio_display_core_set_root_group(&self->core, root_group); } -STATIC const displayio_area_t *displayio_epaperdisplay_get_refresh_areas(displayio_epaperdisplay_obj_t *self) { +STATIC const displayio_area_t *epaperdisplay_epaperdisplay_get_refresh_areas(epaperdisplay_epaperdisplay_obj_t *self) { if (self->core.full_refresh) { self->core.area.next = NULL; return &self->core.area; @@ -132,7 +128,7 @@ STATIC const displayio_area_t *displayio_epaperdisplay_get_refresh_areas(display if (self->core.current_group != NULL) { first_area = displayio_group_get_refresh_areas(self->core.current_group, NULL); } - if (first_area != NULL && self->core.row_command == NO_COMMAND) { + if (first_area != NULL && self->bus.row_command == NO_COMMAND) { // Do a full refresh if the display doesn't support partial updates. self->core.area.next = NULL; return &self->core.area; @@ -140,15 +136,15 @@ STATIC const displayio_area_t *displayio_epaperdisplay_get_refresh_areas(display return first_area; } -uint16_t common_hal_displayio_epaperdisplay_get_width(displayio_epaperdisplay_obj_t *self) { +uint16_t common_hal_epaperdisplay_epaperdisplay_get_width(epaperdisplay_epaperdisplay_obj_t *self) { return displayio_display_core_get_width(&self->core); } -uint16_t common_hal_displayio_epaperdisplay_get_height(displayio_epaperdisplay_obj_t *self) { +uint16_t common_hal_epaperdisplay_epaperdisplay_get_height(epaperdisplay_epaperdisplay_obj_t *self) { return displayio_display_core_get_height(&self->core); } -STATIC void wait_for_busy(displayio_epaperdisplay_obj_t *self) { +STATIC void wait_for_busy(epaperdisplay_epaperdisplay_obj_t *self) { if (self->busy.base.type == &mp_type_NoneType) { return; } @@ -157,7 +153,7 @@ STATIC void wait_for_busy(displayio_epaperdisplay_obj_t *self) { } } -STATIC void send_command_sequence(displayio_epaperdisplay_obj_t *self, +STATIC void send_command_sequence(epaperdisplay_epaperdisplay_obj_t *self, bool should_wait_for_busy, const uint8_t *sequence, uint32_t sequence_len) { uint32_t i = 0; while (i < sequence_len) { @@ -170,10 +166,10 @@ STATIC void send_command_sequence(displayio_epaperdisplay_obj_t *self, data_size = ((data_size & ~DELAY) << 8) + *(cmd + 2); data = cmd + 3; } - displayio_display_core_begin_transaction(&self->core); - self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, cmd, 1); - self->core.send(self->core.bus, DISPLAY_DATA, self->chip_select, data, data_size); - displayio_display_core_end_transaction(&self->core); + displayio_display_bus_begin_transaction(&self->bus); + self->bus.send(self->bus.bus, DISPLAY_COMMAND, self->chip_select, cmd, 1); + self->bus.send(self->bus.bus, DISPLAY_DATA, self->chip_select, data, data_size); + displayio_display_bus_end_transaction(&self->bus); uint16_t delay_length_ms = 0; if (delay) { data_size++; @@ -193,16 +189,21 @@ STATIC void send_command_sequence(displayio_epaperdisplay_obj_t *self, } } -void displayio_epaperdisplay_change_refresh_mode_parameters(displayio_epaperdisplay_obj_t *self, +void epaperdisplay_epaperdisplay_change_refresh_mode_parameters(epaperdisplay_epaperdisplay_obj_t *self, mp_buffer_info_t *start_sequence, float seconds_per_frame) { self->start_sequence = (uint8_t *)start_sequence->buf; self->start_sequence_len = start_sequence->len; self->milliseconds_per_frame = seconds_per_frame * 1000; } -STATIC void displayio_epaperdisplay_start_refresh(displayio_epaperdisplay_obj_t *self) { +STATIC void epaperdisplay_epaperdisplay_start_refresh(epaperdisplay_epaperdisplay_obj_t *self) { + if (!displayio_display_bus_is_free(&self->bus)) { + // Can't acquire display bus; skip updating this display. Try next display. + return; + } + // run start sequence - self->core.bus_reset(self->core.bus); + self->bus.bus_reset(self->bus.bus); common_hal_time_delay_ms(self->start_up_time_ms); @@ -210,7 +211,7 @@ STATIC void displayio_epaperdisplay_start_refresh(displayio_epaperdisplay_obj_t displayio_display_core_start_refresh(&self->core); } -uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaperdisplay_obj_t *self) { +uint32_t common_hal_epaperdisplay_epaperdisplay_get_time_to_refresh(epaperdisplay_epaperdisplay_obj_t *self) { if (self->core.last_refresh == 0) { return 0; } @@ -222,7 +223,7 @@ uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaper return self->milliseconds_per_frame - elapsed_time; } -STATIC void displayio_epaperdisplay_finish_refresh(displayio_epaperdisplay_obj_t *self) { +STATIC void epaperdisplay_epaperdisplay_finish_refresh(epaperdisplay_epaperdisplay_obj_t *self) { // Actually refresh the display now that all pixel RAM has been updated. send_command_sequence(self, false, self->refresh_sequence, self->refresh_sequence_len); @@ -232,11 +233,11 @@ STATIC void displayio_epaperdisplay_finish_refresh(displayio_epaperdisplay_obj_t displayio_display_core_finish_refresh(&self->core); } -mp_obj_t common_hal_displayio_epaperdisplay_get_bus(displayio_epaperdisplay_obj_t *self) { - return self->core.bus; +mp_obj_t common_hal_epaperdisplay_epaperdisplay_get_bus(epaperdisplay_epaperdisplay_obj_t *self) { + return self->bus.bus; } -void common_hal_displayio_epaperdisplay_set_rotation(displayio_epaperdisplay_obj_t *self, int rotation) { +void common_hal_epaperdisplay_epaperdisplay_set_rotation(epaperdisplay_epaperdisplay_obj_t *self, int rotation) { bool transposed = (self->core.rotation == 90 || self->core.rotation == 270); bool will_transposed = (rotation == 90 || rotation == 270); if (transposed != will_transposed) { @@ -254,18 +255,18 @@ void common_hal_displayio_epaperdisplay_set_rotation(displayio_epaperdisplay_obj } } -uint16_t common_hal_displayio_epaperdisplay_get_rotation(displayio_epaperdisplay_obj_t *self) { +uint16_t common_hal_epaperdisplay_epaperdisplay_get_rotation(epaperdisplay_epaperdisplay_obj_t *self) { return self->core.rotation; } -mp_obj_t common_hal_displayio_epaperdisplay_get_root_group(displayio_epaperdisplay_obj_t *self) { +mp_obj_t common_hal_epaperdisplay_epaperdisplay_get_root_group(epaperdisplay_epaperdisplay_obj_t *self) { if (self->core.current_group == NULL) { return mp_const_none; } return self->core.current_group; } -STATIC bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t *self, const displayio_area_t *area) { +STATIC bool epaperdisplay_epaperdisplay_refresh_area(epaperdisplay_epaperdisplay_obj_t *self, const displayio_area_t *area) { uint16_t buffer_size = 128; // In uint32_ts displayio_area_t clipped; @@ -306,17 +307,17 @@ STATIC bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t * for (uint8_t pass = 0; pass < passes; pass++) { uint16_t remaining_rows = displayio_area_height(&clipped); - if (self->core.row_command != NO_COMMAND) { - displayio_display_core_set_region_to_update(&self->core, &clipped); + if (self->bus.row_command != NO_COMMAND) { + displayio_display_bus_set_region_to_update(&self->bus, &self->core, &clipped); } uint8_t write_command = self->write_black_ram_command; if (pass == 1) { write_command = self->write_color_ram_command; } - displayio_display_core_begin_transaction(&self->core); - self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, &write_command, 1); - displayio_display_core_end_transaction(&self->core); + displayio_display_bus_begin_transaction(&self->bus); + self->bus.send(self->bus.bus, DISPLAY_COMMAND, self->chip_select, &write_command, 1); + displayio_display_bus_end_transaction(&self->bus); for (uint16_t j = 0; j < subrectangles; j++) { displayio_area_t subrectangle = { @@ -362,12 +363,12 @@ STATIC bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t * } } - if (!displayio_display_core_begin_transaction(&self->core)) { + if (!displayio_display_bus_begin_transaction(&self->bus)) { // Can't acquire display bus; skip the rest of the data. Try next display. return false; } - self->core.send(self->core.bus, DISPLAY_DATA, self->chip_select, (uint8_t *)buffer, subrectangle_size_bytes); - displayio_display_core_end_transaction(&self->core); + self->bus.send(self->bus.bus, DISPLAY_DATA, self->chip_select, (uint8_t *)buffer, subrectangle_size_bytes); + displayio_display_bus_end_transaction(&self->bus); // TODO(tannewt): Make refresh displays faster so we don't starve other // background tasks. @@ -380,7 +381,7 @@ STATIC bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t * return true; } -STATIC bool _clean_area(displayio_epaperdisplay_obj_t *self) { +STATIC bool _clean_area(epaperdisplay_epaperdisplay_obj_t *self) { uint16_t width = displayio_display_core_get_width(&self->core); uint16_t height = displayio_display_core_get_height(&self->core); @@ -388,17 +389,17 @@ STATIC bool _clean_area(displayio_epaperdisplay_obj_t *self) { memset(buffer, 0x77, width / 2); uint8_t write_command = self->write_black_ram_command; - displayio_display_core_begin_transaction(&self->core); - self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, &write_command, 1); - displayio_display_core_end_transaction(&self->core); + displayio_display_bus_begin_transaction(&self->bus); + self->bus.send(self->bus.bus, DISPLAY_COMMAND, self->chip_select, &write_command, 1); + displayio_display_bus_end_transaction(&self->bus); for (uint16_t j = 0; j < height; j++) { - if (!displayio_display_core_begin_transaction(&self->core)) { + if (!displayio_display_bus_begin_transaction(&self->bus)) { // Can't acquire display bus; skip the rest of the data. Try next display. return false; } - self->core.send(self->core.bus, DISPLAY_DATA, self->chip_select, buffer, width / 2); - displayio_display_core_end_transaction(&self->core); + self->bus.send(self->bus.bus, DISPLAY_DATA, self->chip_select, buffer, width / 2); + displayio_display_bus_end_transaction(&self->bus); // TODO(tannewt): Make refresh displays faster so we don't starve other // background tasks. @@ -410,7 +411,7 @@ STATIC bool _clean_area(displayio_epaperdisplay_obj_t *self) { return true; } -bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *self) { +bool common_hal_epaperdisplay_epaperdisplay_refresh(epaperdisplay_epaperdisplay_obj_t *self) { if (self->refreshing && self->busy.base.type == &digitalio_digitalinout_type) { if (common_hal_digitalio_digitalinout_get_value(&self->busy) != self->busy_state) { @@ -426,21 +427,21 @@ bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *s return true; } // Refresh at seconds per frame rate. - if (common_hal_displayio_epaperdisplay_get_time_to_refresh(self) > 0) { + if (common_hal_epaperdisplay_epaperdisplay_get_time_to_refresh(self) > 0) { return false; } - if (!displayio_display_core_bus_free(&self->core)) { + if (!displayio_display_bus_is_free(&self->bus)) { // Can't acquire display bus; skip updating this display. Try next display. return false; } - const displayio_area_t *current_area = displayio_epaperdisplay_get_refresh_areas(self); + const displayio_area_t *current_area = epaperdisplay_epaperdisplay_get_refresh_areas(self); if (current_area == NULL) { return true; } if (self->acep) { - displayio_epaperdisplay_start_refresh(self); + epaperdisplay_epaperdisplay_start_refresh(self); _clean_area(self); - displayio_epaperdisplay_finish_refresh(self); + epaperdisplay_epaperdisplay_finish_refresh(self); while (self->refreshing && !mp_hal_is_interrupted()) { RUN_BACKGROUND_TASKS; } @@ -449,16 +450,16 @@ bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *s return false; } - displayio_epaperdisplay_start_refresh(self); + epaperdisplay_epaperdisplay_start_refresh(self); while (current_area != NULL) { - displayio_epaperdisplay_refresh_area(self, current_area); + epaperdisplay_epaperdisplay_refresh_area(self, current_area); current_area = current_area->next; } - displayio_epaperdisplay_finish_refresh(self); + epaperdisplay_epaperdisplay_finish_refresh(self); return true; } -void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t *self) { +void epaperdisplay_epaperdisplay_background(epaperdisplay_epaperdisplay_obj_t *self) { if (self->refreshing) { bool refresh_done = false; if (self->busy.base.type == &digitalio_digitalinout_type) { @@ -476,12 +477,12 @@ void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t *self) { } } -bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t *self) { - displayio_epaperdisplay_background(self); +bool common_hal_epaperdisplay_epaperdisplay_get_busy(epaperdisplay_epaperdisplay_obj_t *self) { + epaperdisplay_epaperdisplay_background(self); return self->refreshing; } -void release_epaperdisplay(displayio_epaperdisplay_obj_t *self) { +void release_epaperdisplay(epaperdisplay_epaperdisplay_obj_t *self) { if (self->refreshing) { wait_for_busy(self); supervisor_disable_tick(); @@ -496,12 +497,12 @@ void release_epaperdisplay(displayio_epaperdisplay_obj_t *self) { } } -void displayio_epaperdisplay_reset(displayio_epaperdisplay_obj_t *self) { +void epaperdisplay_epaperdisplay_reset(epaperdisplay_epaperdisplay_obj_t *self) { displayio_display_core_set_root_group(&self->core, &circuitpython_splash); self->core.full_refresh = true; } -void displayio_epaperdisplay_collect_ptrs(displayio_epaperdisplay_obj_t *self) { +void epaperdisplay_epaperdisplay_collect_ptrs(epaperdisplay_epaperdisplay_obj_t *self) { displayio_display_core_collect_ptrs(&self->core); gc_collect_ptr((void *)self->start_sequence); gc_collect_ptr((void *)self->stop_sequence); @@ -509,17 +510,17 @@ void displayio_epaperdisplay_collect_ptrs(displayio_epaperdisplay_obj_t *self) { size_t maybe_refresh_epaperdisplay(void) { for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { - if (displays[i].epaper_display.base.type != &displayio_epaperdisplay_type || + if (displays[i].epaper_display.base.type != &epaperdisplay_epaperdisplay_type || displays[i].epaper_display.core.current_group != &circuitpython_splash) { // Skip regular displays and those not showing the splash. continue; } - displayio_epaperdisplay_obj_t *display = &displays[i].epaper_display; - size_t time_to_refresh = common_hal_displayio_epaperdisplay_get_time_to_refresh(display); + epaperdisplay_epaperdisplay_obj_t *display = &displays[i].epaper_display; + size_t time_to_refresh = common_hal_epaperdisplay_epaperdisplay_get_time_to_refresh(display); if (time_to_refresh > 0) { return time_to_refresh; } - if (common_hal_displayio_epaperdisplay_refresh(display)) { + if (common_hal_epaperdisplay_epaperdisplay_refresh(display)) { return 0; } // If we could refresh but it failed, then we want to retry. diff --git a/shared-module/displayio/EPaperDisplay.h b/shared-module/epaperdisplay/EPaperDisplay.h similarity index 78% rename from shared-module/displayio/EPaperDisplay.h rename to shared-module/epaperdisplay/EPaperDisplay.h index d527ed2f50..7cd0be915f 100644 --- a/shared-module/displayio/EPaperDisplay.h +++ b/shared-module/epaperdisplay/EPaperDisplay.h @@ -24,18 +24,19 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_EPAPERDISPLAY_H -#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_EPAPERDISPLAY_H +#pragma once #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/displayio/Group.h" #include "shared-module/displayio/area.h" +#include "shared-module/displayio/bus_core.h" #include "shared-module/displayio/display_core.h" typedef struct { mp_obj_base_t base; displayio_display_core_t core; + displayio_display_bus_t bus; digitalio_digitalinout_obj_t busy; uint32_t milliseconds_per_frame; const uint8_t *start_sequence; @@ -57,15 +58,13 @@ typedef struct { bool acep; bool two_byte_sequence_length; display_chip_select_behavior_t chip_select; -} displayio_epaperdisplay_obj_t; +} epaperdisplay_epaperdisplay_obj_t; -void displayio_epaperdisplay_change_refresh_mode_parameters(displayio_epaperdisplay_obj_t *self, +void epaperdisplay_epaperdisplay_change_refresh_mode_parameters(epaperdisplay_epaperdisplay_obj_t *self, mp_buffer_info_t *start_sequence, float seconds_per_frame); -void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t *self); -void displayio_epaperdisplay_reset(displayio_epaperdisplay_obj_t *self); -void release_epaperdisplay(displayio_epaperdisplay_obj_t *self); +void epaperdisplay_epaperdisplay_background(epaperdisplay_epaperdisplay_obj_t *self); +void epaperdisplay_epaperdisplay_reset(epaperdisplay_epaperdisplay_obj_t *self); +void release_epaperdisplay(epaperdisplay_epaperdisplay_obj_t *self); size_t maybe_refresh_epaperdisplay(void); -void displayio_epaperdisplay_collect_ptrs(displayio_epaperdisplay_obj_t *self); - -#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_EPAPERDISPLAY_H +void epaperdisplay_epaperdisplay_collect_ptrs(epaperdisplay_epaperdisplay_obj_t *self); diff --git a/shared-module/epaperdisplay/__init__.c b/shared-module/epaperdisplay/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/displayio/FourWire.c b/shared-module/fourwire/FourWire.c similarity index 88% rename from shared-module/displayio/FourWire.c rename to shared-module/fourwire/FourWire.c index 41d43400f9..a349e8d7b7 100644 --- a/shared-module/displayio/FourWire.c +++ b/shared-module/fourwire/FourWire.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/fourwire/FourWire.h" #include @@ -34,9 +34,8 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/time/__init__.h" -#include "shared-module/displayio/display_core.h" -void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t *self, +void common_hal_fourwire_fourwire_construct(fourwire_fourwire_obj_t *self, busio_spi_obj_t *spi, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *reset, uint32_t baudrate, uint8_t polarity, uint8_t phase) { @@ -67,13 +66,13 @@ void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t *self, common_hal_digitalio_digitalinout_construct(&self->reset, reset); common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL); common_hal_never_reset_pin(reset); - common_hal_displayio_fourwire_reset(self); + common_hal_fourwire_fourwire_reset(self); } common_hal_never_reset_pin(chip_select); } -void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t *self) { +void common_hal_fourwire_fourwire_deinit(fourwire_fourwire_obj_t *self) { if (self->bus == &self->inline_bus) { common_hal_busio_spi_deinit(self->bus); } @@ -83,8 +82,8 @@ void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t *self) { common_hal_reset_pin(self->reset.pin); } -bool common_hal_displayio_fourwire_reset(mp_obj_t obj) { - displayio_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_fourwire_fourwire_reset(mp_obj_t obj) { + fourwire_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->reset.base.type == &mp_type_NoneType) { return false; } @@ -95,8 +94,8 @@ bool common_hal_displayio_fourwire_reset(mp_obj_t obj) { return true; } -bool common_hal_displayio_fourwire_bus_free(mp_obj_t obj) { - displayio_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_fourwire_fourwire_bus_free(mp_obj_t obj) { + fourwire_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); if (!common_hal_busio_spi_try_lock(self->bus)) { return false; } @@ -104,8 +103,8 @@ bool common_hal_displayio_fourwire_bus_free(mp_obj_t obj) { return true; } -bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t obj) { - displayio_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_fourwire_fourwire_begin_transaction(mp_obj_t obj) { + fourwire_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); if (!common_hal_busio_spi_try_lock(self->bus)) { return false; } @@ -115,9 +114,9 @@ bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t obj) { return true; } -void common_hal_displayio_fourwire_send(mp_obj_t obj, display_byte_type_t data_type, +void common_hal_fourwire_fourwire_send(mp_obj_t obj, display_byte_type_t data_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { - displayio_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); + fourwire_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->command.base.type == &mp_type_NoneType) { // When the data/command pin is not specified, we simulate a 9-bit SPI mode, by // adding a data/command bit to every byte, and then splitting the resulting data back @@ -172,8 +171,8 @@ void common_hal_displayio_fourwire_send(mp_obj_t obj, display_byte_type_t data_t } } -void common_hal_displayio_fourwire_end_transaction(mp_obj_t obj) { - displayio_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); +void common_hal_fourwire_fourwire_end_transaction(mp_obj_t obj) { + fourwire_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->chip_select, true); common_hal_busio_spi_unlock(self->bus); } diff --git a/shared-module/displayio/FourWire.h b/shared-module/fourwire/FourWire.h similarity index 88% rename from shared-module/displayio/FourWire.h rename to shared-module/fourwire/FourWire.h index b28c1ef840..ba365554d1 100644 --- a/shared-module/displayio/FourWire.h +++ b/shared-module/fourwire/FourWire.h @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FOURWIRE_H -#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FOURWIRE_H +#pragma once #include "common-hal/busio/SPI.h" #include "common-hal/digitalio/DigitalInOut.h" @@ -41,6 +40,4 @@ typedef struct { uint32_t frequency; uint8_t polarity; uint8_t phase; -} displayio_fourwire_obj_t; - -#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FOURWIRE_H +} fourwire_fourwire_obj_t; diff --git a/shared-module/fourwire/__init__.c b/shared-module/fourwire/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c index df70010a0f..88c7bdd351 100644 --- a/shared-module/framebufferio/FramebufferDisplay.c +++ b/shared-module/framebufferio/FramebufferDisplay.c @@ -54,28 +54,18 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu self->framebuffer = framebuffer; self->framebuffer_protocol = mp_proto_get_or_throw(MP_QSTR_protocol_framebuffer, framebuffer); - uint16_t ram_width = 0x100; - uint16_t ram_height = 0x100; uint16_t depth = fb_getter_default(get_color_depth, 16); displayio_display_core_construct( &self->core, - NULL, self->framebuffer_protocol->get_width(self->framebuffer), self->framebuffer_protocol->get_height(self->framebuffer), - ram_width, - ram_height, - 0, - 0, 0, // rotation depth, fb_getter_default(get_grayscale, (depth < 8)), fb_getter_default(get_pixels_in_byte_share_row, false), fb_getter_default(get_bytes_per_cell, 2), fb_getter_default(get_reverse_pixels_in_byte, false), - fb_getter_default(get_reverse_pixels_in_word, false), - // Region update related settings that aren't used by framebuffer display. - NO_COMMAND, NO_COMMAND, NO_COMMAND, NO_COMMAND, - false, false, false, false + fb_getter_default(get_reverse_pixels_in_word, false) ); self->first_pixel_offset = fb_getter_default(get_first_pixel_offset, 0); diff --git a/shared-module/displayio/I2CDisplay.c b/shared-module/i2cdisplaybus/I2CDisplayBus.c similarity index 79% rename from shared-module/displayio/I2CDisplay.c rename to shared-module/i2cdisplaybus/I2CDisplayBus.c index f38e4d6296..78ac36d61a 100644 --- a/shared-module/displayio/I2CDisplay.c +++ b/shared-module/i2cdisplaybus/I2CDisplayBus.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/displayio/I2CDisplay.h" +#include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" #include #include @@ -38,7 +38,7 @@ #include "shared-bindings/time/__init__.h" #include "shared-module/displayio/display_core.h" -void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t *self, +void common_hal_i2cdisplaybus_i2cdisplaybus_construct(i2cdisplaybus_i2cdisplaybus_obj_t *self, busio_i2c_obj_t *i2c, uint16_t device_address, const mcu_pin_obj_t *reset) { // Reset the display before probing @@ -48,13 +48,13 @@ void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t *self, common_hal_digitalio_digitalinout_construct(&self->reset, reset); common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL); common_hal_never_reset_pin(reset); - common_hal_displayio_i2cdisplay_reset(self); + common_hal_i2cdisplaybus_i2cdisplaybus_reset(self); } // Probe the bus to see if a device acknowledges the given address. if (!common_hal_busio_i2c_probe(i2c, device_address)) { self->base.type = &mp_type_NoneType; - common_hal_displayio_i2cdisplay_deinit(self); + common_hal_i2cdisplaybus_i2cdisplaybus_deinit(self); mp_raise_ValueError_varg(translate("Unable to find I2C Display at %x"), device_address); } @@ -68,7 +68,7 @@ void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t *self, self->address = device_address; } -void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t *self) { +void common_hal_i2cdisplaybus_i2cdisplaybus_deinit(i2cdisplaybus_i2cdisplaybus_obj_t *self) { if (self->bus == &self->inline_bus) { common_hal_busio_i2c_deinit(self->bus); } @@ -78,8 +78,8 @@ void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t *self) { } } -bool common_hal_displayio_i2cdisplay_reset(mp_obj_t obj) { - displayio_i2cdisplay_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_i2cdisplaybus_i2cdisplaybus_reset(mp_obj_t obj) { + i2cdisplaybus_i2cdisplaybus_obj_t *self = MP_OBJ_TO_PTR(obj); if (self->reset.base.type == &mp_type_NoneType) { return false; } @@ -90,8 +90,8 @@ bool common_hal_displayio_i2cdisplay_reset(mp_obj_t obj) { return true; } -bool common_hal_displayio_i2cdisplay_bus_free(mp_obj_t obj) { - displayio_i2cdisplay_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_i2cdisplaybus_i2cdisplaybus_bus_free(mp_obj_t obj) { + i2cdisplaybus_i2cdisplaybus_obj_t *self = MP_OBJ_TO_PTR(obj); if (!common_hal_busio_i2c_try_lock(self->bus)) { return false; } @@ -99,14 +99,14 @@ bool common_hal_displayio_i2cdisplay_bus_free(mp_obj_t obj) { return true; } -bool common_hal_displayio_i2cdisplay_begin_transaction(mp_obj_t obj) { - displayio_i2cdisplay_obj_t *self = MP_OBJ_TO_PTR(obj); +bool common_hal_i2cdisplaybus_i2cdisplaybus_begin_transaction(mp_obj_t obj) { + i2cdisplaybus_i2cdisplaybus_obj_t *self = MP_OBJ_TO_PTR(obj); return common_hal_busio_i2c_try_lock(self->bus); } -void common_hal_displayio_i2cdisplay_send(mp_obj_t obj, display_byte_type_t data_type, +void common_hal_i2cdisplaybus_i2cdisplaybus_send(mp_obj_t obj, display_byte_type_t data_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { - displayio_i2cdisplay_obj_t *self = MP_OBJ_TO_PTR(obj); + i2cdisplaybus_i2cdisplaybus_obj_t *self = MP_OBJ_TO_PTR(obj); if (data_type == DISPLAY_COMMAND) { uint8_t command_bytes[2 * data_length]; for (uint32_t i = 0; i < data_length; i++) { @@ -122,7 +122,7 @@ void common_hal_displayio_i2cdisplay_send(mp_obj_t obj, display_byte_type_t data } } -void common_hal_displayio_i2cdisplay_end_transaction(mp_obj_t obj) { - displayio_i2cdisplay_obj_t *self = MP_OBJ_TO_PTR(obj); +void common_hal_i2cdisplaybus_i2cdisplaybus_end_transaction(mp_obj_t obj) { + i2cdisplaybus_i2cdisplaybus_obj_t *self = MP_OBJ_TO_PTR(obj); common_hal_busio_i2c_unlock(self->bus); } diff --git a/shared-module/displayio/I2CDisplay.h b/shared-module/i2cdisplaybus/I2CDisplayBus.h similarity index 87% rename from shared-module/displayio/I2CDisplay.h rename to shared-module/i2cdisplaybus/I2CDisplayBus.h index cc5bcf1eb7..be5a24a951 100644 --- a/shared-module/displayio/I2CDisplay.h +++ b/shared-module/i2cdisplaybus/I2CDisplayBus.h @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_I2CDISPLAY_H -#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_I2CDISPLAY_H +#pragma once #include "common-hal/busio/I2C.h" #include "common-hal/digitalio/DigitalInOut.h" @@ -36,6 +35,4 @@ typedef struct { busio_i2c_obj_t inline_bus; digitalio_digitalinout_obj_t reset; uint16_t address; -} displayio_i2cdisplay_obj_t; - -#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_I2CDISPLAY_H +} i2cdisplaybus_i2cdisplaybus_obj_t; diff --git a/shared-module/i2cdisplaybus/__init__.c b/shared-module/i2cdisplaybus/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/paralleldisplay/ParallelBus.c b/shared-module/paralleldisplaybus/ParallelBus.c similarity index 91% rename from shared-module/paralleldisplay/ParallelBus.c rename to shared-module/paralleldisplaybus/ParallelBus.c index 3a9495934e..cb6ebfb32a 100644 --- a/shared-module/paralleldisplay/ParallelBus.c +++ b/shared-module/paralleldisplaybus/ParallelBus.c @@ -24,13 +24,13 @@ * THE SOFTWARE. */ -#include "shared-bindings/paralleldisplay/ParallelBus.h" +#include "shared-bindings/paralleldisplaybus/ParallelBus.h" #include "py/runtime.h" // If non-sequential pins aren't supported, then this default (weak) // implementation will raise an exception for you. __attribute__((weak)) -void common_hal_paralleldisplay_parallelbus_construct_nonsequential(paralleldisplay_parallelbus_obj_t *self, +void common_hal_paralleldisplaybus_parallelbus_construct_nonsequential(paralleldisplaybus_parallelbus_obj_t *self, uint8_t n_pins, const mcu_pin_obj_t **data_pins, 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("This microcontroller only supports data0=, not data_pins=, because it requires contiguous pins.")); diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c index 3c8141ab8b..22f26f48b1 100644 --- a/supervisor/shared/display.c +++ b/supervisor/shared/display.c @@ -60,6 +60,9 @@ static supervisor_allocation *tilegrid_tiles = NULL; #endif void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { + if (supervisor_terminal_started()) { + return; + } // Default the scale to 2 because we may show blinka without the terminal for // languages that don't have font support. uint8_t scale = 2;