summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/_stage/__init__.c24
1 files changed, 11 insertions, 13 deletions
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;
}