From c3136f4f32df28cc29596fc9ba76dcc0bfd533f0 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Sat, 6 Apr 2019 14:02:18 +0200 Subject: Enable displayio for uGame10 board Also, make the _stage library work with the fourwire bus, to re-use the display. --- frozen/circuitpython-stage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'frozen/circuitpython-stage') diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index d8a9d8c1d..347b02095 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit d8a9d8c1d73041e4cc5669c5441f531ecba517fc +Subproject commit 347b02095449075d3e9bb1b7bac6d3a8a2151df2 -- cgit v1.2.3 From dabbded622878f8c8dbea17310b4b63f71a387d3 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Fri, 12 Apr 2019 11:19:19 +0200 Subject: Got back to using Display object in the Stage library --- frozen/circuitpython-stage | 2 +- ports/atmel-samd/boards/ugame10/board.c | 2 +- ports/atmel-samd/boards/ugame10/mpconfigboard.mk | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'frozen/circuitpython-stage') diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index 347b02095..a7b3295ff 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit 347b02095449075d3e9bb1b7bac6d3a8a2151df2 +Subproject commit a7b3295ff573ce03cd7111a6cf7bf9cfe1e4f657 diff --git a/ports/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c index cd67dabe3..a4f6bb175 100644 --- a/ports/atmel-samd/boards/ugame10/board.c +++ b/ports/atmel-samd/boards/ugame10/board.c @@ -52,7 +52,7 @@ uint8_t display_init_sequence[] = { 0xc4, 2, 0x8a, 0xee, 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V 0x2a, 0, // _INVOFF - 0x36, 1, 0xa8, // _MADCTL bottom to top refresh + 0x36, 1, 0xa0, // _MADCTL bottom to top refresh // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, // fix on VTL 0x3a, 1, 0x05, // COLMOD - 16bit color diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk index 4a0330d57..cafd84b21 100644 --- a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk @@ -29,4 +29,6 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_PIXELBUF = 0 -FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage +FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/ugame10 + +CIRCUITPY_DISPLAY_FONT = "../../tools/Tecate-bitmap-fonts/bitmap/phallus/lemon.bdf" -- cgit v1.2.3 From d39e7e7dd51aa55e92cfda3e05ea80ae1abe409d Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Fri, 12 Apr 2019 11:56:23 +0200 Subject: Use displayio.Display directly --- frozen/circuitpython-stage | 2 +- shared-bindings/_stage/__init__.c | 24 +++++++++++------------- shared-module/_stage/__init__.c | 14 ++++---------- shared-module/_stage/__init__.h | 6 +++--- supervisor/supervisor.mk | 2 +- 5 files changed, 20 insertions(+), 28 deletions(-) (limited to 'frozen/circuitpython-stage') diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index a7b3295ff..069fad835 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit a7b3295ff573ce03cd7111a6cf7bf9cfe1e4f657 +Subproject commit 069fad8357623f5ea2ff3c865a5b8ed54608afd7 diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 95cbda846..466098061 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/FourWire.h" +#include "shared-bindings/displayio/Display.h" #include "shared-module/_stage/__init__.h" #include "Layer.h" #include "Text.h" @@ -50,7 +50,7 @@ //| Layer //| Text //| -//| .. function:: render(x0, y0, x1, y1, layers, buffer, spi) +//| .. function:: render(x0, y0, x1, y1, layers, buffer, display) //| //| Render and send to the display a fragment of the screen. //| @@ -60,11 +60,8 @@ //| :param int y1: Bottom edge of the fragment. //| :param list layers: A list of the :py:class:`~_stage.Layer` objects. //| :param bytearray buffer: A buffer to use for rendering. -//| :param ~busio.SPI spi: The SPI bus to use. +//| :param ~displayio.Display display: The display to use. //| -//| Note that this function only sends the raw pixel data. Setting up -//| the display for receiving it and handling the chip-select and -//| data-command pins has to be done outside of it. //| There are also no sanity checks, outside of the basic overflow //| checking. The caller is responsible for making the passed parameters //| valid. @@ -86,18 +83,19 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { uint16_t *buffer = bufinfo.buf; size_t buffer_size = bufinfo.len / 2; // 16-bit indexing - displayio_fourwire_obj_t *bus = MP_OBJ_TO_PTR(args[6]); + if (!MP_OBJ_IS_TYPE(args[6], &displayio_display_type)) { + mp_raise_TypeError(translate("expected displayio.Display")); + } + displayio_display_obj_t *display = MP_OBJ_TO_PTR(args[6]); - while (!common_hal_displayio_fourwire_begin_transaction(bus)) { + while (!displayio_display_begin_transaction(display)) { #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP ; #endif } - if (!render_stage(x0, y0, x1, y1, layers, layers_size, - buffer, buffer_size, bus->bus)) { - mp_raise_OSError(MP_EIO); - } - common_hal_displayio_fourwire_end_transaction(bus); + displayio_display_set_region_to_update(display, x0, y0, x1, y1); + render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size, display); + displayio_display_end_transaction(display); return mp_const_none; } diff --git a/shared-module/_stage/__init__.c b/shared-module/_stage/__init__.c index 86f5ee795..1af279e92 100644 --- a/shared-module/_stage/__init__.c +++ b/shared-module/_stage/__init__.c @@ -31,10 +31,10 @@ #include "shared-bindings/_stage/Text.h" -bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, +void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, - busio_spi_obj_t *spi) { + displayio_display_obj_t *display) { size_t index = 0; for (uint16_t y = y0; y < y1; ++y) { @@ -55,19 +55,13 @@ bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, index += 1; // The buffer is full, send it. if (index >= buffer_size) { - if (!common_hal_busio_spi_write(spi, - ((uint8_t*)buffer), buffer_size * 2)) { - return false; - } + display->send(display->bus, false, ((uint8_t*)buffer), buffer_size * 2); index = 0; } } } // Send the remaining data. if (index) { - if (!common_hal_busio_spi_write(spi, ((uint8_t*)buffer), index * 2)) { - return false; - } + display->send(display->bus, false, ((uint8_t*)buffer), index * 2); } - return true; } diff --git a/shared-module/_stage/__init__.h b/shared-module/_stage/__init__.h index d56a26940..d263302b4 100644 --- a/shared-module/_stage/__init__.h +++ b/shared-module/_stage/__init__.h @@ -27,16 +27,16 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE__STAGE_H #define MICROPY_INCLUDED_SHARED_MODULE__STAGE_H -#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/Display.h" #include #include #include "py/obj.h" #define TRANSPARENT (0x1ff8) -bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, +void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, - busio_spi_obj_t *spi); + displayio_display_obj_t *display); #endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 95cffc098..f94f19353 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -101,7 +101,7 @@ autogen_usb_descriptor.intermediate: ../../tools/gen_usb_descriptor.py Makefile --output_c_file $(BUILD)/autogen_usb_descriptor.c\ --output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h -CIRCUITPY_DISPLAY_FONT = "../../tools/Tecate-bitmap-fonts/bitmap/terminus-font-4.39/ter-u12n.bdf" +CIRCUITPY_DISPLAY_FONT ?= "../../tools/Tecate-bitmap-fonts/bitmap/terminus-font-4.39/ter-u12n.bdf" $(BUILD)/autogen_display_resources.c: ../../tools/gen_display_resources.py $(HEADER_BUILD)/qstrdefs.generated.h Makefile | $(HEADER_BUILD) $(STEPECHO) "GEN $@" -- cgit v1.2.3