summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-01-14 17:26:36 -0800
committerScott Shawcroft <scott@tannewt.org>2019-01-14 17:29:19 -0800
commit747f2cfe267628fda8487c533ce7a5ab10a9388f (patch)
treef8d8d56e7682e0627801897780556dc340b5411e /shared-module
parent72d993d60c5e5238942491df00776ca31f9758a1 (diff)
Add subclass support to displayio.
Also, swap make_news to accept a kwarg map and refine param checking. Fixes #1237
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/displayio/Group.c7
-rw-r--r--shared-module/displayio/__init__.c17
2 files changed, 21 insertions, 3 deletions
diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c
index 93ac35964..b9923128a 100644
--- a/shared-module/displayio/Group.c
+++ b/shared-module/displayio/Group.c
@@ -38,6 +38,13 @@ void common_hal_displayio_group_append(displayio_group_t* self, mp_obj_t layer)
if (self->size == self->max_size) {
mp_raise_RuntimeError(translate("Group full"));
}
+ mp_obj_t native_layer = mp_instance_cast_to_native_base(layer, &displayio_group_type);
+ if (native_layer == MP_OBJ_NULL) {
+ native_layer = mp_instance_cast_to_native_base(layer, &displayio_sprite_type);
+ }
+ if (native_layer == MP_OBJ_NULL) {
+ mp_raise_ValueError(translate("Layer must be a Group or Sprite subclass."));
+ }
self->children[self->size] = layer;
self->size++;
self->needs_refresh = true;
diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c
index df9c2963a..f1a00db9f 100644
--- a/shared-module/displayio/__init__.c
+++ b/shared-module/displayio/__init__.c
@@ -39,6 +39,8 @@ void displayio_refresh_display(void) {
return;
}
if (refresh_queued(display)) {
+ PORT->Group[1].DIRSET.reg = 1 << 22;
+
// We compute the pixels
uint16_t x0 = 0;
uint16_t y0 = 0;
@@ -53,10 +55,19 @@ void displayio_refresh_display(void) {
for (uint16_t x = x0; x < x1; ++x) {
uint16_t* pixel = &(((uint16_t*)buffer)[index]);
*pixel = 0;
- if (display->current_group != NULL) {
- displayio_group_get_pixel(display->current_group, x, y, pixel);
- }
+ PORT->Group[1].OUTTGL.reg = 1 << 22;
+
+ //if (index == 0) {
+ if (display->current_group != NULL) {
+ displayio_group_get_pixel(display->current_group, x, y, pixel);
+ }
+ // } else {
+ // *pixel = (((uint16_t*)buffer)[0]);
+ // }
+
+
+ PORT->Group[1].OUTTGL.reg = 1 << 22;
index += 1;
// The buffer is full, send it.