diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index 2b9b9f0a80..2c89a32906 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit 2b9b9f0a80810b0c4ff0feebbbe07312251de144 +Subproject commit 2c89a329063848bcd7dba6af6fb6c9d6036dd4f2 diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 1d5c06c862..4dfcc796e7 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -81,21 +81,17 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { mp_raise_TypeError(translate("argument num/types mismatch")); } displayio_display_obj_t *display = MP_OBJ_TO_PTR(native_display); - uint8_t scale = 1; - if (n_args > 7) { - scale = mp_obj_get_int(args[7]); - } + uint8_t scale = mp_obj_get_int(args[7]); + int16_t vx = mp_obj_get_int(args[8]); + int16_t vy = mp_obj_get_int(args[9]); uint16_t background = 0; - if (n_args > 8) { - background = mp_obj_get_int(args[8]); - } - render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size, - display, scale, background); + render_stage(x0, y0, x1, y1, vx, vy, layers, layers_size, + buffer, buffer_size, display, scale, background); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stage_render_obj, 7, 8, stage_render); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stage_render_obj, 10, 10, stage_render); STATIC const mp_rom_map_elem_t stage_module_globals_table[] = { diff --git a/shared-module/_stage/__init__.c b/shared-module/_stage/__init__.c index 69f7812c0e..7ec640bc6e 100644 --- a/shared-module/_stage/__init__.c +++ b/shared-module/_stage/__init__.c @@ -31,7 +31,10 @@ #include "shared-bindings/_stage/Text.h" -void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, +void render_stage( + uint16_t x0, uint16_t y0, + uint16_t x1, uint16_t y1, + int16_t vx, int16_t vy, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, displayio_display_obj_t *display, @@ -55,9 +58,9 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CHIP_SELECT_TOGGLE_EVERY_BYTE, &display->write_ram_command, 1); size_t index = 0; - for (uint16_t y = y0; y < y1; ++y) { + for (int16_t y = y0 + vy; y < y1 + vy; ++y) { for (uint8_t yscale = 0; yscale < scale; ++yscale) { - for (uint16_t x = x0; x < x1; ++x) { + for (int16_t x = x0 + vx; x < x1 + vx; ++x) { uint16_t c = TRANSPARENT; for (size_t layer = 0; layer < layers_size; ++layer) { layer_obj_t *obj = MP_OBJ_TO_PTR(layers[layer]); diff --git a/shared-module/_stage/__init__.h b/shared-module/_stage/__init__.h index 5cbaa235b6..596752bee5 100644 --- a/shared-module/_stage/__init__.h +++ b/shared-module/_stage/__init__.h @@ -34,7 +34,10 @@ #define TRANSPARENT (0x1ff8) -void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, +void render_stage( + uint16_t x0, uint16_t y0, + uint16_t x1, uint16_t y1, + int16_t vx, int16_t vy, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, displayio_display_obj_t *display,