summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorDan Halbert <halbert@adafruit.com>2019-08-02 18:28:16 -0400
committerGitHub <noreply@github.com>2019-08-02 18:28:16 -0400
commit347fbb652fa8ceba7ee640a690f0996204136443 (patch)
tree1a78eec970fee0705fd83c481658bae48d81242a /shared-bindings
parent64bf0f8f1feb432a4b7206b53867aa62fb3cce0f (diff)
parentc1e5247d51ffb34bdfdb1f5039ba9118fab25f26 (diff)
Merge pull request #2030 from pewpew-game/stage-scale
Add support for scaling to _stage
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/_stage/__init__.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c
index 1ca206339..485fa80c5 100644
--- a/shared-bindings/_stage/__init__.c
+++ b/shared-bindings/_stage/__init__.c
@@ -50,7 +50,7 @@
//| Layer
//| Text
//|
-//| .. function:: render(x0, y0, x1, y1, layers, buffer, display)
+//| .. function:: render(x0, y0, x1, y1, layers, buffer, display[, scale])
//|
//| Render and send to the display a fragment of the screen.
//|
@@ -61,6 +61,7 @@
//| :param list layers: A list of the :py:class:`~_stage.Layer` objects.
//| :param bytearray buffer: A buffer to use for rendering.
//| :param ~displayio.Display display: The display to use.
+//| :param int scale: How many times should the image be scaled up.
//|
//| There are also no sanity checks, outside of the basic overflow
//| checking. The caller is responsible for making the passed parameters
@@ -89,6 +90,10 @@ 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 >= 8) {
+ scale = mp_obj_get_int(args[7]);
+ }
while (!displayio_display_begin_transaction(display)) {
#ifdef MICROPY_VM_HOOK_LOOP
@@ -103,12 +108,13 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) {
displayio_display_set_region_to_update(display, &area);
display->send(display->bus, true, &display->write_ram_command, 1);
- render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size, display);
+ render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size,
+ display, scale);
displayio_display_end_transaction(display);
return mp_const_none;
}
-MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stage_render_obj, 7, 7, stage_render);
+MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stage_render_obj, 7, 8, stage_render);
STATIC const mp_rom_map_elem_t stage_module_globals_table[] = {