diff --git a/BUILDING.md b/BUILDING.md index 1c47eb7b45..c5b4c5ae9b 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -48,7 +48,7 @@ To compile (or recompile) mpy-cross: make -C mpy-cross -# Building +## Building There a number of ports of CircuitPython! To build for your board, change to the appropriate ports directory and build. @@ -64,7 +64,7 @@ If you aren't sure what boards exist, have a peek in the boards subdirectory of If you have a fast computer with many cores, consider adding `-j` to your build flags, such as `-j17` on a 6-core 12-thread machine. -# Testing +## Testing If you are working on changes to the core language, you might find it useful to run the test suite. The test suite in the top level `tests` directory. It needs the unix port to run. @@ -84,7 +84,7 @@ A successful run will say something like 676 tests passed 30 tests skipped: buffered_writer builtin_help builtin_range_binop class_delattr_setattr cmd_parsetree extra_coverage framebuf1 framebuf16 framebuf2 framebuf4 framebuf8 framebuf_subclass mpy_invalid namedtuple_asdict non_compliant resource_stream schedule sys_getsizeof urandom_extra ure_groups ure_span ure_sub ure_sub_unmatched vfs_basic vfs_fat_fileio1 vfs_fat_fileio2 vfs_fat_more vfs_fat_oldproto vfs_fat_ramdisk vfs_userfs -# Debugging +## Debugging The easiest way to debug CircuitPython on hardware is with a JLink device, JLinkGDBServer, and an appropriate GDB. Instructions can be found at https://learn.adafruit.com/debugging-the-samd21-with-gdb @@ -99,7 +99,7 @@ Example: If your port/build includes `arm-none-eabi-gdb-py`, consider using it instead, as it can be used for better register debugging with https://github.com/bnahill/PyCortexMDebug -# Code Quality Checks +## Code Quality Checks We apply code quality checks using pre-commit. Install pre-commit once per system with diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 15b4cfc892..68e9cbeb7d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,9 +38,9 @@ For SAMD21 debugging workflow tips check out [this learn guide](https://learn.ad Scott Shawcroft ([@tannewt](https://github.com/tannewt)) is the lead developer of CircuitPython and is sponsored by [Adafruit Industries LLC](https://adafruit.com). Scott is usually available during US West Coast working hours. Dan Halbert ([@dhalbert](https://github.com/dhalbert)) and -Kattni Rembor ([@kattni](https://github.com/kattni)) are also sponsored by [Adafruit Industries - LLC](https://adafruit.com) and are usually available during US East Coast daytime hours including -some weekends. +Jeff Epler ([@jepler](https://github.com/jepler)) are also sponsored by [Adafruit Industries +LLC](https://adafruit.com) and are usually available during US daytime hours including some +weekends. They are all reachable on [Discord](https://adafru.it/discord), GitHub issues and the [Adafruit support forum](https://forums.adafruit.com/viewforum.php?f=60). diff --git a/README.rst b/README.rst index 96ca69a50e..9175cfb4a2 100644 --- a/README.rst +++ b/README.rst @@ -56,10 +56,6 @@ Specifically useful documentation when starting out: - `CircuitPython Essentials `__ - `Example Code `__ -Code Search ------------- -GitHub doesn't currently support code search on forks. Therefore, CircuitPython doesn't have code search through GitHub because it is a fork of MicroPython. Luckily, `SourceGraph `_ has free code search for public repos like CircuitPython. So, visit `sourcegraph.com/github.com/adafruit/circuitpython `_ to search the CircuitPython codebase online. - Contributing ------------ diff --git a/conf.py b/conf.py index 11a589dd3b..938a71fa73 100644 --- a/conf.py +++ b/conf.py @@ -218,12 +218,12 @@ exclude_patterns = ["**/build*", "ports/nrf/usb", "ports/raspberrypi/sdk", "ports/raspberrypi/lib", - "ports/silabs", + "ports/silabs/gecko_sdk", + "ports/silabs/tools", "ports/stm/st_driver", "ports/stm/packages", "ports/stm/peripherals", "ports/stm/ref", - "ports/unix", "py", "shared/*", "shared-bindings/util.*", @@ -362,14 +362,21 @@ latex_elements = { # Additional stuff for the LaTeX preamble. #'preamble': '', # Include 3 levels of headers in PDF ToC -'preamble': '\setcounter{tocdepth}{2}', +'preamble': r''' +\setcounter{tocdepth}{2} +\hbadness=99999 +\hfuzz=20pt +\usepackage{pdflscape} +''', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'CircuitPython.tex', 'CircuitPython Documentation', + ("docs/pdf", 'CircuitPython.tex', 'CircuitPython Documentation', + 'CircuitPython Contributors', 'manual'), + ("shared-bindings/support_matrix", 'SupportMatrix.tex', 'Board Support Matrix', 'CircuitPython Contributors', 'manual'), ] diff --git a/docs/pdf.rst b/docs/pdf.rst new file mode 100644 index 0000000000..b60b0f77b2 --- /dev/null +++ b/docs/pdf.rst @@ -0,0 +1,60 @@ +:orphan: + +Adafruit CircuitPython API Reference +==================================== + +Welcome to the API reference documentation for Adafruit CircuitPython. +This contains low-level API reference docs which may link out to separate +*"getting started"* guides. `Adafruit `_ has many +excellent tutorials available through the +`Adafruit Learning System `_. + + +.. toctree:: + :maxdepth: 3 + + ../README.rst + libraries.rst + workflows + environment.rst + troubleshooting.rst + ../CONTRIBUTING + ../BUILDING + ../WEBUSB_README + supported_ports.rst + +Design and porting reference +---------------------------- + +.. toctree:: + :maxdepth: 1 + + design_guide + porting + common_hal + +API Reference +---------------------- + +.. toctree:: + :glob: + :maxdepth: 3 + + library/index.rst + ../shared-bindings/*/index + ../shared-bindings/help + + +.. toctree:: + :maxdepth: 1 + + reference/glossary.rst + ../CODE_OF_CONDUCT + ../docs/LICENSE + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/supported_ports.rst b/docs/supported_ports.rst index fbe61e81ce..6112dd3e0e 100644 --- a/docs/supported_ports.rst +++ b/docs/supported_ports.rst @@ -12,10 +12,13 @@ is limited. :maxdepth: 2 ../ports/atmel-samd/README + ../ports/broadcom/README ../ports/cxd56/README ../ports/espressif/README ../ports/litex/README ../ports/mimxrt10xx/README ../ports/nrf/README ../ports/raspberrypi/README + ../ports/silabs/README ../ports/stm/README + ../ports/unix/README diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index 9c0da3cda6..27d8187e71 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -540,7 +540,7 @@ STATIC const mp_vfs_proto_t fat_vfs_proto = { MP_DEFINE_CONST_OBJ_TYPE( mp_fat_vfs_type, MP_QSTR_VfsFat, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, fat_vfs_make_new, protocol, &fat_vfs_proto, locals_dict, &fat_vfs_locals_dict 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/bindings/samd/Clock.c b/ports/atmel-samd/bindings/samd/Clock.c index fb8dd366d6..f483cfe376 100644 --- a/ports/atmel-samd/bindings/samd/Clock.c +++ b/ports/atmel-samd/bindings/samd/Clock.c @@ -131,7 +131,7 @@ STATIC MP_DEFINE_CONST_DICT(samd_clock_locals_dict, samd_clock_locals_dict_table MP_DEFINE_CONST_OBJ_TYPE( samd_clock_type, MP_QSTR_Clock, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, print, samd_clock_print, locals_dict, &samd_clock_locals_dict ); 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/README.rst b/ports/broadcom/README.rst new file mode 100644 index 0000000000..10ff81711b --- /dev/null +++ b/ports/broadcom/README.rst @@ -0,0 +1,5 @@ +Broadcom +================== + +This port supports running CircuitPython bare-metal on Raspberry Pi single board +computers that utilize Broadcom system-on-chips. diff --git a/ports/broadcom/bindings/videocore/Framebuffer.c b/ports/broadcom/bindings/videocore/Framebuffer.c index 7239456d3e..0816e31aed 100644 --- a/ports/broadcom/bindings/videocore/Framebuffer.c +++ b/ports/broadcom/bindings/videocore/Framebuffer.c @@ -172,7 +172,7 @@ STATIC const framebuffer_p_t videocore_framebuffer_proto = { MP_DEFINE_CONST_OBJ_TYPE( videocore_framebuffer_type, MP_QSTR_Framebuffer, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, (mp_obj_dict_t *)&videocore_framebuffer_locals_dict, make_new, videocore_framebuffer_make_new, buffer, common_hal_videocore_framebuffer_get_buffer, 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/cxd56/README.md b/ports/cxd56/README.md index d727722249..cccc2b6bac 100644 --- a/ports/cxd56/README.md +++ b/ports/cxd56/README.md @@ -1,4 +1,4 @@ -# CircuitPython port to Spresense # +# CXD56 (Spresense) # This directory contains the port of CircuitPython to Spresense. It is a compact development board based on Sony’s power-efficient multicore microcontroller diff --git a/ports/espressif/README.rst b/ports/espressif/README.rst index b8b0a097aa..6964d47a0e 100644 --- a/ports/espressif/README.rst +++ b/ports/espressif/README.rst @@ -1,4 +1,4 @@ -CircuitPython on Espressif SoCs +Espressif ======================================= This port adds the Espressif line of SoCs to CircuitPython. @@ -10,9 +10,11 @@ Support Status: :header: SoC, Status ESP32, "beta" + ESP32-H2, "alpha" ESP32-C3, "beta" + ESP32-C6, "alpha" ESP32-S2, "stable" - ESP32-S3, "beta" + ESP32-S3, "stable" How this port is organized: --------------------------------------- diff --git a/ports/espressif/bindings/espcamera/Camera.c b/ports/espressif/bindings/espcamera/Camera.c index aea4cc775b..8e02d80f22 100644 --- a/ports/espressif/bindings/espcamera/Camera.c +++ b/ports/espressif/bindings/espcamera/Camera.c @@ -995,7 +995,7 @@ STATIC MP_DEFINE_CONST_DICT(espcamera_camera_locals_dict, espcamera_camera_local MP_DEFINE_CONST_OBJ_TYPE( espcamera_camera_type, MP_QSTR_Camera, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, espcamera_camera_make_new, locals_dict, &espcamera_camera_locals_dict ); diff --git a/ports/espressif/bindings/espnow/ESPNow.c b/ports/espressif/bindings/espnow/ESPNow.c index 1f544758d1..08ed4087ba 100644 --- a/ports/espressif/bindings/espnow/ESPNow.c +++ b/ports/espressif/bindings/espnow/ESPNow.c @@ -362,7 +362,7 @@ STATIC mp_obj_t espnow_unary_op(mp_unary_op_t op, mp_obj_t self_in) { MP_DEFINE_CONST_OBJ_TYPE( espnow_type, MP_QSTR_ESPNow, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, espnow_make_new, locals_dict, &espnow_locals_dict, protocol, &espnow_stream_p, diff --git a/ports/espressif/bindings/espnow/Peer.c b/ports/espressif/bindings/espnow/Peer.c index 9f6b46ac8e..cfe49954ff 100644 --- a/ports/espressif/bindings/espnow/Peer.c +++ b/ports/espressif/bindings/espnow/Peer.c @@ -225,7 +225,7 @@ STATIC MP_DEFINE_CONST_DICT(espnow_peer_locals_dict, espnow_peer_locals_dict_tab MP_DEFINE_CONST_OBJ_TYPE( espnow_peer_type, MP_QSTR_Peer, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, espnow_peer_make_new, locals_dict, &espnow_peer_locals_dict ); diff --git a/ports/espressif/bindings/espulp/ULP.c b/ports/espressif/bindings/espulp/ULP.c index 4e9c331758..9fd3be4297 100644 --- a/ports/espressif/bindings/espulp/ULP.c +++ b/ports/espressif/bindings/espulp/ULP.c @@ -175,7 +175,7 @@ STATIC MP_DEFINE_CONST_DICT(espulp_ulp_locals_dict, espulp_ulp_locals_table); MP_DEFINE_CONST_OBJ_TYPE( espulp_ulp_type, MP_QSTR_ULP, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, espulp_ulp_make_new, locals_dict, &espulp_ulp_locals_dict ); 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/README.md b/ports/mimxrt10xx/README.md index fe7fd5ea69..c5039d03de 100644 --- a/ports/mimxrt10xx/README.md +++ b/ports/mimxrt10xx/README.md @@ -1,3 +1,3 @@ -# CircuitPython Port To The NXP i.MX RT10xx Series +# NXP i.MX RT10xx Series This is a port of CircuitPython to the i.MX RT10xx series of chips. 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/README.md b/ports/nrf/README.md index 88dd472738..481de89727 100644 --- a/ports/nrf/README.md +++ b/ports/nrf/README.md @@ -1,4 +1,4 @@ -# CircuitPython Port To The Nordic Semiconductor nRF52 Series +# Nordic Semiconductor nRF52 Series This is a port of CircuitPython to the Nordic Semiconductor nRF52 series of chips. 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/README.rst b/ports/raspberrypi/README.rst index d6ad9b3335..4e615b9d92 100644 --- a/ports/raspberrypi/README.rst +++ b/ports/raspberrypi/README.rst @@ -15,4 +15,6 @@ Port Specific modules --------------------- .. toctree:: + ../../shared-bindings/cyw43/index + ../../shared-bindings/picodvi/index ../../shared-bindings/rp2pio/index diff --git a/ports/raspberrypi/bindings/picodvi/Framebuffer.c b/ports/raspberrypi/bindings/picodvi/Framebuffer.c index c327ce284d..8a34a90b8b 100644 --- a/ports/raspberrypi/bindings/picodvi/Framebuffer.c +++ b/ports/raspberrypi/bindings/picodvi/Framebuffer.c @@ -251,7 +251,7 @@ STATIC const framebuffer_p_t picodvi_framebuffer_proto = { MP_DEFINE_CONST_OBJ_TYPE( picodvi_framebuffer_type, MP_QSTR_Framebuffer, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &picodvi_framebuffer_locals_dict, make_new, picodvi_framebuffer_make_new, buffer, common_hal_picodvi_framebuffer_get_buffer, diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 120145f5ea..37a3fd6f7f 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -862,7 +862,7 @@ STATIC MP_DEFINE_CONST_DICT(rp2pio_statemachine_locals_dict, rp2pio_statemachine MP_DEFINE_CONST_OBJ_TYPE( rp2pio_statemachine_type, MP_QSTR_StateMachine, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, rp2pio_statemachine_make_new, locals_dict, &rp2pio_statemachine_locals_dict ); 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/README.md b/ports/silabs/README.md index 3813104727..1307a95743 100644 --- a/ports/silabs/README.md +++ b/ports/silabs/README.md @@ -1,4 +1,4 @@ -# CircuitPython on EFR32 # +# Silicon Labs EFR32 # ![GitHub](https://img.shields.io/badge/Technology-Bluetooth_BLE-green) ![GitHub](https://img.shields.io/badge/CircuitPython-8.1.0--beta.0-green) @@ -84,11 +84,11 @@ Flash the project by using [Simplicity Commander](https://community.silabs.com/s ### Connecting to the Serial Console ### -Connect the devkit to the PC via the USB cable. The board uses serial for REPL access and debugging because the EFR32 chips has no USB support. +Connect the devkit to the PC via the USB cable. The board uses serial for REPL access and debugging because the EFR32 chips has no USB support. #### Windows #### -On Windows, we need to install a serial console e.g., PuTTY, MobaXterm. The JLink CDC UART Port can be found in the Device Manager. +On Windows, we need to install a serial console e.g., PuTTY, MobaXterm. The JLink CDC UART Port can be found in the Device Manager. #### Linux #### @@ -96,17 +96,17 @@ Open a terminal and issue the following command: ls /dev/ttyACM* -Then note down the correct name and substitute com-port-name in the following command with it: +Then note down the correct name and substitute `com-port-name` in the following command with it: screen /dev/'com-port-name' ### Using the REPL prompt ### -After flashing the firmware to the board, at your first connecting to the board, you might see a blank screen. Press enter and you should be presented with a Circuitpython prompt, >>>. If not, try to reset the board (see instructions below). +After flashing the firmware to the board, at your first connecting to the board, you might see a blank screen. Press enter and you should be presented with a Circuitpython prompt,`>>>`. If not, try to reset the board (see instructions below). You can now type in simple commands such as: - >>> print("Hello world!")  + >>> print("Hello world!") Hello world! If something goes wrong with the board, you can reset it. Pressing CTRL+D when the prompt is open performs a soft reset. @@ -119,13 +119,13 @@ Config serial: Tools > Options > Interpreter > Select MicroPython > Select Port ### Running CircuitPython scripts ### -At the boot stage, two scripts will be run (if not booting in safe mode). First, the file  boot.py  will be executed. The file **boot.py** can be used to perform the initial setup. Then, after boot.py has been completed, the file **code.py** will be executed.   +At the boot stage, two scripts will be run (if not booting in safe mode). First, the file `boot.py` will be executed. The file `boot.py` can be used to perform the initial setup. Then, after `boot.py` has been completed, the file `code.py` will be executed. -After code.py has finished executing, a REPL prompt will be presented on the serial port. Other files can also be executed by using the **Thonny** editors or using **Ampy** tool. +After code.py has finished executing, a REPL prompt will be presented on the serial port. Other files can also be executed by using the **Thonny** editors or using **Ampy** tool. ![Thonny](./res/Thonny.png) -With the boards which support USB mass storage, we can drag the files to the board file system. However, because the EFR32 boards don’t support USB mass storage, we need to use a tool like **Ampy** to copy the file to the board. You can use the latest version of **Ampy** and its  command to copy the module directories to the board. +With the boards which support USB mass storage, we can drag the files to the board file system. However, because the EFR32 boards don’t support USB mass storage, we need to use a tool like **Ampy** to copy the file to the board. You can use the latest version of **Ampy** and its command to copy the module directories to the board. Refer to the guide below for installing the **Ampy** tool: diff --git a/ports/silabs/license.md b/ports/silabs/license.md deleted file mode 100644 index 4833861a01..0000000000 --- a/ports/silabs/license.md +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2013-2022 Damien P. George and others - -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. 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/README.md b/ports/stm/README.md index 5df9cedee2..f7a0b735ab 100644 --- a/ports/stm/README.md +++ b/ports/stm/README.md @@ -1,4 +1,4 @@ -# Circuitpython on STM32 # +# ST Microelectronics STM32 # This port brings the ST Microelectronics STM32 series of MCUs to Circuitpython. STM32 chips have a wide range of capability, from <$1 low power STM32F0s to dual-core STM32H7s running at 400+ MHz. Currently, only the F4, F7, and H7 families are supported, powered by the ARM Cortex M4 and M7 processors. 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/ports/unix/README.md b/ports/unix/README.md index e15fd93b23..21661dc877 100644 --- a/ports/unix/README.md +++ b/ports/unix/README.md @@ -1,5 +1,5 @@ The Unix version ----------------- +================ The "unix" port requires a standard Unix-like environment with gcc and GNU make. This includes Linux, BSD, macOS, and Windows Subsystem for Linux. The @@ -46,7 +46,7 @@ Browse available modules at for more information about `mip`. External dependencies ---------------------- +===================== The `libffi` library and `pkg-config` tool are required. On Debian/Ubuntu/Mint derivative Linux distros, install `build-essential`(includes toolchain and diff --git a/ports/unix/main.c b/ports/unix/main.c index d9a7c0ed35..cc876970af 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -593,6 +593,9 @@ MP_NOINLINE int main_(int argc, char **argv) { MP_DECLARE_CONST_FUN_OBJ_0(extra_cpp_coverage_obj); mp_store_global(MP_QSTR_extra_coverage, MP_OBJ_FROM_PTR(&extra_coverage_obj)); mp_store_global(MP_QSTR_extra_cpp_coverage, MP_OBJ_FROM_PTR(&extra_cpp_coverage_obj)); + // CIRCUITPY-CHANGE: test native base classes work as needed by CircuitPython libraries. + extern const mp_obj_type_t native_base_class_type; + mp_store_global(MP_QSTR_NativeBaseClass, MP_OBJ_FROM_PTR(&native_base_class_type)); } #endif diff --git a/ports/unix/native_base_class.c b/ports/unix/native_base_class.c new file mode 100644 index 0000000000..42cea88e18 --- /dev/null +++ b/ports/unix/native_base_class.c @@ -0,0 +1,87 @@ +#include "py/obj.h" +#include "py/objproperty.h" +#include "py/objtype.h" +#include "py/runtime.h" + +#if defined(MICROPY_UNIX_COVERAGE) + +// This is a native base class that is used in tests. + +typedef struct { + mp_obj_base_t base; + mp_obj_t test; +} native_base_class_obj_t; + +const mp_obj_type_t native_base_class_type; + +STATIC mp_obj_t native_base_class_make_new(const mp_obj_type_t *type, size_t n_args, + size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_test }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_test, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, + }; + 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); + + native_base_class_obj_t *self = mp_obj_malloc(native_base_class_obj_t, &native_base_class_type); + self->test = args[ARG_test].u_obj; + return MP_OBJ_FROM_PTR(self); +} + +// Helper to ensure we have the native super class instead of a subclass. +static native_base_class_obj_t *native_base(mp_obj_t unknown_obj) { + mp_obj_t native_obj = mp_obj_cast_to_native_base(unknown_obj, &native_base_class_type); + mp_obj_assert_native_inited(native_obj); + return MP_OBJ_TO_PTR(native_obj); +} + +STATIC mp_obj_t native_base_class_obj_get_test(mp_obj_t self_in) { + native_base_class_obj_t *self = native_base(self_in); + return self->test; +} +MP_DEFINE_CONST_FUN_OBJ_1(native_base_class_get_test_obj, native_base_class_obj_get_test); + +STATIC mp_obj_t native_base_class_obj_set_test(mp_obj_t self_in, mp_obj_t value) { + mp_printf(&mp_plat_print, "native base class .test set to: "); + mp_obj_print_helper(&mp_plat_print, value, PRINT_REPR); + mp_printf(&mp_plat_print, "\n"); + native_base_class_obj_t *self = native_base(self_in); + self->test = value; + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(native_base_class_set_test_obj, native_base_class_obj_set_test); + +MP_PROPERTY_GETSET(native_base_class_test_obj, + (mp_obj_t)&native_base_class_get_test_obj, + (mp_obj_t)&native_base_class_set_test_obj); + +STATIC mp_obj_t native_base_class_obj_print_subclass_attr(mp_obj_t self_in, mp_obj_t attr_name_obj) { + if (!mp_obj_is_str(attr_name_obj)) { + mp_raise_TypeError(NULL); + } + qstr attr_name = mp_obj_str_get_qstr(attr_name_obj); + mp_obj_t value = mp_load_attr(self_in, attr_name); + mp_printf(&mp_plat_print, "native base class .%q set to: ", attr_name); + mp_obj_print_helper(&mp_plat_print, value, PRINT_REPR); + mp_printf(&mp_plat_print, "\n"); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(native_base_class_print_subclass_attr_obj, native_base_class_obj_print_subclass_attr); + +STATIC const mp_rom_map_elem_t native_base_class_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_test), MP_ROM_PTR(&native_base_class_test_obj) }, + + { MP_ROM_QSTR(MP_QSTR_print_subclass_attr), MP_ROM_PTR(&native_base_class_print_subclass_attr_obj) }, + +}; +STATIC MP_DEFINE_CONST_DICT(native_base_class_locals_dict, native_base_class_locals_dict_table); + +MP_DEFINE_CONST_OBJ_TYPE( + native_base_class_type, + MP_QSTR_NativeBaseClass, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, + make_new, &native_base_class_make_new, + locals_dict, &native_base_class_locals_dict + ); + +#endif diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index e19a136194..f48084e9dd 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -90,6 +90,7 @@ CFLAGS += \ -DCIRCUITPY_TRACEBACK=1 \ -DCIRCUITPY_ZLIB=1 -SRC_C += coverage.c +# CIRCUITPY-CHANGE: test native base classes. +SRC_C += coverage.c native_base_class.c SRC_CXX += coveragecpp.cpp CIRCUITPY_MESSAGE_COMPRESSION_LEVEL = 1 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/py/objproperty.h b/py/objproperty.h index c1b5dba460..0098bfd0b1 100644 --- a/py/objproperty.h +++ b/py/objproperty.h @@ -28,6 +28,12 @@ #include "py/obj.h" +// CIRCUITPY-CHANGE: MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS marks classes with +// properties, descriptors, __delattr__ or __setattr___. +// When defining native classes that use properties, you *must* set the +// MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS flag. Otherwise, the property will be +// ignored. + #if MICROPY_PY_BUILTINS_PROPERTY typedef struct _mp_obj_property_t { diff --git a/py/objstringio.c b/py/objstringio.c index a3c66ed010..a5167768d7 100644 --- a/py/objstringio.c +++ b/py/objstringio.c @@ -45,15 +45,26 @@ STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) { #define check_stringio_is_open(o) #endif +STATIC mp_obj_stringio_t *native_obj(mp_obj_t o_in) { + mp_obj_stringio_t *native = mp_obj_cast_to_native_base(o_in, &mp_type_stringio); + + #if MICROPY_PY_IO_BYTESIO + if (native == MP_OBJ_NULL) { + native = mp_obj_cast_to_native_base(o_in, &mp_type_bytesio); + } + #endif + return native; +} + STATIC void stringio_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { (void)kind; - mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_stringio_t *self = native_obj(self_in); mp_printf(print, self->base.type == &mp_type_stringio ? "" : "", self); } STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) { (void)errcode; - mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); + mp_obj_stringio_t *o = native_obj(o_in); check_stringio_is_open(o); if (o->vstr->len <= o->pos) { // read to EOF, or seeked to EOF or beyond return 0; @@ -77,7 +88,7 @@ STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) { STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { (void)errcode; - mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); + mp_obj_stringio_t *o = native_obj(o_in); check_stringio_is_open(o); if (o->vstr->fixed_buf) { @@ -111,7 +122,7 @@ STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, STATIC mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) { (void)errcode; - mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); + mp_obj_stringio_t *o = native_obj(o_in); switch (request) { case MP_STREAM_SEEK: { struct mp_stream_seek_t *s = (struct mp_stream_seek_t *)arg; @@ -163,7 +174,7 @@ STATIC mp_uint_t stringio_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, #define STREAM_TO_CONTENT_TYPE(o) (((o)->base.type == &mp_type_stringio) ? &mp_type_str : &mp_type_bytes) STATIC mp_obj_t stringio_getvalue(mp_obj_t self_in) { - mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_stringio_t *self = native_obj(self_in); check_stringio_is_open(self); // TODO: Try to avoid copying string return mp_obj_new_str_of_type(STREAM_TO_CONTENT_TYPE(self), (byte *)self->vstr->buf, self->vstr->len); diff --git a/py/objtype.c b/py/objtype.c index 8716c7cc12..d15d36a10e 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -193,16 +193,15 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_t // do a lookup, not a (base) type in which we found the class method. const mp_obj_type_t *org_type = (const mp_obj_type_t *)lookup->obj; mp_convert_member_lookup(MP_OBJ_NULL, org_type, elem->value, lookup->dest); + } else if (mp_obj_is_type(elem->value, &mp_type_property)) { + // CIRCUITPY-CHANGE: CircuitPython uses properties on native classes, so we always return them. + lookup->dest[0] = elem->value; + return; } else { mp_obj_instance_t *obj = lookup->obj; - mp_obj_t obj_obj; - if (obj != NULL && mp_obj_is_native_type(type) && type != &mp_type_object /* object is not a real type */) { - // If we're dealing with native base class, then it applies to native sub-object - obj_obj = obj->subobj[0]; - } else { - obj_obj = MP_OBJ_FROM_PTR(obj); - } - mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest); + // CIRCUITPY-CHANGE: Pass object directly. MP passes the native object. + // This allows native code to lookup and call functions on Python subclasses. + mp_convert_member_lookup(obj, type, elem->value, lookup->dest); } #if DEBUG_PRINT DEBUG_printf("mp_obj_class_lookup: Returning: "); @@ -1172,9 +1171,10 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) #endif } #if ENABLE_SPECIAL_ACCESSORS + // Inherit the special accessors flag. + base_flags |= t->flags & MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS; if (mp_obj_is_instance_type(t)) { t->flags |= MP_TYPE_FLAG_IS_SUBCLASSED; - base_flags |= t->flags & MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS; } #endif } diff --git a/py/runtime.c b/py/runtime.c index a488949e74..5b205cd764 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1241,6 +1241,16 @@ void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { mp_map_t *locals_map = &MP_OBJ_TYPE_GET_SLOT(type, locals_dict)->map; mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); if (elem != NULL) { + // CIRCUITPY-CHANGE: Validate flag + #if MICROPY_PY_BUILTINS_PROPERTY + // Validate that the type has the correct flag for properties. It is manually + // managed for native types. If the flag is missing, then act like the + // attribute doesn't exist. + if (mp_obj_is_type(elem->value, &mp_type_property) && (type->flags & MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS) == 0) { + dest[1] = MP_OBJ_NULL; + return; + } + #endif mp_convert_member_lookup(obj, type, elem->value, dest); } return; diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 6b90258111..fcc5959491 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -471,7 +471,7 @@ STATIC MP_DEFINE_CONST_DICT(bleio_adapter_locals_dict, bleio_adapter_locals_dict MP_DEFINE_CONST_OBJ_TYPE( bleio_adapter_type, MP_QSTR_Adapter, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, bleio_adapter_make_new, locals_dict, &bleio_adapter_locals_dict ); diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index 623bc7aaed..977d731a3e 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -202,7 +202,7 @@ STATIC MP_DEFINE_CONST_DICT(bleio_address_locals_dict, bleio_address_locals_dict MP_DEFINE_CONST_OBJ_TYPE( bleio_address_type, MP_QSTR_Address, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, bleio_address_make_new, print, bleio_address_print, locals_dict, &bleio_address_locals_dict, diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 8b14acd7df..1dbf7f4a08 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -328,7 +328,7 @@ STATIC void bleio_characteristic_print(const mp_print_t *print, mp_obj_t self_in MP_DEFINE_CONST_OBJ_TYPE( bleio_characteristic_type, MP_QSTR_Characteristic, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, print, bleio_characteristic_print, locals_dict, &bleio_characteristic_locals_dict ); diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index 474a07f7b9..b5a35ac095 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -225,7 +225,7 @@ STATIC const mp_stream_p_t characteristic_buffer_stream_p = { MP_DEFINE_CONST_OBJ_TYPE( bleio_characteristic_buffer_type, MP_QSTR_CharacteristicBuffer, - MP_TYPE_FLAG_ITER_IS_ITERNEXT, + MP_TYPE_FLAG_ITER_IS_ITERNEXT | MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, bleio_characteristic_buffer_make_new, locals_dict, &bleio_characteristic_buffer_locals_dict, iter, mp_stream_unbuffered_iter, diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index 6f67996103..1f33749438 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -247,6 +247,6 @@ STATIC MP_DEFINE_CONST_DICT(bleio_connection_locals_dict, bleio_connection_local MP_DEFINE_CONST_OBJ_TYPE( bleio_connection_type, MP_QSTR_Connection, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &bleio_connection_locals_dict ); diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index 093b51100e..fd28e924e8 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -214,7 +214,7 @@ STATIC void bleio_descriptor_print(const mp_print_t *print, mp_obj_t self_in, mp MP_DEFINE_CONST_OBJ_TYPE( bleio_descriptor_type, MP_QSTR_Descriptor, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, print, bleio_descriptor_print, locals_dict, &bleio_descriptor_locals_dict ); diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index c97e97b410..fbdb5ffc2b 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -232,7 +232,7 @@ STATIC MP_DEFINE_CONST_DICT(bleio_packet_buffer_locals_dict, bleio_packet_buffer MP_DEFINE_CONST_OBJ_TYPE( bleio_packet_buffer_type, MP_QSTR_PacketBuffer, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, bleio_packet_buffer_make_new, locals_dict, &bleio_packet_buffer_locals_dict ); diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c index f859f22be1..f03048e7c4 100644 --- a/shared-bindings/_bleio/ScanEntry.c +++ b/shared-bindings/_bleio/ScanEntry.c @@ -139,6 +139,6 @@ STATIC MP_DEFINE_CONST_DICT(bleio_scanentry_locals_dict, bleio_scanentry_locals_ MP_DEFINE_CONST_OBJ_TYPE( bleio_scanentry_type, MP_QSTR_ScanEntry, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &bleio_scanentry_locals_dict ); diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index f5ffa982f6..22475f35f6 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -143,7 +143,7 @@ STATIC void bleio_service_print(const mp_print_t *print, mp_obj_t self_in, mp_pr MP_DEFINE_CONST_OBJ_TYPE( bleio_service_type, MP_QSTR_Service, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, bleio_service_make_new, print, bleio_service_print, locals_dict, &bleio_service_locals_dict diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index c177e096f5..5bb668553b 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -283,7 +283,7 @@ void bleio_uuid_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t MP_DEFINE_CONST_OBJ_TYPE( bleio_uuid_type, MP_QSTR_UUID, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, print, bleio_uuid_print, make_new, bleio_uuid_make_new, locals_dict, &bleio_uuid_locals_dict, diff --git a/shared-bindings/_pixelmap/PixelMap.c b/shared-bindings/_pixelmap/PixelMap.c index 4d06fe64fa..6297ef38f4 100644 --- a/shared-bindings/_pixelmap/PixelMap.c +++ b/shared-bindings/_pixelmap/PixelMap.c @@ -258,7 +258,7 @@ STATIC MP_DEFINE_CONST_DICT(pixelmap_pixelmap_locals_dict, pixelmap_pixelmap_loc MP_DEFINE_CONST_OBJ_TYPE( pixelmap_pixelmap_type, MP_QSTR_PixelMap, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &pixelmap_pixelmap_locals_dict, make_new, pixelmap_pixelmap_make_new, subscr, pixelmap_pixelmap_subscr, 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/adafruit_pixelbuf/PixelBuf.c b/shared-bindings/adafruit_pixelbuf/PixelBuf.c index 20455026b4..a7970366a5 100644 --- a/shared-bindings/adafruit_pixelbuf/PixelBuf.c +++ b/shared-bindings/adafruit_pixelbuf/PixelBuf.c @@ -371,7 +371,7 @@ STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_loc MP_DEFINE_CONST_OBJ_TYPE( pixelbuf_pixelbuf_type, MP_QSTR_PixelBuf, - MP_TYPE_FLAG_ITER_IS_GETITER, + MP_TYPE_FLAG_ITER_IS_GETITER | MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &pixelbuf_pixelbuf_locals_dict, make_new, pixelbuf_pixelbuf_make_new, subscr, pixelbuf_pixelbuf_subscr, diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index 8344c43c9b..3d8758346d 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -252,7 +252,7 @@ STATIC MP_DEFINE_CONST_DICT(aesio_locals_dict, aesio_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( aesio_aes_type, MP_QSTR_AES, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, aesio_aes_make_new, locals_dict, &aesio_locals_dict ); diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index 2e9441c725..4d7e9ed495 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -120,7 +120,7 @@ STATIC MP_DEFINE_CONST_DICT(alarm_pin_pinalarm_locals_dict, alarm_pin_pinalarm_l MP_DEFINE_CONST_OBJ_TYPE( alarm_pin_pinalarm_type, MP_QSTR_PinAlarm, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, alarm_pin_pinalarm_make_new, locals_dict, &alarm_pin_pinalarm_locals_dict ); diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 9a6440d451..960f93d1c0 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -134,7 +134,7 @@ STATIC MP_DEFINE_CONST_DICT(alarm_time_timealarm_locals_dict, alarm_time_timeala MP_DEFINE_CONST_OBJ_TYPE( alarm_time_timealarm_type, MP_QSTR_TimeAlarm, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, alarm_time_timealarm_make_new, locals_dict, &alarm_time_timealarm_locals_dict ); diff --git a/shared-bindings/alarm/touch/TouchAlarm.c b/shared-bindings/alarm/touch/TouchAlarm.c index 6433e1d845..2c2bb97327 100644 --- a/shared-bindings/alarm/touch/TouchAlarm.c +++ b/shared-bindings/alarm/touch/TouchAlarm.c @@ -82,7 +82,7 @@ STATIC MP_DEFINE_CONST_DICT(alarm_touch_touchalarm_locals_dict, alarm_touch_touc MP_DEFINE_CONST_OBJ_TYPE( alarm_touch_touchalarm_type, MP_QSTR_TouchAlarm, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, alarm_touch_touchalarm_make_new, locals_dict, &alarm_touch_touchalarm_locals_dict ); diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index c99d48fd56..cff9e10b89 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -152,7 +152,7 @@ STATIC MP_DEFINE_CONST_DICT(analogio_analogin_locals_dict, analogio_analogin_loc MP_DEFINE_CONST_OBJ_TYPE( analogio_analogin_type, MP_QSTR_AnalogIn, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, analogio_analogin_make_new, locals_dict, &analogio_analogin_locals_dict ); diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index facf45cf98..0c6ca73670 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -133,7 +133,7 @@ STATIC MP_DEFINE_CONST_DICT(analogio_analogout_locals_dict, analogio_analogout_l MP_DEFINE_CONST_OBJ_TYPE( analogio_analogout_type, MP_QSTR_AnalogOut, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, analogio_analogout_make_new, locals_dict, &analogio_analogout_locals_dict ); diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 1306e423c2..d3b722ebcb 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -275,7 +275,7 @@ STATIC MP_DEFINE_CONST_DICT(audiobusio_i2sout_locals_dict, audiobusio_i2sout_loc MP_DEFINE_CONST_OBJ_TYPE( audiobusio_i2sout_type, MP_QSTR_I2SOut, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, audiobusio_i2sout_make_new, locals_dict, &audiobusio_i2sout_locals_dict ); diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 601b0c2f84..118ba69177 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -244,7 +244,7 @@ STATIC MP_DEFINE_CONST_DICT(audiobusio_pdmin_locals_dict, audiobusio_pdmin_local MP_DEFINE_CONST_OBJ_TYPE( audiobusio_pdmin_type, MP_QSTR_PDMIn, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, audiobusio_pdmin_make_new #if CIRCUITPY_AUDIOBUSIO_PDMIN , locals_dict, &audiobusio_pdmin_locals_dict diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 265515c3e1..46f5d4c748 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -177,7 +177,7 @@ STATIC const audiosample_p_t audioio_rawsample_proto = { MP_DEFINE_CONST_OBJ_TYPE( audioio_rawsample_type, MP_QSTR_RawSample, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, audioio_rawsample_make_new, locals_dict, &audioio_rawsample_locals_dict, protocol, &audioio_rawsample_proto diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index a07e74809a..98a0a564f8 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -203,7 +203,7 @@ STATIC const audiosample_p_t audioio_wavefile_proto = { MP_DEFINE_CONST_OBJ_TYPE( audioio_wavefile_type, MP_QSTR_WaveFile, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, audioio_wavefile_make_new, locals_dict, &audioio_wavefile_locals_dict, protocol, &audioio_wavefile_proto diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 3df62dbe02..72b7828c48 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -261,7 +261,7 @@ STATIC MP_DEFINE_CONST_DICT(audioio_audioout_locals_dict, audioio_audioout_local MP_DEFINE_CONST_OBJ_TYPE( audioio_audioout_type, MP_QSTR_AudioOut, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, audioio_audioout_make_new, locals_dict, &audioio_audioout_locals_dict ); diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 3698dc4b7e..03d21728dc 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -275,7 +275,7 @@ STATIC const audiosample_p_t audiomixer_mixer_proto = { MP_DEFINE_CONST_OBJ_TYPE( audiomixer_mixer_type, MP_QSTR_Mixer, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, audiomixer_mixer_make_new, locals_dict, &audiomixer_mixer_locals_dict, protocol, &audiomixer_mixer_proto diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index aaa5aedb58..e2d00ebc5b 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -156,7 +156,7 @@ STATIC MP_DEFINE_CONST_DICT(audiomixer_mixervoice_locals_dict, audiomixer_mixerv MP_DEFINE_CONST_OBJ_TYPE( audiomixer_mixervoice_type, MP_QSTR_MixerVoice, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, audiomixer_mixervoice_make_new, locals_dict, &audiomixer_mixervoice_locals_dict ); diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 1acab44a61..b27383aa98 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -286,7 +286,7 @@ STATIC const audiosample_p_t audiomp3_mp3file_proto = { MP_DEFINE_CONST_OBJ_TYPE( audiomp3_mp3file_type, MP_QSTR_MP3Decoder, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, audiomp3_mp3file_make_new, locals_dict, &audiomp3_mp3file_locals_dict, protocol, &audiomp3_mp3file_proto diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index f0837b5620..b7d2a6d8a0 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -271,7 +271,7 @@ STATIC MP_DEFINE_CONST_DICT(audiopwmio_pwmaudioout_locals_dict, audiopwmio_pwmau MP_DEFINE_CONST_OBJ_TYPE( audiopwmio_pwmaudioout_type, MP_QSTR_PWMAudioOut, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, audiopwmio_pwmaudioout_make_new, locals_dict, &audiopwmio_pwmaudioout_locals_dict ); 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..f5571f4040 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, - MP_TYPE_FLAG_NONE, - make_new, displayio_display_make_new, - locals_dict, &displayio_display_locals_dict + busdisplay_busdisplay_type, + MP_QSTR_BusDisplay, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, + 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/busio/SPI.c b/shared-bindings/busio/SPI.c index 39dff26c3b..1f02927bb1 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -492,7 +492,7 @@ STATIC MP_DEFINE_CONST_DICT(busio_spi_locals_dict, busio_spi_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( busio_spi_type, MP_QSTR_SPI, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, busio_spi_make_new, locals_dict, &busio_spi_locals_dict ); diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 3bb9d6eb78..1036534a61 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -465,7 +465,7 @@ STATIC const mp_stream_p_t uart_stream_p = { MP_DEFINE_CONST_OBJ_TYPE( busio_uart_type, MP_QSTR_UART, - MP_TYPE_FLAG_ITER_IS_ITERNEXT, + MP_TYPE_FLAG_ITER_IS_ITERNEXT | MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, busio_uart_make_new, locals_dict, &busio_uart_locals_dict, iter, mp_stream_unbuffered_iter, diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index f82b06216f..10fd752508 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -346,7 +346,7 @@ STATIC MP_DEFINE_CONST_DICT(canio_can_locals_dict, canio_can_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( canio_can_type, MP_QSTR_CAN, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, canio_can_make_new, locals_dict, &canio_can_locals_dict ); diff --git a/shared-bindings/canio/Listener.c b/shared-bindings/canio/Listener.c index ac28ea0df2..8e3de9c7e5 100644 --- a/shared-bindings/canio/Listener.c +++ b/shared-bindings/canio/Listener.c @@ -169,7 +169,7 @@ STATIC MP_DEFINE_CONST_DICT(canio_listener_locals_dict, canio_listener_locals_di MP_DEFINE_CONST_OBJ_TYPE( canio_listener_type, MP_QSTR_Listener, - MP_TYPE_FLAG_ITER_IS_ITERNEXT, + MP_TYPE_FLAG_ITER_IS_ITERNEXT | MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &canio_listener_locals_dict, iter, canio_iternext ); diff --git a/shared-bindings/canio/Match.c b/shared-bindings/canio/Match.c index 4ead5d75c2..2265ba8c46 100644 --- a/shared-bindings/canio/Match.c +++ b/shared-bindings/canio/Match.c @@ -116,7 +116,7 @@ STATIC MP_DEFINE_CONST_DICT(canio_match_locals_dict, canio_match_locals_dict_tab MP_DEFINE_CONST_OBJ_TYPE( canio_match_type, MP_QSTR_Match, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, canio_match_make_new, locals_dict, &canio_match_locals_dict ); diff --git a/shared-bindings/canio/Message.c b/shared-bindings/canio/Message.c index b53181e0dd..7f52e99346 100644 --- a/shared-bindings/canio/Message.c +++ b/shared-bindings/canio/Message.c @@ -139,7 +139,7 @@ STATIC MP_DEFINE_CONST_DICT(canio_message_locals_dict, canio_message_locals_dict MP_DEFINE_CONST_OBJ_TYPE( canio_message_type, MP_QSTR_Message, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, canio_message_make_new, locals_dict, &canio_message_locals_dict ); diff --git a/shared-bindings/canio/RemoteTransmissionRequest.c b/shared-bindings/canio/RemoteTransmissionRequest.c index 3920942bfe..22eb2c5bc7 100644 --- a/shared-bindings/canio/RemoteTransmissionRequest.c +++ b/shared-bindings/canio/RemoteTransmissionRequest.c @@ -139,7 +139,7 @@ STATIC MP_DEFINE_CONST_DICT(canio_remote_transmission_request_locals_dict, canio MP_DEFINE_CONST_OBJ_TYPE( canio_remote_transmission_request_type, MP_QSTR_RemoteTransmissionRequest, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, canio_remote_transmission_request_make_new, locals_dict, &canio_remote_transmission_request_locals_dict ); diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index fc7a9ca11d..cd85d37b9c 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -148,7 +148,7 @@ STATIC MP_DEFINE_CONST_DICT(countio_counter_locals_dict, countio_counter_locals_ MP_DEFINE_CONST_OBJ_TYPE( countio_counter_type, MP_QSTR_Counter, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, countio_counter_make_new, locals_dict, &countio_counter_locals_dict ); diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 07f6bc40a4..c73d552855 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -362,7 +362,7 @@ STATIC MP_DEFINE_CONST_DICT(digitalio_digitalinout_locals_dict, digitalio_digita MP_DEFINE_CONST_OBJ_TYPE( digitalio_digitalinout_type, MP_QSTR_DigitalInOut, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, digitalio_digitalinout_make_new, locals_dict, &digitalio_digitalinout_locals_dict ); diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index a7c93b5033..3d0479c612 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -291,7 +291,7 @@ STATIC mp_int_t bitmap_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, m MP_DEFINE_CONST_OBJ_TYPE( displayio_bitmap_type, MP_QSTR_Bitmap, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, displayio_bitmap_make_new, locals_dict, &displayio_bitmap_locals_dict, subscr, bitmap_subscr, diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 8962a58fa8..ef863162a3 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -138,7 +138,7 @@ STATIC MP_DEFINE_CONST_DICT(displayio_colorconverter_locals_dict, displayio_colo MP_DEFINE_CONST_OBJ_TYPE( displayio_colorconverter_type, MP_QSTR_ColorConverter, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, displayio_colorconverter_make_new, locals_dict, &displayio_colorconverter_locals_dict ); diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 177d62f83a..3253a6adee 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -351,7 +351,7 @@ STATIC MP_DEFINE_CONST_DICT(displayio_group_locals_dict, displayio_group_locals_ MP_DEFINE_CONST_OBJ_TYPE( displayio_group_type, MP_QSTR_Group, - MP_TYPE_FLAG_ITER_IS_GETITER, + MP_TYPE_FLAG_ITER_IS_GETITER | MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, displayio_group_make_new, locals_dict, &displayio_group_locals_dict, subscr, group_subscr, diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index a8fd2658fa..d608a32d4b 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -151,7 +151,7 @@ STATIC MP_DEFINE_CONST_DICT(displayio_ondiskbitmap_locals_dict, displayio_ondisk MP_DEFINE_CONST_OBJ_TYPE( displayio_ondiskbitmap_type, MP_QSTR_OnDiskBitmap, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, displayio_ondiskbitmap_make_new, locals_dict, &displayio_ondiskbitmap_locals_dict ); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 2c0e7ee3a1..4d68c109be 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -218,7 +218,7 @@ STATIC MP_DEFINE_CONST_DICT(displayio_palette_locals_dict, displayio_palette_loc MP_DEFINE_CONST_OBJ_TYPE( displayio_palette_type, MP_QSTR_Palette, - MP_TYPE_FLAG_ITER_IS_GETITER, + MP_TYPE_FLAG_ITER_IS_GETITER | MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, displayio_palette_make_new, locals_dict, &displayio_palette_locals_dict, subscr, palette_subscr, 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..f7a47474bc 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")); } @@ -506,7 +483,7 @@ STATIC MP_DEFINE_CONST_DICT(displayio_tilegrid_locals_dict, displayio_tilegrid_l MP_DEFINE_CONST_OBJ_TYPE( displayio_tilegrid_type, MP_QSTR_TileGrid, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, displayio_tilegrid_make_new, locals_dict, &displayio_tilegrid_locals_dict, subscr, tilegrid_subscr 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/dotclockframebuffer/DotClockFramebuffer.c b/shared-bindings/dotclockframebuffer/DotClockFramebuffer.c index 3a55166f8b..899fccf68a 100644 --- a/shared-bindings/dotclockframebuffer/DotClockFramebuffer.c +++ b/shared-bindings/dotclockframebuffer/DotClockFramebuffer.c @@ -385,7 +385,7 @@ STATIC MP_DEFINE_CONST_DICT(dotclockframebuffer_framebuffer_locals_dict, dotcloc MP_DEFINE_CONST_OBJ_TYPE( dotclockframebuffer_framebuffer_type, MP_QSTR_DotClockFramebuffer, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, dotclockframebuffer_framebuffer_make_new, locals_dict, &dotclockframebuffer_framebuffer_locals_dict, buffer, dotclockframebuffer_framebuffer_get_buffer, 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..8c488fffcc 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 + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, + 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/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index 53d92df995..d68e0ccc09 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -109,6 +109,6 @@ STATIC MP_DEFINE_CONST_DICT(fontio_builtinfont_locals_dict, fontio_builtinfont_l MP_DEFINE_CONST_OBJ_TYPE( fontio_builtinfont_type, MP_QSTR_BuiltinFont, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &fontio_builtinfont_locals_dict ); 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/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index dfbc41f6c8..370d2eacae 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -366,7 +366,7 @@ STATIC MP_DEFINE_CONST_DICT(framebufferio_framebufferdisplay_locals_dict, frameb MP_DEFINE_CONST_OBJ_TYPE( framebufferio_framebufferdisplay_type, MP_QSTR_FramebufferDisplay, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, framebufferio_framebufferdisplay_make_new, locals_dict, &framebufferio_framebufferdisplay_locals_dict ); diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index 569361a566..1cb46887a0 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -220,7 +220,7 @@ STATIC MP_DEFINE_CONST_DICT(frequencyio_frequencyin_locals_dict, frequencyio_fre MP_DEFINE_CONST_OBJ_TYPE( frequencyio_frequencyin_type, MP_QSTR_frequencyin, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, frequencyio_frequencyin_make_new, locals_dict, &frequencyio_frequencyin_locals_dict ); diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index a7a7b62dae..1fb75d6245 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -323,7 +323,7 @@ STATIC MP_DEFINE_CONST_DICT(gifio_ondiskgif_locals_dict, gifio_ondiskgif_locals_ MP_DEFINE_CONST_OBJ_TYPE( gifio_ondiskgif_type, MP_QSTR_OnDiskGif, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, gifio_ondiskgif_make_new, locals_dict, &gifio_ondiskgif_locals_dict ); diff --git a/shared-bindings/gnss/GNSS.c b/shared-bindings/gnss/GNSS.c index a3b2f464d9..07962a682e 100644 --- a/shared-bindings/gnss/GNSS.c +++ b/shared-bindings/gnss/GNSS.c @@ -172,7 +172,7 @@ STATIC MP_DEFINE_CONST_DICT(gnss_locals_dict, gnss_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( gnss_type, MP_QSTR_GNSS, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, gnss_make_new, locals_dict, &gnss_locals_dict ); diff --git a/shared-bindings/hashlib/Hash.c b/shared-bindings/hashlib/Hash.c index 6ab23e1613..3d1e094794 100644 --- a/shared-bindings/hashlib/Hash.c +++ b/shared-bindings/hashlib/Hash.c @@ -92,6 +92,6 @@ STATIC MP_DEFINE_CONST_DICT(hashlib_hash_locals_dict, hashlib_hash_locals_dict_t MP_DEFINE_CONST_OBJ_TYPE( hashlib_hash_type, MP_QSTR_Hash, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &hashlib_hash_locals_dict ); 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/ipaddress/IPv4Address.c b/shared-bindings/ipaddress/IPv4Address.c index 13cc165c4d..95a683e94d 100644 --- a/shared-bindings/ipaddress/IPv4Address.c +++ b/shared-bindings/ipaddress/IPv4Address.c @@ -178,7 +178,7 @@ STATIC MP_DEFINE_CONST_DICT(ipaddress_ipv4address_locals_dict, ipaddress_ipv4add MP_DEFINE_CONST_OBJ_TYPE( ipaddress_ipv4address_type, MP_QSTR_Address, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, ipaddress_ipv4address_make_new, locals_dict, &ipaddress_ipv4address_locals_dict, print, ipaddress_ipv4address_print, diff --git a/shared-bindings/is31fl3741/FrameBuffer.c b/shared-bindings/is31fl3741/FrameBuffer.c index a7725ff65e..5804707228 100644 --- a/shared-bindings/is31fl3741/FrameBuffer.c +++ b/shared-bindings/is31fl3741/FrameBuffer.c @@ -295,7 +295,7 @@ STATIC mp_int_t is31fl3741_FrameBuffer_get_buffer(mp_obj_t self_in, mp_buffer_in MP_DEFINE_CONST_OBJ_TYPE( is31fl3741_FrameBuffer_type, MP_QSTR_is31fl3741, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &is31fl3741_FrameBuffer_locals_dict, make_new, is31fl3741_FrameBuffer_make_new, buffer, is31fl3741_FrameBuffer_get_buffer, diff --git a/shared-bindings/keypad/Event.c b/shared-bindings/keypad/Event.c index ea6dd0018b..57ce660978 100644 --- a/shared-bindings/keypad/Event.c +++ b/shared-bindings/keypad/Event.c @@ -183,7 +183,7 @@ STATIC MP_DEFINE_CONST_DICT(keypad_event_locals_dict, keypad_event_locals_dict_t MP_DEFINE_CONST_OBJ_TYPE( keypad_event_type, MP_QSTR_Event, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, keypad_event_make_new, print, keypad_event_print, locals_dict, &keypad_event_locals_dict, diff --git a/shared-bindings/keypad/EventQueue.c b/shared-bindings/keypad/EventQueue.c index 44450ec21c..1acb1ea500 100644 --- a/shared-bindings/keypad/EventQueue.c +++ b/shared-bindings/keypad/EventQueue.c @@ -168,7 +168,7 @@ STATIC const mp_stream_p_t eventqueue_p = { MP_DEFINE_CONST_OBJ_TYPE( keypad_eventqueue_type, MP_QSTR_EventQueue, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, unary_op, keypad_eventqueue_unary_op, #if MICROPY_PY_SELECT protocol, &eventqueue_p, diff --git a/shared-bindings/mdns/RemoteService.c b/shared-bindings/mdns/RemoteService.c index defd055722..6bf96a2a76 100644 --- a/shared-bindings/mdns/RemoteService.c +++ b/shared-bindings/mdns/RemoteService.c @@ -138,6 +138,6 @@ STATIC MP_DEFINE_CONST_DICT(mdns_remoteservice_locals_dict, mdns_remoteservice_l MP_DEFINE_CONST_OBJ_TYPE( mdns_remoteservice_type, MP_QSTR_RemoteService, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &mdns_remoteservice_locals_dict ); diff --git a/shared-bindings/mdns/Server.c b/shared-bindings/mdns/Server.c index d9afe891e6..a8d4325036 100644 --- a/shared-bindings/mdns/Server.c +++ b/shared-bindings/mdns/Server.c @@ -216,7 +216,7 @@ STATIC MP_DEFINE_CONST_DICT(mdns_server_locals_dict, mdns_server_locals_dict_tab MP_DEFINE_CONST_OBJ_TYPE( mdns_server_type, MP_QSTR_Server, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, mdns_server_make_new, locals_dict, &mdns_server_locals_dict ); diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c index fe82a91553..449f8d825c 100644 --- a/shared-bindings/memorymonitor/AllocationSize.c +++ b/shared-bindings/memorymonitor/AllocationSize.c @@ -167,7 +167,7 @@ STATIC MP_DEFINE_CONST_DICT(memorymonitor_allocationsize_locals_dict, memorymoni MP_DEFINE_CONST_OBJ_TYPE( memorymonitor_allocationsize_type, MP_QSTR_AllocationSize, - MP_TYPE_FLAG_ITER_IS_GETITER, + MP_TYPE_FLAG_ITER_IS_GETITER | MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, memorymonitor_allocationsize_make_new, subscr, memorymonitor_allocationsize_subscr, unary_op, memorymonitor_allocationsize_unary_op, diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index 80064f75a0..56acca256b 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -173,6 +173,6 @@ STATIC MP_DEFINE_CONST_DICT(mcu_processor_locals_dict, mcu_processor_locals_dict MP_DEFINE_CONST_OBJ_TYPE( mcu_processor_type, MP_QSTR_Processor, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &mcu_processor_locals_dict ); diff --git a/shared-bindings/msgpack/ExtType.c b/shared-bindings/msgpack/ExtType.c index 36b342a594..ad8044490a 100644 --- a/shared-bindings/msgpack/ExtType.c +++ b/shared-bindings/msgpack/ExtType.c @@ -111,7 +111,7 @@ STATIC MP_DEFINE_CONST_DICT(mod_msgpack_exttype_locals_dict, mod_msgpack_exttype MP_DEFINE_CONST_OBJ_TYPE( mod_msgpack_exttype_type, MP_QSTR_ExtType, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, mod_msgpack_exttype_make_new, locals_dict, &mod_msgpack_exttype_locals_dict ); 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-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index f26edfea2c..cfb24d0dd4 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -292,7 +292,7 @@ STATIC MP_DEFINE_CONST_DICT(pulseio_pulsein_locals_dict, pulseio_pulsein_locals_ MP_DEFINE_CONST_OBJ_TYPE( pulseio_pulsein_type, MP_QSTR_PulseIn, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, pulseio_pulsein_make_new, locals_dict, &pulseio_pulsein_locals_dict, subscr, pulsein_subscr, diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index 5ec03d1c28..1408696c11 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -301,7 +301,7 @@ STATIC MP_DEFINE_CONST_DICT(pwmio_pwmout_locals_dict, pwmio_pwmout_locals_dict_t MP_DEFINE_CONST_OBJ_TYPE( pwmio_pwmout_type, MP_QSTR_PWMOut, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, pwmio_pwmout_make_new, locals_dict, &pwmio_pwmout_locals_dict ); diff --git a/shared-bindings/qrio/QRDecoder.c b/shared-bindings/qrio/QRDecoder.c index a2c8ea7ee8..aee23fd41e 100644 --- a/shared-bindings/qrio/QRDecoder.c +++ b/shared-bindings/qrio/QRDecoder.c @@ -142,7 +142,7 @@ STATIC MP_DEFINE_CONST_DICT(qrio_qrdecoder_locals, qrio_qrdecoder_locals_table); MP_DEFINE_CONST_OBJ_TYPE( qrio_qrdecoder_type_obj, MP_QSTR_QRDecoder, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, qrio_qrdecoder_make_new, locals_dict, &qrio_qrdecoder_locals ); diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 867d127207..fb645d3050 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -448,7 +448,7 @@ STATIC mp_int_t rgbmatrix_rgbmatrix_get_buffer(mp_obj_t self_in, mp_buffer_info_ MP_DEFINE_CONST_OBJ_TYPE( rgbmatrix_RGBMatrix_type, MP_QSTR_RGBMatrix, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &rgbmatrix_rgbmatrix_locals_dict, make_new, rgbmatrix_rgbmatrix_make_new, buffer, rgbmatrix_rgbmatrix_get_buffer, diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index 6a4e8098bc..51a43d97e9 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -183,7 +183,7 @@ STATIC MP_DEFINE_CONST_DICT(rotaryio_incrementalencoder_locals_dict, rotaryio_in MP_DEFINE_CONST_OBJ_TYPE( rotaryio_incrementalencoder_type, MP_QSTR_IncrementalEncoder, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, rotaryio_incrementalencoder_make_new, locals_dict, &rotaryio_incrementalencoder_locals_dict ); diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index 114055833d..6384f2ea70 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -128,7 +128,7 @@ STATIC MP_DEFINE_CONST_DICT(rtc_rtc_locals_dict, rtc_rtc_locals_dict_table); MP_DEFINE_CONST_OBJ_TYPE( rtc_rtc_type, MP_QSTR_RTC, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, rtc_rtc_make_new, locals_dict, &rtc_rtc_locals_dict ); diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index 7c0d391957..d06d76825c 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -270,7 +270,7 @@ STATIC MP_DEFINE_CONST_DICT(sdioio_sdcard_locals_dict, sdioio_sdcard_locals_dict MP_DEFINE_CONST_OBJ_TYPE( sdioio_SDCard_type, MP_QSTR_SDCard, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, sdioio_sdcard_make_new, locals_dict, &sdioio_sdcard_locals_dict ); diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 4b1c0c7403..0ed98d7a7c 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -201,7 +201,7 @@ STATIC MP_DEFINE_CONST_DICT(ssl_sslcontext_locals_dict, ssl_sslcontext_locals_di MP_DEFINE_CONST_OBJ_TYPE( ssl_sslcontext_type, MP_QSTR_SSLContext, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, ssl_sslcontext_make_new, locals_dict, &ssl_sslcontext_locals_dict ); diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 672b59f076..8367f74420 100644 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -254,6 +254,6 @@ STATIC MP_DEFINE_CONST_DICT(supervisor_runtime_locals_dict, supervisor_runtime_l MP_DEFINE_CONST_OBJ_TYPE( supervisor_runtime_type, MP_QSTR_Runtime, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &supervisor_runtime_locals_dict ); diff --git a/shared-bindings/supervisor/StatusBar.c b/shared-bindings/supervisor/StatusBar.c index 4438c5fa4d..e77e4a9f71 100644 --- a/shared-bindings/supervisor/StatusBar.c +++ b/shared-bindings/supervisor/StatusBar.c @@ -121,6 +121,6 @@ STATIC MP_DEFINE_CONST_DICT(supervisor_status_bar_locals_dict, supervisor_status MP_DEFINE_CONST_OBJ_TYPE( supervisor_status_bar_type, MP_QSTR_Status_Bar, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &supervisor_status_bar_locals_dict ); diff --git a/shared-bindings/support_matrix.rst b/shared-bindings/support_matrix.rst index e3428ac5bc..4318cde5ac 100644 --- a/shared-bindings/support_matrix.rst +++ b/shared-bindings/support_matrix.rst @@ -17,6 +17,10 @@ You can also type a regular expression as a filter.

(all)

+.. raw:: latex + + \begin{landscape} + .. rst-class:: support-matrix-table .. list-table:: :header-rows: 1 @@ -26,8 +30,10 @@ You can also type a regular expression as a filter. - Modules Available {% for key, value in support_matrix|dictsort %} - {{ '.. _' ~ key|replace(" ", "-") ~ ':' }} * - {{ key }} + + {{ '.. _' ~ key|replace(" ", "-") ~ ':' }} + - {{ ':py:mod:`' ~ value.modules|join("`, :py:mod:`") ~ '`' }} {% for module in value.frozen_libraries %}\ @@ -39,3 +45,7 @@ You can also type a regular expression as a filter. {% endfor %} {% endfor %} + +.. raw:: latex + + \end{landscape} diff --git a/shared-bindings/synthio/LFO.c b/shared-bindings/synthio/LFO.c index 6d56da910a..6d0f24ab47 100644 --- a/shared-bindings/synthio/LFO.c +++ b/shared-bindings/synthio/LFO.c @@ -294,7 +294,7 @@ STATIC const synthio_block_proto_t lfo_proto = { MP_DEFINE_CONST_OBJ_TYPE( synthio_lfo_type, MP_QSTR_LFO, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, synthio_lfo_make_new, locals_dict, &synthio_lfo_locals_dict, print, lfo_print, diff --git a/shared-bindings/synthio/Math.c b/shared-bindings/synthio/Math.c index 44073e9a10..d111263728 100644 --- a/shared-bindings/synthio/Math.c +++ b/shared-bindings/synthio/Math.c @@ -294,7 +294,7 @@ STATIC const synthio_block_proto_t math_proto = { MP_DEFINE_CONST_OBJ_TYPE( synthio_math_type, MP_QSTR_Math, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, synthio_math_make_new, locals_dict, &synthio_math_locals_dict, print, math_print, diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index 253ae62b85..f9c5aa4b00 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -188,7 +188,7 @@ STATIC const audiosample_p_t synthio_miditrack_proto = { MP_DEFINE_CONST_OBJ_TYPE( synthio_miditrack_type, MP_QSTR_MidiTrack, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, synthio_miditrack_make_new, locals_dict, &synthio_miditrack_locals_dict, protocol, &synthio_miditrack_proto diff --git a/shared-bindings/synthio/Note.c b/shared-bindings/synthio/Note.c index a1aee54c54..acb12ae0db 100644 --- a/shared-bindings/synthio/Note.c +++ b/shared-bindings/synthio/Note.c @@ -320,7 +320,7 @@ STATIC MP_DEFINE_CONST_DICT(synthio_note_locals_dict, synthio_note_locals_dict_t MP_DEFINE_CONST_OBJ_TYPE( synthio_note_type, MP_QSTR_Note, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, synthio_note_make_new, locals_dict, &synthio_note_locals_dict, print, note_print diff --git a/shared-bindings/synthio/Synthesizer.c b/shared-bindings/synthio/Synthesizer.c index ef7eb1f1bc..59c5966c01 100644 --- a/shared-bindings/synthio/Synthesizer.c +++ b/shared-bindings/synthio/Synthesizer.c @@ -453,7 +453,7 @@ STATIC const audiosample_p_t synthio_synthesizer_proto = { MP_DEFINE_CONST_OBJ_TYPE( synthio_synthesizer_type, MP_QSTR_Synthesizer, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, synthio_synthesizer_make_new, locals_dict, &synthio_synthesizer_locals_dict, protocol, &synthio_synthesizer_proto diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index a5a2593630..982006b532 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -184,7 +184,7 @@ STATIC MP_DEFINE_CONST_DICT(touchio_touchin_locals_dict, touchio_touchin_locals_ MP_DEFINE_CONST_OBJ_TYPE( touchio_touchin_type, MP_QSTR_TouchIn, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, touchio_touchin_make_new, locals_dict, &touchio_touchin_locals_dict ); diff --git a/shared-bindings/usb/core/Device.c b/shared-bindings/usb/core/Device.c index 120bbefd45..4da92aa2f1 100644 --- a/shared-bindings/usb/core/Device.c +++ b/shared-bindings/usb/core/Device.c @@ -334,6 +334,6 @@ STATIC MP_DEFINE_CONST_DICT(usb_core_device_locals_dict, usb_core_device_locals_ MP_DEFINE_CONST_OBJ_TYPE( usb_core_device_type, MP_QSTR_Device, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &usb_core_device_locals_dict ); diff --git a/shared-bindings/usb_cdc/Serial.c b/shared-bindings/usb_cdc/Serial.c index 52bc3d7295..14c921dd3e 100644 --- a/shared-bindings/usb_cdc/Serial.c +++ b/shared-bindings/usb_cdc/Serial.c @@ -280,7 +280,7 @@ STATIC const mp_stream_p_t usb_cdc_serial_stream_p = { MP_DEFINE_CONST_OBJ_TYPE( usb_cdc_serial_type, MP_QSTR_Serial, - MP_TYPE_FLAG_ITER_IS_ITERNEXT, + MP_TYPE_FLAG_ITER_IS_ITERNEXT | MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &usb_cdc_serial_locals_dict, iter, mp_stream_unbuffered_iter, protocol, &usb_cdc_serial_stream_p diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index efd0d15a6e..ab0e600046 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -266,7 +266,7 @@ STATIC MP_DEFINE_CONST_DICT(usb_hid_device_locals_dict, usb_hid_device_locals_di MP_DEFINE_CONST_OBJ_TYPE( usb_hid_device_type, MP_QSTR_Device, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, usb_hid_device_make_new, locals_dict, &usb_hid_device_locals_dict ); diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 4dc3058e74..4fa992d706 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -135,7 +135,7 @@ STATIC MP_DEFINE_CONST_DICT(vectorio_circle_locals_dict, vectorio_circle_locals_ MP_DEFINE_CONST_OBJ_TYPE( vectorio_circle_type, MP_QSTR_Circle, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, vectorio_circle_make_new, locals_dict, &vectorio_circle_locals_dict, protocol, &circle_draw_protocol diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index 251e113d9f..d9c923c0cd 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -144,7 +144,7 @@ STATIC MP_DEFINE_CONST_DICT(vectorio_polygon_locals_dict, vectorio_polygon_local MP_DEFINE_CONST_OBJ_TYPE( vectorio_polygon_type, MP_QSTR_Polygon, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, vectorio_polygon_make_new, locals_dict, &vectorio_polygon_locals_dict, protocol, &polygon_draw_protocol diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index c2bce53f09..95960c51f2 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -244,6 +244,6 @@ STATIC MP_DEFINE_CONST_DICT(vectorio_vector_shape_locals_dict, vectorio_vector_s MP_DEFINE_CONST_OBJ_TYPE( vectorio_vector_shape_type, MP_QSTR_VectorShape, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &vectorio_vector_shape_locals_dict ); diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c index fca860fe92..ccbd3f6de1 100644 --- a/shared-bindings/watchdog/WatchDogTimer.c +++ b/shared-bindings/watchdog/WatchDogTimer.c @@ -151,6 +151,6 @@ STATIC MP_DEFINE_CONST_DICT(watchdog_watchdogtimer_locals_dict, watchdog_watchdo MP_DEFINE_CONST_OBJ_TYPE( watchdog_watchdogtimer_type, MP_QSTR_WatchDogTimer, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &watchdog_watchdogtimer_locals_dict ); diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index bde6caa59f..e2a6e3db4e 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -154,7 +154,7 @@ STATIC MP_DEFINE_CONST_DICT(wifi_monitor_locals_dict, wifi_monitor_locals_dict_t MP_DEFINE_CONST_OBJ_TYPE( wifi_monitor_type, MP_QSTR_Monitor, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, make_new, wifi_monitor_make_new, locals_dict, &wifi_monitor_locals_dict ); diff --git a/shared-bindings/wifi/Network.c b/shared-bindings/wifi/Network.c index d262b392eb..4bb860404b 100644 --- a/shared-bindings/wifi/Network.c +++ b/shared-bindings/wifi/Network.c @@ -122,6 +122,6 @@ STATIC MP_DEFINE_CONST_DICT(wifi_network_locals_dict, wifi_network_locals_dict_t MP_DEFINE_CONST_OBJ_TYPE( wifi_network_type, MP_QSTR_Network, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &wifi_network_locals_dict ); diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index dd56408561..065ee56a73 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -780,6 +780,6 @@ STATIC MP_DEFINE_CONST_DICT(wifi_radio_locals_dict, wifi_radio_locals_dict_table MP_DEFINE_CONST_OBJ_TYPE( wifi_radio_type, MP_QSTR_Radio, - MP_TYPE_FLAG_NONE, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, locals_dict, &wifi_radio_locals_dict ); 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; diff --git a/tests/unix/subclass_native.py b/tests/unix/subclass_native.py new file mode 100644 index 0000000000..8b3a9dbb73 --- /dev/null +++ b/tests/unix/subclass_native.py @@ -0,0 +1,49 @@ +try: + NativeBaseClass +except NameError: + print("SKIP") + raise SystemExit + +# This tests two things that CircuitPython uses: +# 1. Native class's `make_new` get kwargs. +# 2. Native class's properties get used instead of creating a new attribute on +# the subclass instance. + +n = NativeBaseClass(test="direct kwarg") +print(".test:", n.test) + +n.test = "test set directly" +print(".test:", n.test) + + +class A(NativeBaseClass): + pass + + +a = A(test="subclass kwarg") +print(".test:", a.test) + +a.test = "test set indirectly" +print(".test:", a.test) + +a._new_attribute = True +print("._new_attribute", a._new_attribute) + +a.print_subclass_attr("_new_attribute") + + +class B(NativeBaseClass): + def __init__(self, suffix): + super().__init__(test="super init " + suffix) + + +b = B("suffix") +print(".test:", b.test) + +b.test = "test set indirectly through b" +print(".test:", b.test) + +b._new_attribute = True +print("._new_attribute", b._new_attribute) + +b.print_subclass_attr("_new_attribute") diff --git a/tests/unix/subclass_native.py.exp b/tests/unix/subclass_native.py.exp new file mode 100644 index 0000000000..7f872c4008 --- /dev/null +++ b/tests/unix/subclass_native.py.exp @@ -0,0 +1,13 @@ +.test: direct kwarg +native base class .test set to: 'test set directly' +.test: test set directly +.test: subclass kwarg +native base class .test set to: 'test set indirectly' +.test: test set indirectly +._new_attribute True +native base class ._new_attribute set to: True +.test: super init suffix +native base class .test set to: 'test set indirectly through b' +.test: test set indirectly through b +._new_attribute True +native base class ._new_attribute set to: True