From 4e2ee3be422802b202fe43260aa66e7eaa2bad7f Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 2 Sep 2025 12:18:15 +0100 Subject: [PATCH] PicoGraphics: Add Spectra73 display type for Inky Frame. Internally this uses the Inky73 driver with no modifications, but also preloads the correct colour palette into PicoGraphics. --- .../modules/picographics/picographics.c | 1 + .../modules/picographics/picographics.cpp | 18 ++++++++++++++++-- .../modules/picographics/picographics.h | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/micropython/modules/picographics/picographics.c b/micropython/modules/picographics/picographics.c index c0f811e4..42f9cb30 100644 --- a/micropython/modules/picographics/picographics.c +++ b/micropython/modules/picographics/picographics.c @@ -175,6 +175,7 @@ static const mp_map_elem_t picographics_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_DISPLAY_PRESTO), MP_ROM_INT(DISPLAY_PRESTO) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY_PRESTO_FULL_RES), MP_ROM_INT(DISPLAY_PRESTO_FULL_RES) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY_GENERIC), MP_ROM_INT(DISPLAY_GENERIC) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY_INKY_FRAME_SPECTRA_7), MP_ROM_INT(DISPLAY_INKY_FRAME_SPECTRA_7) }, { MP_ROM_QSTR(MP_QSTR_PEN_1BIT), MP_ROM_INT(PEN_1BIT) }, diff --git a/micropython/modules/picographics/picographics.cpp b/micropython/modules/picographics/picographics.cpp index dbdc2bba..b2d9143a 100644 --- a/micropython/modules/picographics/picographics.cpp +++ b/micropython/modules/picographics/picographics.cpp @@ -220,6 +220,7 @@ bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height, if(pen_type == -1) pen_type = PEN_RGB888; break; case DISPLAY_INKY_FRAME_7: + case DISPLAY_INKY_FRAME_SPECTRA_7: width = 800; height = 480; bus_type = BUS_SPI; @@ -367,7 +368,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size self->i2c = (_PimoroniI2C_obj_t *)MP_OBJ_TO_PTR(PimoroniI2C_make_new(&PimoroniI2C_type, 0, 0, nullptr)); i2c_bus = (pimoroni::I2C *)(self->i2c->i2c); } else if (bus_type == BUS_SPI) { - if(display == DISPLAY_INKY_FRAME || display == DISPLAY_INKY_FRAME_4 || display == DISPLAY_INKY_FRAME_7) { + if(display == DISPLAY_INKY_FRAME || display == DISPLAY_INKY_FRAME_4 || display == DISPLAY_INKY_FRAME_7 || display == DISPLAY_INKY_FRAME_SPECTRA_7) { spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 28, PIN_UNUSED}; } else if (display == DISPLAY_INKY_PACK) { spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 20, PIN_UNUSED}; @@ -389,7 +390,7 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size // TODO grab BUSY and RESET from ARG_extra_pins self->display = m_new_class(UC8159, width, height, (Rotation)rotate, spi_bus); - } else if (display == DISPLAY_INKY_FRAME_7) { + } else if (display == DISPLAY_INKY_FRAME_7 || display == DISPLAY_INKY_FRAME_SPECTRA_7) { pen_type = PEN_INKY7; // TODO grab BUSY and RESET from ARG_extra_pins self->display = m_new_class(Inky73, width, height, (Rotation)rotate, spi_bus); @@ -502,6 +503,19 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size self->graphics->set_layer(0); } + // Replace the palette for Spectra 7 + // We use white for colour 4 since the first pure white should always get + // considered for dithering before it. + if (display == DISPLAY_INKY_FRAME_SPECTRA_7) { + self->graphics->update_pen(0, 0, 0, 0); + self->graphics->update_pen(1, 255, 255, 255); + self->graphics->update_pen(2, 255, 255, 0); + self->graphics->update_pen(3, 255, 0, 0); + self->graphics->update_pen(4, 255, 255, 255); // This colour is missing/non-functional on the display + self->graphics->update_pen(5, 0, 0, 255); + self->graphics->update_pen(6, 0, 255, 0); + } + // Update the LCD from the graphics library if (display != DISPLAY_INKY_FRAME && display != DISPLAY_INKY_FRAME_4 && display != DISPLAY_INKY_PACK && display != DISPLAY_INKY_FRAME_7) { self->display->update(self->graphics); diff --git a/micropython/modules/picographics/picographics.h b/micropython/modules/picographics/picographics.h index b6f53926..0c5c2452 100644 --- a/micropython/modules/picographics/picographics.h +++ b/micropython/modules/picographics/picographics.h @@ -35,7 +35,8 @@ enum PicoGraphicsDisplay { DISPLAY_EXPLORER, DISPLAY_PRESTO, DISPLAY_PRESTO_FULL_RES, - DISPLAY_GENERIC + DISPLAY_GENERIC, + DISPLAY_INKY_FRAME_SPECTRA_7, }; enum PicoGraphicsPenType {