diff --git a/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk b/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk index 4063a6395226c..1f47795002df9 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk +++ b/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk @@ -11,5 +11,8 @@ CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1 CIRCUITPY_ESP_USB_SERIAL_JTAG = 1 +# Not enough flash space. +CIRCUITPY_CODEOP = 0 + # Not enough pins. CIRCUITPY_PARALLELDISPLAYBUS = 0 diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index 041600bff4e49..ff29609fc4e91 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -82,6 +82,7 @@ vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl = { .draw_finish_refresh = (draw_finish_refresh_fun)vectorio_vector_shape_finish_refresh, .draw_get_refresh_areas = (draw_get_refresh_areas_fun)vectorio_vector_shape_get_refresh_areas, .draw_set_dirty = (draw_set_dirty_fun)common_hal_vectorio_vector_shape_set_dirty, + .draw_set_in_group = (draw_set_in_group_fun)vectorio_vector_shape_set_in_group, }; // Stub checker does not approve of these shared properties. diff --git a/shared-bindings/vectorio/VectorShape.h b/shared-bindings/vectorio/VectorShape.h index 9e06a0c146e8d..7924eb07ba287 100644 --- a/shared-bindings/vectorio/VectorShape.h +++ b/shared-bindings/vectorio/VectorShape.h @@ -43,6 +43,7 @@ mp_obj_t common_hal_vectorio_vector_shape_get_pixel_shader(vectorio_vector_shape void common_hal_vectorio_vector_shape_set_pixel_shader(vectorio_vector_shape_t *self, mp_obj_t pixel_shader); void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displayio_buffer_transform_t *group_transform); +bool vectorio_vector_shape_set_in_group(vectorio_vector_shape_t *self, bool in_group); // Composable property definition for shapes that use VectorShape extern vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl; diff --git a/shared-bindings/vectorio/__init__.h b/shared-bindings/vectorio/__init__.h index c982f63815b4d..c5dcc02656738 100644 --- a/shared-bindings/vectorio/__init__.h +++ b/shared-bindings/vectorio/__init__.h @@ -23,6 +23,7 @@ typedef bool (*draw_get_dirty_area_fun)(mp_obj_t draw_protocol_self, displayio_a typedef void (*draw_update_transform_fun)(mp_obj_t draw_protocol_self, displayio_buffer_transform_t *group_transform); typedef void (*draw_finish_refresh_fun)(mp_obj_t draw_protocol_self); typedef void (*draw_set_dirty_fun)(mp_obj_t draw_protocol_self); +typedef bool (*draw_set_in_group_fun)(mp_obj_t draw_protocol_self, bool in_group); typedef displayio_area_t *(*draw_get_refresh_areas_fun)(mp_obj_t draw_protocol_self, displayio_area_t *tail); typedef struct _vectorio_draw_protocol_impl_t { @@ -32,6 +33,7 @@ typedef struct _vectorio_draw_protocol_impl_t { draw_finish_refresh_fun draw_finish_refresh; draw_get_refresh_areas_fun draw_get_refresh_areas; draw_set_dirty_fun draw_set_dirty; + draw_set_in_group_fun draw_set_in_group; } vectorio_draw_protocol_impl_t; // Draw protocol diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index e2a1a527062b8..a2bf685d0f7c4 100644 --- a/shared-module/displayio/Group.c +++ b/shared-module/displayio/Group.c @@ -251,7 +251,11 @@ static void _add_layer(displayio_group_t *self, mp_obj_t layer) { #if CIRCUITPY_VECTORIO const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, layer); if (draw_protocol != NULL) { - draw_protocol->draw_protocol_impl->draw_update_transform(draw_protocol->draw_get_protocol_self(layer), &self->absolute_transform); + mp_obj_t protocol_self = draw_protocol->draw_get_protocol_self(layer); + if (draw_protocol->draw_protocol_impl->draw_set_in_group(protocol_self, true)) { + mp_raise_ValueError(MP_ERROR_TEXT("Layer already in a group")); + } + draw_protocol->draw_protocol_impl->draw_update_transform(protocol_self, &self->absolute_transform); return; } #endif @@ -296,6 +300,7 @@ static void _remove_layer(displayio_group_t *self, size_t index) { bool has_dirty_area = draw_protocol->draw_protocol_impl->draw_get_dirty_area(layer, &layer_area); rendered_last_frame = has_dirty_area; draw_protocol->draw_protocol_impl->draw_update_transform(layer, NULL); + draw_protocol->draw_protocol_impl->draw_set_in_group(layer, false); } #endif layer = mp_obj_cast_to_native_base( diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index 75e1de8b96071..680a9f157c360 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -555,3 +555,9 @@ void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displ self->absolute_transform = group_transform == NULL ? &null_transform : group_transform; common_hal_vectorio_vector_shape_set_dirty(self); } + +bool vectorio_vector_shape_set_in_group(vectorio_vector_shape_t *self, bool in_group) { + bool was_in_group = self->in_group; + self->in_group = in_group; + return was_in_group; +} diff --git a/shared-module/vectorio/VectorShape.h b/shared-module/vectorio/VectorShape.h index db77fc0acb940..f66569f97d492 100644 --- a/shared-module/vectorio/VectorShape.h +++ b/shared-module/vectorio/VectorShape.h @@ -43,6 +43,7 @@ typedef struct { displayio_area_t current_area; bool current_area_dirty; bool hidden; + bool in_group; } vectorio_vector_shape_t; displayio_area_t *vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_t *self, displayio_area_t *tail);