diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 6beb320527e43..6dc0262d2f629 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -1056,7 +1056,8 @@ msgstr "" msgid "File exists" msgstr "" -#: shared-module/lvfontio/OnDiskFont.c shared-module/os/getenv.c +#: shared-bindings/supervisor/__init__.c shared-module/lvfontio/OnDiskFont.c +#: shared-module/os/getenv.c msgid "File not found" msgstr "" @@ -1251,6 +1252,7 @@ msgstr "" #: ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2040.c py/argcheck.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/epaperdisplay/EPaperDisplay.c shared-bindings/pwmio/PWMOut.c +#: shared-bindings/supervisor/__init__.c #: shared-module/aurora_epaper/aurora_framebuffer.c #: shared-module/lvfontio/OnDiskFont.c msgid "Invalid %q" @@ -2068,6 +2070,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-module/tilepalettemapper/TilePaletteMapper.c +msgid "TilePaletteMapper may only be bound to a TileGrid once" +msgstr "" + #: shared-bindings/alarm/time/TimeAlarm.c msgid "Time is in the past." msgstr "" @@ -2591,16 +2597,16 @@ msgstr "" msgid "bits must be 32 or less" msgstr "" +#: shared-bindings/audiofreeverb/Freeverb.c +msgid "bits_per_sample must be 16" +msgstr "" + #: shared-bindings/audiodelays/Chorus.c shared-bindings/audiodelays/Echo.c #: shared-bindings/audiodelays/MultiTapDelay.c #: shared-bindings/audiodelays/PitchShift.c #: shared-bindings/audiofilters/Distortion.c -#: shared-bindings/audiodelays/Reverb.c -msgid "bits_per_sample must be 16" -msgstr "" - -#: shared-bindings/audiodelays/Echo.c shared-bindings/audiofilters/Distortion.c -#: shared-bindings/audiofilters/Filter.c shared-bindings/audiomixer/Mixer.c +#: shared-bindings/audiofilters/Filter.c shared-bindings/audiofilters/Phaser.c +#: shared-bindings/audiomixer/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "" @@ -4017,7 +4023,7 @@ msgstr "" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audiodelays/Reverb.c +#: shared-bindings/audiofreeverb/Freeverb.c msgid "samples_signed must be true" msgstr "" diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.mk b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.mk index f907853f2382e..366586c1d5568 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.mk +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.mk @@ -10,3 +10,4 @@ CIRCUITPY_ESP_FLASH_SIZE = 4MB CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1 CIRCUITPY_ESP_USB_SERIAL_JTAG = 0 +CIRCUITPY_TILEPALETTEMAPPER = 0 diff --git a/ports/espressif/boards/beetle-esp32-c3/mpconfigboard.mk b/ports/espressif/boards/beetle-esp32-c3/mpconfigboard.mk index a03e6c32eb2c6..4341584e4cef3 100644 --- a/ports/espressif/boards/beetle-esp32-c3/mpconfigboard.mk +++ b/ports/espressif/boards/beetle-esp32-c3/mpconfigboard.mk @@ -11,3 +11,4 @@ CIRCUITPY_ESP_FLASH_SIZE=4MB CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1 CIRCUITPY_ESP_USB_SERIAL_JTAG = 1 +CIRCUITPY_TILEPALETTEMAPPER = 0 diff --git a/ports/espressif/boards/lolin_c3_mini/mpconfigboard.mk b/ports/espressif/boards/lolin_c3_mini/mpconfigboard.mk index 36dc38883ff39..2481a95928bda 100644 --- a/ports/espressif/boards/lolin_c3_mini/mpconfigboard.mk +++ b/ports/espressif/boards/lolin_c3_mini/mpconfigboard.mk @@ -10,3 +10,4 @@ CIRCUITPY_ESP_FLASH_SIZE=4MB CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1 CIRCUITPY_ESP_USB_SERIAL_JTAG = 1 +CIRCUITPY_TILEPALETTEMAPPER = 0 diff --git a/ports/espressif/boards/microdev_micro_c3/mpconfigboard.mk b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.mk index b2ea6005db53a..fa51216e911a1 100644 --- a/ports/espressif/boards/microdev_micro_c3/mpconfigboard.mk +++ b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.mk @@ -10,3 +10,4 @@ CIRCUITPY_ESP_FLASH_SIZE = 4MB CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1 CIRCUITPY_ESP_USB_SERIAL_JTAG = 1 +CIRCUITPY_TILEPALETTEMAPPER = 0 diff --git a/shared-bindings/tilepalettemapper/TilePaletteMapper.c b/shared-bindings/tilepalettemapper/TilePaletteMapper.c index 88189de549dbb..ed3e928957f9f 100644 --- a/shared-bindings/tilepalettemapper/TilePaletteMapper.c +++ b/shared-bindings/tilepalettemapper/TilePaletteMapper.c @@ -12,6 +12,7 @@ #include "shared-bindings/util.h" #include "shared-bindings/displayio/Palette.h" #include "shared-bindings/displayio/ColorConverter.h" +#include "shared-bindings/displayio/TileGrid.h" #include "shared-bindings/tilepalettemapper/TilePaletteMapper.h" //| class TilePaletteMapper: @@ -21,24 +22,21 @@ //| bitmap with a wider array of colors.""" //| //| def __init__( -//| self, palette: displayio.Palette, input_color_count: int, width: int, height: int +//| self, palette: displayio.Palette, input_color_count: int //| ) -> None: //| """Create a TilePaletteMApper object to store a set of color mappings for tiles. //| //| :param Union[displayio.Palette, displayio.ColorConverter] pixel_shader: //| The palette or ColorConverter to get mapped colors from. -//| :param int input_color_count: The number of colors in in the input bitmap. -//| :param int width: The width of the grid in tiles. -//| :param int height: The height of the grid in tiles.""" +//| :param int input_color_count: The number of colors in in the input bitmap.""" //| static mp_obj_t tilepalettemapper_tilepalettemapper_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_pixel_shader, ARG_input_color_count, ARG_width, ARG_height }; + enum { ARG_pixel_shader, ARG_input_color_count }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_input_color_count, MP_ARG_INT | MP_ARG_REQUIRED }, - { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED }, - { MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED }, + }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -46,8 +44,10 @@ static mp_obj_t tilepalettemapper_tilepalettemapper_make_new(const mp_obj_type_t if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) { mp_raise_TypeError_varg(MP_ERROR_TEXT("unsupported %q type"), MP_QSTR_pixel_shader); } + + tilepalettemapper_tilepalettemapper_t *self = mp_obj_malloc(tilepalettemapper_tilepalettemapper_t, &tilepalettemapper_tilepalettemapper_type); - common_hal_tilepalettemapper_tilepalettemapper_construct(self, pixel_shader, args[ARG_input_color_count].u_int, args[ARG_width].u_int, args[ARG_height].u_int); + common_hal_tilepalettemapper_tilepalettemapper_construct(self, pixel_shader, args[ARG_input_color_count].u_int); return MP_OBJ_FROM_PTR(self); } @@ -84,9 +84,20 @@ static mp_obj_t tilepalettemapper_tilepalettemapper_obj_get_pixel_shader(mp_obj_ } MP_DEFINE_CONST_FUN_OBJ_1(tilepalettemapper_tilepalettemapper_get_pixel_shader_obj, tilepalettemapper_tilepalettemapper_obj_get_pixel_shader); -MP_PROPERTY_GETTER(tilepalettemapper_tilepalettemapper_palette_obj, +MP_PROPERTY_GETTER(tilepalettemapper_tilepalettemapper_pixel_shader_obj, (mp_obj_t)&tilepalettemapper_tilepalettemapper_get_pixel_shader_obj); +//| tilegrid: displayio.TileGrid +//| """The TileGrid that the TilePaletteMapper is used with.""" +//| +static mp_obj_t tilepalettemapper_tilepalettemapper_obj_get_tilegrid(mp_obj_t self_in) { + tilepalettemapper_tilepalettemapper_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_tilepalettemapper_tilepalettemapper_get_tilegrid(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(tilepalettemapper_tilepalettemapper_get_tilegrid_obj, tilepalettemapper_tilepalettemapper_obj_get_tilegrid); + +MP_PROPERTY_GETTER(tilepalettemapper_tilepalettemapper_tilegrid_obj, + (mp_obj_t)&tilepalettemapper_tilepalettemapper_get_tilegrid_obj); //| def __getitem__(self, index: Union[Tuple[int, int], int]) -> Tuple[int]: //| """Returns the mapping for the given index. The index can either be an x,y tuple or an int equal @@ -154,7 +165,8 @@ static mp_obj_t tilepalettemapper_subscr(mp_obj_t self_in, mp_obj_t index_obj, m static const mp_rom_map_elem_t tilepalettemapper_tilepalettemapper_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&tilepalettemapper_tilepalettemapper_width_obj) }, { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&tilepalettemapper_tilepalettemapper_height_obj) }, - { MP_ROM_QSTR(MP_QSTR_palette), MP_ROM_PTR(&tilepalettemapper_tilepalettemapper_palette_obj) }, + { MP_ROM_QSTR(MP_QSTR_pixel_shader), MP_ROM_PTR(&tilepalettemapper_tilepalettemapper_pixel_shader_obj) }, + { MP_ROM_QSTR(MP_QSTR_tilegrid), MP_ROM_PTR(&tilepalettemapper_tilepalettemapper_tilegrid_obj) }, }; static MP_DEFINE_CONST_DICT(tilepalettemapper_tilepalettemapper_locals_dict, tilepalettemapper_tilepalettemapper_locals_dict_table); diff --git a/shared-bindings/tilepalettemapper/TilePaletteMapper.h b/shared-bindings/tilepalettemapper/TilePaletteMapper.h index 3fa1ab1e3a5cc..ef0d949591722 100644 --- a/shared-bindings/tilepalettemapper/TilePaletteMapper.h +++ b/shared-bindings/tilepalettemapper/TilePaletteMapper.h @@ -8,11 +8,12 @@ extern const mp_obj_type_t tilepalettemapper_tilepalettemapper_type; void common_hal_tilepalettemapper_tilepalettemapper_construct(tilepalettemapper_tilepalettemapper_t *self, - mp_obj_t paltte, uint16_t input_color_count, uint16_t bitmap_width_in_tiles, uint16_t bitmap_height_in_tiles); + mp_obj_t paltte, uint16_t input_color_count); uint16_t common_hal_tilepalettemapper_tilepalettemapper_get_width(tilepalettemapper_tilepalettemapper_t *self); uint16_t common_hal_tilepalettemapper_tilepalettemapper_get_height(tilepalettemapper_tilepalettemapper_t *self); mp_obj_t common_hal_tilepalettemapper_tilepalettemapper_get_pixel_shader(tilepalettemapper_tilepalettemapper_t *self); +mp_obj_t common_hal_tilepalettemapper_tilepalettemapper_get_tilegrid(tilepalettemapper_tilepalettemapper_t *self); mp_obj_t common_hal_tilepalettemapper_tilepalettemapper_get_mapping(tilepalettemapper_tilepalettemapper_t *self, uint16_t x, uint16_t y); void common_hal_tilepalettemapper_tilepalettemapper_set_mapping(tilepalettemapper_tilepalettemapper_t *self, uint16_t x, uint16_t y, size_t len, mp_obj_t *items); diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c index cfa97130b6aa0..b5c691ccbd6ce 100644 --- a/shared-module/displayio/TileGrid.c +++ b/shared-module/displayio/TileGrid.c @@ -81,6 +81,11 @@ void common_hal_displayio_tilegrid_construct(displayio_tilegrid_t *self, mp_obj_ self->flip_y = false; self->transpose_xy = false; self->absolute_transform = NULL; + #if CIRCUITPY_TILEPALETTEMAPPER + if (mp_obj_is_type(self->pixel_shader, &tilepalettemapper_tilepalettemapper_type)) { + tilepalettemapper_tilepalettemapper_bind(self->pixel_shader, self); + } + #endif } @@ -231,6 +236,11 @@ mp_obj_t common_hal_displayio_tilegrid_get_pixel_shader(displayio_tilegrid_t *se void common_hal_displayio_tilegrid_set_pixel_shader(displayio_tilegrid_t *self, mp_obj_t pixel_shader) { self->pixel_shader = pixel_shader; self->full_change = true; + #if CIRCUITPY_TILEPALETTEMAPPER + if (mp_obj_is_type(self->pixel_shader, &tilepalettemapper_tilepalettemapper_type)) { + tilepalettemapper_tilepalettemapper_bind(self->pixel_shader, self); + } + #endif } mp_obj_t common_hal_displayio_tilegrid_get_bitmap(displayio_tilegrid_t *self) { @@ -275,25 +285,7 @@ uint16_t common_hal_displayio_tilegrid_get_tile(displayio_tilegrid_t *self, uint } } -void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t x, uint16_t y, uint16_t tile_index) { - if (tile_index >= self->tiles_in_bitmap) { - mp_raise_ValueError(MP_ERROR_TEXT("Tile index out of bounds")); - } - - void *tiles = self->tiles; - if (self->inline_tiles) { - tiles = &self->tiles; - } - if (tiles == NULL) { - return; - } - - uint32_t index = y * self->width_in_tiles + x; - if (self->tiles_in_bitmap > 255) { - ((uint16_t *)tiles)[index] = tile_index; - } else { - ((uint8_t *)tiles)[index] = (uint8_t)tile_index; - } +void displayio_tilegrid_mark_tile_dirty(displayio_tilegrid_t *self, uint16_t x, uint16_t y) { displayio_area_t temp_area; displayio_area_t *tile_area; if (!self->partial_change) { @@ -317,10 +309,31 @@ void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t if (self->partial_change) { displayio_area_union(&self->dirty_area, &temp_area, &self->dirty_area); } - self->partial_change = true; } +void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t x, uint16_t y, uint16_t tile_index) { + if (tile_index >= self->tiles_in_bitmap) { + mp_raise_ValueError(MP_ERROR_TEXT("Tile index out of bounds")); + } + + void *tiles = self->tiles; + if (self->inline_tiles) { + tiles = &self->tiles; + } + if (tiles == NULL) { + return; + } + + uint32_t index = y * self->width_in_tiles + x; + if (self->tiles_in_bitmap > 255) { + ((uint16_t *)tiles)[index] = tile_index; + } else { + ((uint8_t *)tiles)[index] = (uint8_t)tile_index; + } + displayio_tilegrid_mark_tile_dirty(self, x, y); +} + void common_hal_displayio_tilegrid_set_all_tiles(displayio_tilegrid_t *self, uint16_t tile_index) { if (tile_index >= self->tiles_in_bitmap) { mp_raise_ValueError(MP_ERROR_TEXT("Tile index out of bounds")); @@ -613,11 +626,6 @@ void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self) { } else if (mp_obj_is_type(self->pixel_shader, &displayio_colorconverter_type)) { displayio_colorconverter_finish_refresh(self->pixel_shader); } - #if CIRCUITPY_TILEPALETTEMAPPER - if (mp_obj_is_type(self->pixel_shader, &tilepalettemapper_tilepalettemapper_type)) { - tilepalettemapper_tilepalettemapper_finish_refresh(self->pixel_shader); - } - #endif if (mp_obj_is_type(self->bitmap, &displayio_bitmap_type)) { displayio_bitmap_finish_refresh(self->bitmap); } else if (mp_obj_is_type(self->bitmap, &displayio_ondiskbitmap_type)) { @@ -671,11 +679,6 @@ displayio_area_t *displayio_tilegrid_get_refresh_areas(displayio_tilegrid_t *sel displayio_palette_needs_refresh(self->pixel_shader)) || (mp_obj_is_type(self->pixel_shader, &displayio_colorconverter_type) && displayio_colorconverter_needs_refresh(self->pixel_shader)); - #if CIRCUITPY_TILEPALETTEMAPPER - self->full_change = self->full_change || - (mp_obj_is_type(self->pixel_shader, &tilepalettemapper_tilepalettemapper_type) && - tilepalettemapper_tilepalettemapper_needs_refresh(self->pixel_shader)); - #endif if (self->full_change || first_draw) { self->current_area.next = tail; diff --git a/shared-module/displayio/TileGrid.h b/shared-module/displayio/TileGrid.h index 400ade5359827..0051cc0ebf19d 100644 --- a/shared-module/displayio/TileGrid.h +++ b/shared-module/displayio/TileGrid.h @@ -68,3 +68,5 @@ void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self); bool displayio_tilegrid_get_rendered_hidden(displayio_tilegrid_t *self); void displayio_tilegrid_validate_pixel_shader(mp_obj_t pixel_shader); + +void displayio_tilegrid_mark_tile_dirty(displayio_tilegrid_t *self, uint16_t x, uint16_t y); diff --git a/shared-module/tilepalettemapper/TilePaletteMapper.c b/shared-module/tilepalettemapper/TilePaletteMapper.c index fb784fd441b9b..13711b2c2537d 100644 --- a/shared-module/tilepalettemapper/TilePaletteMapper.c +++ b/shared-module/tilepalettemapper/TilePaletteMapper.c @@ -8,29 +8,13 @@ #include "shared-bindings/tilepalettemapper/TilePaletteMapper.h" #include "shared-bindings/displayio/Palette.h" #include "shared-bindings/displayio/ColorConverter.h" +#include "shared-bindings/displayio/TileGrid.h" void common_hal_tilepalettemapper_tilepalettemapper_construct(tilepalettemapper_tilepalettemapper_t *self, - mp_obj_t pixel_shader, uint16_t input_color_count, uint16_t width, uint16_t height) { - + mp_obj_t pixel_shader, uint16_t input_color_count) { self->pixel_shader = pixel_shader; - self->width_in_tiles = width; - self->height_in_tiles = height; self->input_color_count = input_color_count; - self->needs_refresh = false; - int mappings_len = width * height; - self->tile_mappings = (uint32_t **)m_malloc(mappings_len * sizeof(uint32_t *)); - for (int i = 0; i < mappings_len; i++) { - self->tile_mappings[i] = (uint32_t *)m_malloc_without_collect(input_color_count * sizeof(uint32_t)); - if (mp_obj_is_type(self->pixel_shader, &displayio_palette_type)) { - for (uint16_t j = 0; j < input_color_count; j++) { - self->tile_mappings[i][j] = j; - } - } else if (mp_obj_is_type(self->pixel_shader, &displayio_colorconverter_type)) { - for (uint16_t j = 0; j < input_color_count; j++) { - self->tile_mappings[i][j] = 0; - } - } - } + self->tilegrid = mp_const_none; } uint16_t common_hal_tilepalettemapper_tilepalettemapper_get_width(tilepalettemapper_tilepalettemapper_t *self) { @@ -45,6 +29,10 @@ mp_obj_t common_hal_tilepalettemapper_tilepalettemapper_get_pixel_shader(tilepal return self->pixel_shader; } +mp_obj_t common_hal_tilepalettemapper_tilepalettemapper_get_tilegrid(tilepalettemapper_tilepalettemapper_t *self) { + return self->tilegrid; +} + mp_obj_t common_hal_tilepalettemapper_tilepalettemapper_get_mapping(tilepalettemapper_tilepalettemapper_t *self, uint16_t x, uint16_t y) { int index = x + y * self->width_in_tiles; mp_obj_t result[self->input_color_count]; @@ -67,7 +55,7 @@ void common_hal_tilepalettemapper_tilepalettemapper_set_mapping(tilepalettemappe mp_arg_validate_int_range(mapping_val, 0, palette_max, MP_QSTR_mapping_value); self->tile_mappings[y * self->width_in_tiles + x][i] = mapping_val; } - self->needs_refresh = true; + displayio_tilegrid_mark_tile_dirty(self->tilegrid, x, y); } void tilepalettemapper_tilepalettemapper_get_color(tilepalettemapper_tilepalettemapper_t *self, const _displayio_colorspace_t *colorspace, displayio_input_pixel_t *input_pixel, displayio_output_pixel_t *output_color, uint16_t x_tile_index, uint16_t y_tile_index) { @@ -91,10 +79,26 @@ void tilepalettemapper_tilepalettemapper_get_color(tilepalettemapper_tilepalette } -bool tilepalettemapper_tilepalettemapper_needs_refresh(tilepalettemapper_tilepalettemapper_t *self) { - return self->needs_refresh; -} +void tilepalettemapper_tilepalettemapper_bind(tilepalettemapper_tilepalettemapper_t *self, displayio_tilegrid_t *tilegrid) { + if (self->tilegrid != mp_const_none) { + mp_raise_RuntimeError(MP_ERROR_TEXT("TilePaletteMapper may only be bound to a TileGrid once")); + } + self->tilegrid = tilegrid; + self->width_in_tiles = common_hal_displayio_tilegrid_get_width(tilegrid); + self->height_in_tiles = common_hal_displayio_tilegrid_get_height(tilegrid); -void tilepalettemapper_tilepalettemapper_finish_refresh(tilepalettemapper_tilepalettemapper_t *self) { - self->needs_refresh = false; + int mappings_len = self->width_in_tiles * self->height_in_tiles; + self->tile_mappings = (uint32_t **)m_malloc(mappings_len * sizeof(uint32_t *)); + for (int i = 0; i < mappings_len; i++) { + self->tile_mappings[i] = (uint32_t *)m_malloc_without_collect(self->input_color_count * sizeof(uint32_t)); + if (mp_obj_is_type(self->pixel_shader, &displayio_palette_type)) { + for (uint16_t j = 0; j < self->input_color_count; j++) { + self->tile_mappings[i][j] = j; + } + } else if (mp_obj_is_type(self->pixel_shader, &displayio_colorconverter_type)) { + for (uint16_t j = 0; j < self->input_color_count; j++) { + self->tile_mappings[i][j] = 0; + } + } + } } diff --git a/shared-module/tilepalettemapper/TilePaletteMapper.h b/shared-module/tilepalettemapper/TilePaletteMapper.h index 98226ae7e04fa..d1f535eda11bb 100644 --- a/shared-module/tilepalettemapper/TilePaletteMapper.h +++ b/shared-module/tilepalettemapper/TilePaletteMapper.h @@ -12,18 +12,17 @@ #include "py/obj.h" #include "shared-module/displayio/Palette.h" +#include "shared-module/displayio/TileGrid.h" typedef struct { mp_obj_base_t base; mp_obj_t pixel_shader; + mp_obj_t tilegrid; uint16_t width_in_tiles; uint16_t height_in_tiles; uint16_t input_color_count; uint32_t **tile_mappings; - bool needs_refresh; } tilepalettemapper_tilepalettemapper_t; -bool tilepalettemapper_tilepalettemapper_needs_refresh(tilepalettemapper_tilepalettemapper_t *self); -void tilepalettemapper_tilepalettemapper_finish_refresh(tilepalettemapper_tilepalettemapper_t *self); - void tilepalettemapper_tilepalettemapper_get_color(tilepalettemapper_tilepalettemapper_t *self, const _displayio_colorspace_t *colorspace, displayio_input_pixel_t *input_pixel, displayio_output_pixel_t *output_color, uint16_t x_tile_index, uint16_t y_tile_index); +void tilepalettemapper_tilepalettemapper_bind(tilepalettemapper_tilepalettemapper_t *self, displayio_tilegrid_t *tilegrid);