From db0140f5869c59bef03fbd16f7cbf57059a2cf46 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Mon, 31 Jan 2022 15:02:00 -0600 Subject: [PATCH 1/5] Expose splash group, add function to resize REPL terminal --- shared-bindings/supervisor/__init__.c | 14 ++++++++++++++ supervisor/shared/display.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 35ae63c03d..b82853674f 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -33,6 +33,7 @@ #include "shared/runtime/interrupt_char.h" #include "supervisor/shared/autoreload.h" #include "supervisor/shared/bluetooth/bluetooth.h" +#include "supervisor/shared/display.h" #include "supervisor/shared/status_leds.h" #include "supervisor/shared/stack.h" #include "supervisor/shared/traceback.h" @@ -299,6 +300,17 @@ STATIC mp_obj_t supervisor_disable_ble_workflow(void) { } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_ble_workflow_obj, supervisor_disable_ble_workflow); +//| def reset_terminal(x_pixels: int, y_pixels: int) -> None: +//| """Adjust the pixel dimensions of the REPL console.""" +//| ... +//| +STATIC mp_obj_t supervisor_reset_terminal(mp_obj_t x_pixels, mp_obj_t y_pixels) { + supervisor_stop_terminal(); + supervisor_start_terminal(mp_obj_get_int(x_pixels), mp_obj_get_int(y_pixels)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(supervisor_reset_terminal_obj, supervisor_reset_terminal); + STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_supervisor) }, { MP_ROM_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&supervisor_enable_autoreload_obj) }, @@ -312,6 +324,8 @@ STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&supervisor_ticks_ms_obj) }, { MP_ROM_QSTR(MP_QSTR_get_previous_traceback), MP_ROM_PTR(&supervisor_get_previous_traceback_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_ble_workflow), MP_ROM_PTR(&supervisor_disable_ble_workflow_obj) }, + { MP_ROM_QSTR(MP_QSTR_splash), MP_ROM_PTR(&circuitpython_splash) }, + { MP_ROM_QSTR(MP_QSTR_reset_terminal), MP_ROM_PTR(&supervisor_reset_terminal_obj) }, }; STATIC MP_DEFINE_CONST_DICT(supervisor_module_globals, supervisor_module_globals_table); diff --git a/supervisor/shared/display.h b/supervisor/shared/display.h index 4110cfe8e4..8c57a1d579 100644 --- a/supervisor/shared/display.h +++ b/supervisor/shared/display.h @@ -32,6 +32,7 @@ #if CIRCUITPY_TERMINALIO #include "shared-bindings/displayio/Bitmap.h" +#include "shared-bindings/displayio/Group.h" #include "shared-bindings/displayio/TileGrid.h" #include "shared-bindings/fontio/BuiltinFont.h" #include "shared-bindings/terminalio/Terminal.h" @@ -45,6 +46,7 @@ extern const fontio_builtinfont_t supervisor_terminal_font; extern displayio_bitmap_t supervisor_terminal_font_bitmap; extern displayio_tilegrid_t supervisor_terminal_text_grid; extern terminalio_terminal_obj_t supervisor_terminal; +extern displayio_group_t circuitpython_splash; #endif From 0290fc35d2e40c7b525d1f9713f9bfc1772a5569 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 1 Feb 2022 08:28:09 -0600 Subject: [PATCH 2/5] Removing some unnecessary files that were changed --- shared-bindings/displayio/Display.c | 18 ++++++++++++++++++ shared-bindings/displayio/Display.h | 2 +- shared-bindings/supervisor/__init__.c | 1 - shared-module/displayio/Display.c | 4 ++++ shared-module/displayio/display_core.c | 15 +++++++++------ supervisor/shared/display.h | 2 -- 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 1b750eb934..ff08ea201b 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -444,6 +444,23 @@ const mp_obj_property_t displayio_display_bus_obj = { MP_ROM_NONE}, }; +//| root_group: _Group +//| """The root group on the display.""" +//| +//| +STATIC mp_obj_t displayio_display_obj_get_root_group(mp_obj_t self_in) { + displayio_display_obj_t *self = native_display(self_in); + return common_hal_displayio_display_get_root_group(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_root_group_obj, displayio_display_obj_get_root_group); + +const mp_obj_property_t displayio_display_root_group_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_display_get_root_group_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + //| def fill_row(self, y: int, buffer: WriteableBuffer) -> WriteableBuffer: //| """Extract the pixels from a single row @@ -517,6 +534,7 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) }, { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_display_rotation_obj) }, { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) }, + { MP_ROM_QSTR(MP_QSTR_root_group), MP_ROM_PTR(&displayio_display_root_group_obj) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_display_locals_dict, displayio_display_locals_dict_table); diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index 9e0eb64e5f..f193e61d2f 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -69,6 +69,6 @@ mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t * bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self, mp_float_t brightness); mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t *self); - +mp_obj_t common_hal_displayio_display_get_root_group(displayio_display_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_DISPLAY_H diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index b82853674f..f7f21f6ae4 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -324,7 +324,6 @@ STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&supervisor_ticks_ms_obj) }, { MP_ROM_QSTR(MP_QSTR_get_previous_traceback), MP_ROM_PTR(&supervisor_get_previous_traceback_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_ble_workflow), MP_ROM_PTR(&supervisor_disable_ble_workflow_obj) }, - { MP_ROM_QSTR(MP_QSTR_splash), MP_ROM_PTR(&circuitpython_splash) }, { MP_ROM_QSTR(MP_QSTR_reset_terminal), MP_ROM_PTR(&supervisor_reset_terminal_obj) }, }; diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 4d41245b3b..579dca49fc 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -220,6 +220,10 @@ mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t *self) { return self->core.bus; } +mp_obj_t common_hal_displayio_display_get_root_group(displayio_display_obj_t *self) { + return self->core.current_group; +} + STATIC const displayio_area_t *_get_refresh_areas(displayio_display_obj_t *self) { if (self->core.full_refresh) { self->core.area.next = NULL; diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 114b274fd1..78e946823b 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -163,12 +163,15 @@ void displayio_display_core_set_rotation(displayio_display_core_t *self, } bool displayio_display_core_show(displayio_display_core_t *self, displayio_group_t *root_group) { - if (root_group == NULL) { - if (!circuitpython_splash.in_group) { - root_group = &circuitpython_splash; - } else if (self->current_group == &circuitpython_splash) { - return true; - } + + if (root_group == NULL) { // set the display to the REPL, reset REPL position and size + circuitpython_splash.in_group = false; + // force the circuit_python_splash out of any group (Note: could cause problems with the parent group) + circuitpython_splash.x = 0; // reset position in case someone moved it. + circuitpython_splash.y = 0; + supervisor_stop_terminal(); + supervisor_start_terminal(self->width, self->height); + root_group = &circuitpython_splash; } if (root_group == self->current_group) { return true; diff --git a/supervisor/shared/display.h b/supervisor/shared/display.h index 8c57a1d579..4110cfe8e4 100644 --- a/supervisor/shared/display.h +++ b/supervisor/shared/display.h @@ -32,7 +32,6 @@ #if CIRCUITPY_TERMINALIO #include "shared-bindings/displayio/Bitmap.h" -#include "shared-bindings/displayio/Group.h" #include "shared-bindings/displayio/TileGrid.h" #include "shared-bindings/fontio/BuiltinFont.h" #include "shared-bindings/terminalio/Terminal.h" @@ -46,7 +45,6 @@ extern const fontio_builtinfont_t supervisor_terminal_font; extern displayio_bitmap_t supervisor_terminal_font_bitmap; extern displayio_tilegrid_t supervisor_terminal_text_grid; extern terminalio_terminal_obj_t supervisor_terminal; -extern displayio_group_t circuitpython_splash; #endif From ff3693238858f022b6e03d6134f5b1c94d94b2e0 Mon Sep 17 00:00:00 2001 From: kmatch <33587466+kmatch98@users.noreply.github.com> Date: Tue, 1 Feb 2022 14:36:25 -0600 Subject: [PATCH 3/5] Update shared-bindings/supervisor/__init__.c Co-authored-by: Scott Shawcroft --- shared-bindings/supervisor/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index f7f21f6ae4..f8a9436ab5 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -301,7 +301,7 @@ STATIC mp_obj_t supervisor_disable_ble_workflow(void) { MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_ble_workflow_obj, supervisor_disable_ble_workflow); //| def reset_terminal(x_pixels: int, y_pixels: int) -> None: -//| """Adjust the pixel dimensions of the REPL console.""" +//| """Reset the CircuitPython serial terminal with new dimensions.""" //| ... //| STATIC mp_obj_t supervisor_reset_terminal(mp_obj_t x_pixels, mp_obj_t y_pixels) { From 89a0f37661a154168a563e57267305bc871d68de Mon Sep 17 00:00:00 2001 From: kmatch <33587466+kmatch98@users.noreply.github.com> Date: Tue, 1 Feb 2022 14:36:35 -0600 Subject: [PATCH 4/5] Update shared-bindings/supervisor/__init__.c Co-authored-by: Scott Shawcroft --- shared-bindings/supervisor/__init__.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index f8a9436ab5..e7c4479d2a 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -305,8 +305,12 @@ MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_ble_workflow_obj, supervisor_disabl //| ... //| STATIC mp_obj_t supervisor_reset_terminal(mp_obj_t x_pixels, mp_obj_t y_pixels) { + #if CIRCUITPY_DISPLAYIO supervisor_stop_terminal(); supervisor_start_terminal(mp_obj_get_int(x_pixels), mp_obj_get_int(y_pixels)); + #else + mp_raise_NotImplementedError(NULL); + #endif return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(supervisor_reset_terminal_obj, supervisor_reset_terminal); From 65837a9941f19a82c4f77436379be8dd1bcc064c Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Wed, 2 Feb 2022 09:23:37 -0600 Subject: [PATCH 5/5] update doc string --- shared-bindings/displayio/Display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index ff08ea201b..f7b3305439 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -444,7 +444,7 @@ const mp_obj_property_t displayio_display_bus_obj = { MP_ROM_NONE}, }; -//| root_group: _Group +//| root_group: Group //| """The root group on the display.""" //| //|