@@ -53,9 +53,7 @@ static bool _suspended = false;
5353// Clear if possible, but give up if we can't do it now.
5454void supervisor_status_bar_clear (void ) {
5555 if (!_suspended ) {
56- supervisor_status_bar_set_update_in_progress (& shared_module_supervisor_status_bar_obj , true);
5756 serial_write ("\x1b" "]0;" "\x1b" "\\" );
58- supervisor_status_bar_set_update_in_progress (& shared_module_supervisor_status_bar_obj , false);
5957 }
6058}
6159
@@ -66,9 +64,31 @@ void supervisor_status_bar_update(void) {
6664 }
6765 _forced_dirty = false;
6866
69- supervisor_status_bar_set_update_in_progress (& shared_module_supervisor_status_bar_obj , true );
67+ shared_module_supervisor_status_bar_updated (& shared_module_supervisor_status_bar_obj );
7068
71- // Neighboring "" "" are concatenated by the compiler. Without this separation, the hex code
69+ // Disable status bar console writes if supervisor.status_bar.console is False.
70+ // Also disable if there is no serial connection now. This avoids sending part
71+ // of the status bar update if the serial connection comes up during the update.
72+ bool disable_console_writes =
73+ !shared_module_supervisor_status_bar_get_console (& shared_module_supervisor_status_bar_obj ) ||
74+ !serial_connected ();
75+
76+ // Disable status bar display writes if supervisor.status_bar.display is False.
77+ bool disable_display_writes =
78+ !shared_module_supervisor_status_bar_get_display (& shared_module_supervisor_status_bar_obj );
79+
80+ // Suppress writes to console and/or display if status bar is not enabled for either or both.
81+ bool prev_console_disable ;
82+ bool prev_display_disable ;
83+
84+ if (disable_console_writes ) {
85+ prev_console_disable = serial_console_write_disable (true);
86+ }
87+ if (disable_display_writes ) {
88+ prev_display_disable = serial_display_write_disable (true);
89+ }
90+
91+ // Neighboring "..." "..." are concatenated by the compiler. Without this separation, the hex code
7292 // doesn't get terminated after two following characters and the value is invalid.
7393 // This is the OSC command to set the title and the icon text. It can be up to 255 characters
7494 // but some may be cut off.
@@ -91,7 +111,14 @@ void supervisor_status_bar_update(void) {
91111 // Send string terminator
92112 serial_write ("\x1b" "\\" );
93113
94- supervisor_status_bar_set_update_in_progress (& shared_module_supervisor_status_bar_obj , false);
114+ // Restore writes to console and/or display.
115+ if (disable_console_writes ) {
116+ serial_console_write_disable (prev_console_disable );
117+ }
118+ if (disable_display_writes ) {
119+ serial_display_write_disable (prev_display_disable );
120+ }
121+
95122}
96123
97124static void status_bar_background (void * data ) {
@@ -137,8 +164,5 @@ void supervisor_status_bar_init(void) {
137164 status_bar_background_cb .fun = status_bar_background ;
138165 status_bar_background_cb .data = NULL ;
139166
140- shared_module_supervisor_status_bar_obj .console = true;
141- shared_module_supervisor_status_bar_obj .display = true;
142- shared_module_supervisor_status_bar_obj .update_in_progress = false;
143- shared_module_supervisor_status_bar_obj .written = false;
167+ shared_module_supervisor_status_bar_init (& shared_module_supervisor_status_bar_obj );
144168}
0 commit comments