diff --git a/main.c b/main.c index 4c3bae6948..804b229861 100644 --- a/main.c +++ b/main.c @@ -937,6 +937,10 @@ int __attribute__((used)) main(void) { stack_init(); + #if CIRCUITPY_STATUS_BAR + supervisor_status_bar_init(); + #endif + #if CIRCUITPY_BLEIO // Early init so that a reset press can cause BLE public advertising. supervisor_bluetooth_init(); diff --git a/shared-bindings/supervisor/StatusBar.c b/shared-bindings/supervisor/StatusBar.c index 3ee9ae9de4..ad6bfb401c 100644 --- a/shared-bindings/supervisor/StatusBar.c +++ b/shared-bindings/supervisor/StatusBar.c @@ -52,7 +52,7 @@ //| """Whether status bar information is sent over the console (REPL) serial connection, //| using OSC terminal escape codes that change the terminal's title. Default is ``True``. //| If set to ``False``, status bar will be cleared and then disabled. -//| May be set in ``boot.py`` or later. +//| May be set in ``boot.py`` or later. Persists across soft restarts. //| """ //| STATIC mp_obj_t supervisor_status_bar_get_console(mp_obj_t self_in) { @@ -83,7 +83,8 @@ MP_PROPERTY_GETSET(supervisor_status_bar_console_obj, //| display: bool //| """Whether status bar information is displayed on the top line of the display. //| Default is ``True``. If set to ``False``, status bar will be cleared and then disabled. -//| May be set in ``boot.py`` or later. Not available if `terminalio` is not available. +//| May be set in ``boot.py`` or later. Persists across soft restarts. +//| Not available if `terminalio` is not available. //| """ //| STATIC mp_obj_t supervisor_status_bar_get_display(mp_obj_t self_in) { diff --git a/shared-module/supervisor/StatusBar.c b/shared-module/supervisor/StatusBar.c index cb0882fd44..2b2dda9ecf 100644 --- a/shared-module/supervisor/StatusBar.c +++ b/shared-module/supervisor/StatusBar.c @@ -40,8 +40,10 @@ bool shared_module_supervisor_status_bar_get_console(supervisor_status_bar_obj_t } void shared_module_supervisor_status_bar_set_console(supervisor_status_bar_obj_t *self, bool enabled) { - // Clear before changing state. If disabling, will remain cleared. - supervisor_status_bar_clear(); + if (self->written) { + // Clear before changing state. If disabling, will remain cleared. + supervisor_status_bar_clear(); + } self->console = enabled; @@ -55,8 +57,10 @@ bool shared_module_supervisor_status_bar_get_display(supervisor_status_bar_obj_t #if CIRCUITPY_TERMINALIO void shared_module_supervisor_status_bar_set_display(supervisor_status_bar_obj_t *self, bool enabled) { - terminalio_terminal_clear_status_bar(&supervisor_terminal); - // Clear before changing state. If disabling, will remain cleared. + if (self->written) { + // Clear before changing state. If disabling, will remain cleared. + terminalio_terminal_clear_status_bar(&supervisor_terminal); + } self->display = enabled; @@ -70,5 +74,6 @@ bool supervisor_status_bar_get_update_in_progress(supervisor_status_bar_obj_t *s } void supervisor_status_bar_set_update_in_progress(supervisor_status_bar_obj_t *self, bool update_in_progress) { + self->written = true; self->update_in_progress = update_in_progress; } diff --git a/shared-module/supervisor/StatusBar.h b/shared-module/supervisor/StatusBar.h index 88bf965864..bc80d7825f 100644 --- a/shared-module/supervisor/StatusBar.h +++ b/shared-module/supervisor/StatusBar.h @@ -34,6 +34,7 @@ typedef struct { bool console; bool display; bool update_in_progress; + bool written; } supervisor_status_bar_obj_t; extern bool supervisor_status_bar_get_update_in_progress(supervisor_status_bar_obj_t *self); diff --git a/shared-module/supervisor/__init__.c b/shared-module/supervisor/__init__.c index 7921eec46a..05e23e26e7 100644 --- a/shared-module/supervisor/__init__.c +++ b/shared-module/supervisor/__init__.c @@ -34,6 +34,4 @@ supervisor_status_bar_obj_t shared_module_supervisor_status_bar_obj = { .base = { .type = &supervisor_status_bar_type, }, - .console = true, - .display = true, }; diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c index f573a92271..8ed2f5c17e 100644 --- a/supervisor/shared/display.c +++ b/supervisor/shared/display.c @@ -144,10 +144,8 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { scroll_area->full_change = true; common_hal_terminalio_terminal_construct(&supervisor_terminal, scroll_area, &supervisor_terminal_font, status_bar); - #if CIRCUITPY_STATUS_BAR - // Update the status bar since we just cleared the terminal. - supervisor_status_bar_update(); - #endif + + // Do not update status bar until after boot.py has run, in case it is disabled. } #endif diff --git a/supervisor/shared/status_bar.c b/supervisor/shared/status_bar.c index 2adc065e04..0607696d3e 100644 --- a/supervisor/shared/status_bar.c +++ b/supervisor/shared/status_bar.c @@ -50,6 +50,13 @@ static background_callback_t status_bar_background_cb; static bool _forced_dirty = false; static bool _suspended = false; +void supervisor_status_bar_init(void) { + shared_module_supervisor_status_bar_obj.console = true; + shared_module_supervisor_status_bar_obj.display = true; + shared_module_supervisor_status_bar_obj.update_in_progress = false; + shared_module_supervisor_status_bar_obj.written = false; +} + // Clear if possible, but give up if we can't do it now. void supervisor_status_bar_clear(void) { if (!_suspended) { diff --git a/supervisor/shared/status_bar.h b/supervisor/shared/status_bar.h index db2c442276..062012b545 100644 --- a/supervisor/shared/status_bar.h +++ b/supervisor/shared/status_bar.h @@ -28,6 +28,8 @@ #include +void supervisor_status_bar_init(void); + void supervisor_status_bar_start(void); void supervisor_status_bar_suspend(void); void supervisor_status_bar_resume(void);