@@ -53,9 +53,7 @@ static bool _suspended = false;
53
53
// Clear if possible, but give up if we can't do it now.
54
54
void supervisor_status_bar_clear (void ) {
55
55
if (!_suspended ) {
56
- supervisor_status_bar_set_update_in_progress (& shared_module_supervisor_status_bar_obj , true);
57
56
serial_write ("\x1b" "]0;" "\x1b" "\\" );
58
- supervisor_status_bar_set_update_in_progress (& shared_module_supervisor_status_bar_obj , false);
59
57
}
60
58
}
61
59
@@ -66,9 +64,31 @@ void supervisor_status_bar_update(void) {
66
64
}
67
65
_forced_dirty = false;
68
66
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 );
70
68
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
72
92
// doesn't get terminated after two following characters and the value is invalid.
73
93
// This is the OSC command to set the title and the icon text. It can be up to 255 characters
74
94
// but some may be cut off.
@@ -91,7 +111,14 @@ void supervisor_status_bar_update(void) {
91
111
// Send string terminator
92
112
serial_write ("\x1b" "\\" );
93
113
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
+
95
122
}
96
123
97
124
static void status_bar_background (void * data ) {
@@ -137,8 +164,5 @@ void supervisor_status_bar_init(void) {
137
164
status_bar_background_cb .fun = status_bar_background ;
138
165
status_bar_background_cb .data = NULL ;
139
166
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 );
144
168
}
0 commit comments