diff --git a/micropython/modules/picographics/picographics.cpp b/micropython/modules/picographics/picographics.cpp index 8e0b57a7a..61b7f34b5 100644 --- a/micropython/modules/picographics/picographics.cpp +++ b/micropython/modules/picographics/picographics.cpp @@ -40,7 +40,7 @@ typedef struct _ModPicoGraphics_obj_t { void *fontdata; _PimoroniI2C_obj_t *i2c; bool blocking = true; - //mp_obj_t scanline_callback; // Not really feasible in MicroPython + uint8_t layers; } ModPicoGraphics_obj_t; bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height, int &rotate, int &pen_type, PicoGraphicsBusType &bus_type) { @@ -477,6 +477,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size //self->scanline_callback = mp_const_none; + self->layers = layers; self->spritedata = nullptr; // Clear the buffer @@ -807,6 +808,10 @@ mp_obj_t ModPicoGraphics_set_pen(mp_obj_t self_in, mp_obj_t pen) { mp_obj_t ModPicoGraphics_set_layer(mp_obj_t self_in, mp_obj_t layer) { ModPicoGraphics_obj_t *self = MP_OBJ_TO_PTR2(self_in, ModPicoGraphics_obj_t); + if (mp_obj_get_int(layer) >= self->layers) { + mp_raise_ValueError("set_layer: layer out of range!"); + } + self->graphics->set_layer(mp_obj_get_int(layer)); return mp_const_none; diff --git a/micropython/modules/picovector/picovector.cpp b/micropython/modules/picovector/picovector.cpp index 6709c3d3f..b29b1e714 100644 --- a/micropython/modules/picovector/picovector.cpp +++ b/micropython/modules/picovector/picovector.cpp @@ -16,7 +16,11 @@ typedef struct _ModPicoGraphics_obj_t { mp_obj_base_t base; PicoGraphics *graphics; DisplayDriver *display; + void *spritedata; void *buffer; + void *fontdata; + void *i2c; + bool blocking = true; } ModPicoGraphics_obj_t; typedef struct _VECTOR_obj_t {