diff --git a/shared-module/displayio/ColorConverter.c b/shared-module/displayio/ColorConverter.c index d20b24c01a..3928e115ab 100644 --- a/shared-module/displayio/ColorConverter.c +++ b/shared-module/displayio/ColorConverter.c @@ -39,3 +39,11 @@ bool common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *sel *output_color = __builtin_bswap16(packed); return true; } + +// Currently no refresh logic is needed for a ColorConverter. +bool displayio_colorconverter_needs_refresh(displayio_colorconverter_t *self) { + return false; +} + +void displayio_colorconverter_finish_refresh(displayio_colorconverter_t *self) { +} diff --git a/shared-module/displayio/ColorConverter.h b/shared-module/displayio/ColorConverter.h index 62ef2eaab9..7f3c1a0a03 100644 --- a/shared-module/displayio/ColorConverter.h +++ b/shared-module/displayio/ColorConverter.h @@ -36,4 +36,7 @@ typedef struct { mp_obj_base_t base; } displayio_colorconverter_t; +bool displayio_colorconverter_needs_refresh(displayio_colorconverter_t *self); +void displayio_colorconverter_finish_refresh(displayio_colorconverter_t *self); + #endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_COLORCONVERTER_H diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c index bbbb119245..3212dfe8b9 100644 --- a/shared-module/displayio/TileGrid.c +++ b/shared-module/displayio/TileGrid.c @@ -170,12 +170,24 @@ bool displayio_tilegrid_get_pixel(displayio_tilegrid_t *self, int16_t x, int16_t } bool displayio_tilegrid_needs_refresh(displayio_tilegrid_t *self) { - return self->needs_refresh || displayio_palette_needs_refresh(self->pixel_shader); + if (self->needs_refresh) { + return true; + } else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type)) { + return displayio_palette_needs_refresh(self->pixel_shader); + } else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type)) { + return displayio_colorconverter_needs_refresh(self->pixel_shader); + } + + return false; } void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self) { self->needs_refresh = false; - displayio_palette_finish_refresh(self->pixel_shader); + if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type)) { + displayio_palette_finish_refresh(self->pixel_shader); + } else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type)) { + displayio_colorconverter_finish_refresh(self->pixel_shader); + } // TODO(tannewt): We could double buffer changes to position and move them over here. // That way they won't change during a refresh and tear. }