avoid status bar updates immediately after hard restart
This commit is contained in:
parent
52080e24eb
commit
2fa671c0f8
4
main.c
4
main.c
|
@ -937,6 +937,10 @@ int __attribute__((used)) main(void) {
|
||||||
|
|
||||||
stack_init();
|
stack_init();
|
||||||
|
|
||||||
|
#if CIRCUITPY_STATUS_BAR
|
||||||
|
supervisor_status_bar_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CIRCUITPY_BLEIO
|
#if CIRCUITPY_BLEIO
|
||||||
// Early init so that a reset press can cause BLE public advertising.
|
// Early init so that a reset press can cause BLE public advertising.
|
||||||
supervisor_bluetooth_init();
|
supervisor_bluetooth_init();
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
//| """Whether status bar information is sent over the console (REPL) serial connection,
|
//| """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``.
|
//| 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.
|
//| 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) {
|
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
|
//| display: bool
|
||||||
//| """Whether status bar information is displayed on the top line of the display.
|
//| """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.
|
//| 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) {
|
STATIC mp_obj_t supervisor_status_bar_get_display(mp_obj_t self_in) {
|
||||||
|
|
|
@ -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) {
|
void shared_module_supervisor_status_bar_set_console(supervisor_status_bar_obj_t *self, bool enabled) {
|
||||||
|
if (self->written) {
|
||||||
// Clear before changing state. If disabling, will remain cleared.
|
// Clear before changing state. If disabling, will remain cleared.
|
||||||
supervisor_status_bar_clear();
|
supervisor_status_bar_clear();
|
||||||
|
}
|
||||||
|
|
||||||
self->console = enabled;
|
self->console = enabled;
|
||||||
|
|
||||||
|
@ -55,8 +57,10 @@ bool shared_module_supervisor_status_bar_get_display(supervisor_status_bar_obj_t
|
||||||
|
|
||||||
#if CIRCUITPY_TERMINALIO
|
#if CIRCUITPY_TERMINALIO
|
||||||
void shared_module_supervisor_status_bar_set_display(supervisor_status_bar_obj_t *self, bool enabled) {
|
void shared_module_supervisor_status_bar_set_display(supervisor_status_bar_obj_t *self, bool enabled) {
|
||||||
terminalio_terminal_clear_status_bar(&supervisor_terminal);
|
if (self->written) {
|
||||||
// Clear before changing state. If disabling, will remain cleared.
|
// Clear before changing state. If disabling, will remain cleared.
|
||||||
|
terminalio_terminal_clear_status_bar(&supervisor_terminal);
|
||||||
|
}
|
||||||
|
|
||||||
self->display = enabled;
|
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) {
|
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;
|
self->update_in_progress = update_in_progress;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ typedef struct {
|
||||||
bool console;
|
bool console;
|
||||||
bool display;
|
bool display;
|
||||||
bool update_in_progress;
|
bool update_in_progress;
|
||||||
|
bool written;
|
||||||
} supervisor_status_bar_obj_t;
|
} supervisor_status_bar_obj_t;
|
||||||
|
|
||||||
extern bool supervisor_status_bar_get_update_in_progress(supervisor_status_bar_obj_t *self);
|
extern bool supervisor_status_bar_get_update_in_progress(supervisor_status_bar_obj_t *self);
|
||||||
|
|
|
@ -34,6 +34,4 @@ supervisor_status_bar_obj_t shared_module_supervisor_status_bar_obj = {
|
||||||
.base = {
|
.base = {
|
||||||
.type = &supervisor_status_bar_type,
|
.type = &supervisor_status_bar_type,
|
||||||
},
|
},
|
||||||
.console = true,
|
|
||||||
.display = true,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -144,10 +144,8 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
|
||||||
scroll_area->full_change = true;
|
scroll_area->full_change = true;
|
||||||
|
|
||||||
common_hal_terminalio_terminal_construct(&supervisor_terminal, scroll_area, &supervisor_terminal_font, status_bar);
|
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.
|
// Do not update status bar until after boot.py has run, in case it is disabled.
|
||||||
supervisor_status_bar_update();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,13 @@ static background_callback_t status_bar_background_cb;
|
||||||
static bool _forced_dirty = false;
|
static bool _forced_dirty = false;
|
||||||
static bool _suspended = 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.
|
// Clear if possible, but give up if we can't do it now.
|
||||||
void supervisor_status_bar_clear(void) {
|
void supervisor_status_bar_clear(void) {
|
||||||
if (!_suspended) {
|
if (!_suspended) {
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
void supervisor_status_bar_init(void);
|
||||||
|
|
||||||
void supervisor_status_bar_start(void);
|
void supervisor_status_bar_start(void);
|
||||||
void supervisor_status_bar_suspend(void);
|
void supervisor_status_bar_suspend(void);
|
||||||
void supervisor_status_bar_resume(void);
|
void supervisor_status_bar_resume(void);
|
||||||
|
|
Loading…
Reference in New Issue