avoid status bar updates immediately after hard restart

This commit is contained in:
Dan Halbert 2022-08-30 22:33:29 -04:00
parent 52080e24eb
commit 2fa671c0f8
8 changed files with 28 additions and 12 deletions

4
main.c
View File

@ -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();

View File

@ -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) {

View File

@ -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;
}

View File

@ -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);

View File

@ -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,
};

View File

@ -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

View File

@ -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) {

View File

@ -28,6 +28,8 @@
#include <stdbool.h>
void supervisor_status_bar_init(void);
void supervisor_status_bar_start(void);
void supervisor_status_bar_suspend(void);
void supervisor_status_bar_resume(void);