summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------frozen/circuitpython-stage0
-rw-r--r--shared-bindings/_stage/__init__.c24
-rw-r--r--shared-module/_stage/__init__.c14
-rw-r--r--shared-module/_stage/__init__.h6
-rw-r--r--supervisor/supervisor.mk2
5 files changed, 19 insertions, 27 deletions
diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage
-Subproject a7b3295ff573ce03cd7111a6cf7bf9cfe1e4f65
+Subproject 069fad8357623f5ea2ff3c865a5b8ed54608afd
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 <stdint.h>
#include <stdbool.h>
#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 $@"