41
41
#include "supervisor/shared/bluetooth/serial.h"
42
42
#endif
43
43
44
- #if CIRCUITPY_STATUS_BAR
45
- #include "shared-bindings/supervisor/__init__.h"
46
- #include "shared-bindings/supervisor/StatusBar.h"
47
- #endif
48
-
49
44
#if CIRCUITPY_USB
50
45
#include "tusb.h"
51
46
#endif
@@ -72,10 +67,10 @@ bool tud_vendor_connected(void);
72
67
#endif
73
68
74
69
// Set to true to temporarily discard writes to the console only.
75
- static bool _console_write_disabled ;
70
+ static bool _serial_console_write_disabled ;
76
71
77
72
// Set to true to temporarily discard writes to the display terminal only.
78
- static bool _display_write_disabled ;
73
+ static bool _serial_display_write_disabled ;
79
74
80
75
#if CIRCUITPY_CONSOLE_UART
81
76
STATIC void console_uart_print_strn (void * env , const char * str , size_t len ) {
@@ -283,39 +278,21 @@ bool serial_bytes_available(void) {
283
278
return false;
284
279
}
285
280
286
- #if CIRCUITPY_STATUS_BAR
287
- // Detect when USB is down when the status bar write starts. If USB comes up in the middle of writing
288
- // the status bar, we want to the skip the rest so so junk doesn't get written out.
289
- static bool ignore_rest_of_status_bar_update = false;
290
- #endif
291
-
292
281
void serial_write_substring (const char * text , uint32_t length ) {
293
282
if (length == 0 ) {
294
283
return ;
295
284
}
296
285
297
286
#if CIRCUITPY_TERMINALIO
298
287
int errcode ;
299
- // If the status bar is disabled for the display, common_hal_terminalio_terminal_write() will not write it.
300
- common_hal_terminalio_terminal_write (& supervisor_terminal , (const uint8_t * )text , length , & errcode );
301
- #endif
302
-
303
- #if CIRCUITPY_STATUS_BAR
304
- // If the status bar is disabled for the console, skip writing out the OSC sequence.
305
- if (supervisor_status_bar_get_update_in_progress (& shared_module_supervisor_status_bar_obj )) {
306
- if (!shared_module_supervisor_status_bar_get_console (& shared_module_supervisor_status_bar_obj )) {
307
- // Console status bar disabled, so just return.
308
- return ;
309
- }
310
- } else {
311
- // Status bar update is not in progress, so clear this history flag (will get cleared repeatedly).
312
- ignore_rest_of_status_bar_update = false;
288
+ if (!_serial_display_write_disabled ) {
289
+ common_hal_terminalio_terminal_write (& supervisor_terminal , (const uint8_t * )text , length , & errcode );
313
290
}
291
+ #endif
314
292
315
- if (ignore_rest_of_status_bar_update ) {
293
+ if (_serial_console_write_disabled ) {
316
294
return ;
317
295
}
318
- #endif
319
296
320
297
#if CIRCUITPY_USB_VENDOR
321
298
if (tud_vendor_connected ()) {
@@ -355,13 +332,6 @@ void serial_write_substring(const char *text, uint32_t length) {
355
332
usb_background ();
356
333
}
357
334
}
358
- #if CIRCUITPY_STATUS_BAR
359
- else {
360
- // USB was not connected for the first part of the status bar update. Ignore the rest
361
- // so we don't send the remaining part of the OSC sequence if USB comes up later.
362
- ignore_rest_of_status_bar_update = true;
363
- }
364
- #endif
365
335
#endif
366
336
367
337
port_serial_write_substring (text , length );
@@ -371,10 +341,14 @@ void serial_write(const char *text) {
371
341
serial_write_substring (text , strlen (text ));
372
342
}
373
343
374
- void serial_console_write_disable (bool disabled ) {
344
+ bool serial_console_write_disable (bool disabled ) {
345
+ bool now = _serial_console_write_disabled ;
375
346
_serial_console_write_disabled = disabled ;
347
+ return now ;
376
348
}
377
349
378
- void serial_display_write_disable (bool disabled ) {
350
+ bool serial_display_write_disable (bool disabled ) {
351
+ bool now = _serial_display_write_disabled ;
379
352
_serial_display_write_disabled = disabled ;
353
+ return now ;
380
354
}
0 commit comments