Merge pull request #5954 from kmatch98/repl_wrangler
Expose display’s root_group, add function to resize REPL terminal
This commit is contained in:
commit
4dc9b00221
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,21 @@ 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:
|
||||
//| """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) {
|
||||
#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);
|
||||
|
||||
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 +328,7 @@ 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_reset_terminal), MP_ROM_PTR(&supervisor_reset_terminal_obj) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(supervisor_module_globals, supervisor_module_globals_table);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue