Skip to content

Commit dd37c81

Browse files
authored
Merge pull request #6847 from dhalbert/status-bar-control
Allow enabling and disabling of status bar
2 parents 58b0046 + 2c42a48 commit dd37c81

File tree

25 files changed

+626
-135
lines changed

25 files changed

+626
-135
lines changed

main.c

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
#include "supervisor/shared/stack.h"
5858
#include "supervisor/shared/status_leds.h"
5959
#include "supervisor/shared/tick.h"
60-
#include "supervisor/shared/title_bar.h"
6160
#include "supervisor/shared/traceback.h"
6261
#include "supervisor/shared/translate/translate.h"
6362
#include "supervisor/shared/workflow.h"
@@ -106,6 +105,10 @@
106105
#include "shared-bindings/socketpool/__init__.h"
107106
#endif
108107

108+
#if CIRCUITPY_STATUS_BAR
109+
#include "supervisor/shared/status_bar.h"
110+
#endif
111+
109112
#if CIRCUITPY_USB_HID
110113
#include "shared-module/usb_hid/__init__.h"
111114
#endif
@@ -208,6 +211,7 @@ STATIC const char *_current_executing_filename = NULL;
208211

209212
STATIC pyexec_result_t _exec_result = {0, MP_OBJ_NULL, 0};
210213

214+
#if CIRCUITPY_STATUS_BAR
211215
void supervisor_execution_status(void) {
212216
mp_obj_exception_t *exception = MP_OBJ_TO_PTR(_exec_result.exception);
213217
if (_current_executing_filename != NULL) {
@@ -220,6 +224,7 @@ void supervisor_execution_status(void) {
220224
serial_write_compressed(translate("Done"));
221225
}
222226
}
227+
#endif
223228

224229
#define STRING_LIST(...) {__VA_ARGS__, ""}
225230

@@ -245,13 +250,23 @@ STATIC bool maybe_run_list(const char *const *filenames) {
245250
}
246251
mp_hal_stdout_tx_str(_current_executing_filename);
247252
serial_write_compressed(translate(" output:\n"));
248-
supervisor_title_bar_update();
253+
254+
#if CIRCUITPY_STATUS_BAR
255+
supervisor_status_bar_update();
256+
#endif
257+
249258
pyexec_file(_current_executing_filename, &_exec_result);
259+
250260
#if CIRCUITPY_ATEXIT
251261
shared_module_atexit_execute(&_exec_result);
252262
#endif
263+
253264
_current_executing_filename = NULL;
254-
supervisor_title_bar_update();
265+
266+
#if CIRCUITPY_STATUS_BAR
267+
supervisor_status_bar_update();
268+
#endif
269+
255270
return true;
256271
}
257272

@@ -443,6 +458,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
443458

444459
// Finished executing python code. Cleanup includes filesystem flush and a board reset.
445460
cleanup_after_vm(heap, _exec_result.exception);
461+
_exec_result.exception = NULL;
446462

447463
// If a new next code file was set, that is a reason to keep it (obviously). Stuff this into
448464
// the options because it can be treated like any other reason-for-stickiness bit. The
@@ -749,8 +765,10 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
749765

750766
if (ok_to_run) {
751767
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
752-
// Turn off title bar updates when writing out to boot_out.txt.
753-
supervisor_title_bar_suspend();
768+
#if CIRCUITPY_STATUS_BAR
769+
// Turn off status bar updates when writing out to boot_out.txt.
770+
supervisor_status_bar_suspend();
771+
#endif
754772
vstr_t boot_text;
755773
vstr_init(&boot_text, 512);
756774
boot_output = &boot_text;
@@ -778,7 +796,9 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
778796
FATFS *fs = &vfs->fatfs;
779797

780798
boot_output = NULL;
781-
supervisor_title_bar_resume();
799+
#if CIRCUITPY_STATUS_BAR
800+
supervisor_status_bar_resume();
801+
#endif
782802
bool write_boot_output = true;
783803
FIL boot_output_file;
784804
if (f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) {
@@ -822,6 +842,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
822842
port_post_boot_py(true);
823843

824844
cleanup_after_vm(heap, _exec_result.exception);
845+
_exec_result.exception = NULL;
825846

826847
port_post_boot_py(false);
827848

@@ -854,15 +875,23 @@ STATIC int run_repl(bool first_run) {
854875
status_led_deinit();
855876
#endif
856877
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
857-
supervisor_title_bar_suspend();
878+
#if CIRCUITPY_STATUS_BAR
879+
supervisor_status_bar_suspend();
880+
#endif
858881
exit_code = pyexec_raw_repl();
859-
supervisor_title_bar_resume();
882+
#if CIRCUITPY_STATUS_BAR
883+
supervisor_status_bar_resume();
884+
#endif
860885
} else {
861886
_current_executing_filename = "REPL";
862-
supervisor_title_bar_update();
887+
#if CIRCUITPY_STATUS_BAR
888+
supervisor_status_bar_update();
889+
#endif
863890
exit_code = pyexec_friendly_repl();
864891
_current_executing_filename = NULL;
865-
supervisor_title_bar_update();
892+
#if CIRCUITPY_STATUS_BAR
893+
supervisor_status_bar_update();
894+
#endif
866895
}
867896
#if CIRCUITPY_ATEXIT
868897
pyexec_result_t result;
@@ -910,6 +939,10 @@ int __attribute__((used)) main(void) {
910939

911940
stack_init();
912941

942+
#if CIRCUITPY_STATUS_BAR
943+
supervisor_status_bar_init();
944+
#endif
945+
913946
#if CIRCUITPY_BLEIO
914947
// Early init so that a reset press can cause BLE public advertising.
915948
supervisor_bluetooth_init();
@@ -959,7 +992,10 @@ int __attribute__((used)) main(void) {
959992
run_boot_py(safe_mode);
960993

961994
supervisor_workflow_start();
962-
supervisor_title_bar_start();
995+
996+
#if CIRCUITPY_STATUS_BAR
997+
supervisor_status_bar_request_update(true);
998+
#endif
963999

9641000
// Boot script is finished, so now go into REPL or run code.py.
9651001
int exit_code = PYEXEC_FORCED_EXIT;

ports/espressif/common-hal/wifi/__init__.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ wifi_radio_obj_t common_hal_wifi_radio_obj;
4444
#include "components/log/include/esp_log.h"
4545

4646
#include "supervisor/port.h"
47-
#include "supervisor/shared/title_bar.h"
4847
#include "supervisor/workflow.h"
4948

49+
#if CIRCUITPY_STATUS_BAR
50+
#include "supervisor/shared/status_bar.h"
51+
#endif
52+
5053
#include "esp_ipc.h"
5154

5255
#ifdef CONFIG_IDF_TARGET_ESP32
@@ -56,7 +59,9 @@ wifi_radio_obj_t common_hal_wifi_radio_obj;
5659
static const char *TAG = "CP wifi";
5760

5861
STATIC void schedule_background_on_cp_core(void *arg) {
59-
supervisor_title_bar_request_update(false);
62+
#if CIRCUITPY_STATUS_BAR
63+
supervisor_status_bar_request_update(false);
64+
#endif
6065

6166
// CircuitPython's VM is run in a separate FreeRTOS task from wifi callbacks. So, we have to
6267
// notify the main task every time in case it's waiting for us.

py/circuitpy_defns.mk

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ endif
101101

102102
###
103103
# Select which builtin modules to compile and include.
104+
# Keep alphabetical.
104105

105106
ifeq ($(CIRCUITPY_AESIO),1)
106107
SRC_PATTERNS += aesio/%
@@ -175,29 +176,21 @@ endif
175176
ifeq ($(CIRCUITPY_DOTENV),1)
176177
SRC_PATTERNS += dotenv/%
177178
endif
178-
ifeq ($(CIRCUITPY_PARALLELDISPLAY),1)
179-
SRC_PATTERNS += paralleldisplay/%
180-
endif
181-
ifeq ($(CIRCUITPY_VECTORIO),1)
182-
SRC_PATTERNS += vectorio/%
179+
ifeq ($(CIRCUITPY__EVE),1)
180+
SRC_PATTERNS += _eve/%
183181
endif
184182
ifeq ($(CIRCUITPY_FLOPPYIO),1)
185183
SRC_PATTERNS += floppyio/%
186184
endif
187185
ifeq ($(CIRCUITPY_FRAMEBUFFERIO),1)
188186
SRC_PATTERNS += framebufferio/%
189187
endif
190-
ifeq ($(CIRCUITPY__EVE),1)
191-
SRC_PATTERNS += _eve/%
192-
endif
193188
ifeq ($(CIRCUITPY_FREQUENCYIO),1)
194189
SRC_PATTERNS += frequencyio/%
195190
endif
196-
197191
ifeq ($(CIRCUITPY_FUTURE),1)
198192
SRC_PATTERNS += __future__/%
199193
endif
200-
201194
ifeq ($(CIRCUITPY_GETPASS),1)
202195
SRC_PATTERNS += getpass/%
203196
endif
@@ -237,6 +230,9 @@ endif
237230
ifeq ($(CIRCUITPY_MDNS),1)
238231
SRC_PATTERNS += mdns/%
239232
endif
233+
ifeq ($(CIRCUITPY_MSGPACK),1)
234+
SRC_PATTERNS += msgpack/%
235+
endif
240236
ifeq ($(CIRCUITPY_NEOPIXEL_WRITE),1)
241237
SRC_PATTERNS += neopixel_write/%
242238
endif
@@ -252,6 +248,12 @@ endif
252248
ifeq ($(CIRCUITPY_DUALBANK),1)
253249
SRC_PATTERNS += dualbank/%
254250
endif
251+
ifeq ($(CIRCUITPY_PARALLELDISPLAY),1)
252+
SRC_PATTERNS += paralleldisplay/%
253+
endif
254+
ifeq ($(CIRCUITPY_PEW),1)
255+
SRC_PATTERNS += _pew/%
256+
endif
255257
ifeq ($(CIRCUITPY_PIXELBUF),1)
256258
SRC_PATTERNS += adafruit_pixelbuf/%
257259
endif
@@ -351,8 +353,8 @@ endif
351353
ifeq ($(CIRCUITPY_USTACK),1)
352354
SRC_PATTERNS += ustack/%
353355
endif
354-
ifeq ($(CIRCUITPY_ZLIB),1)
355-
SRC_PATTERNS += zlib/%
356+
ifeq ($(CIRCUITPY_VECTORIO),1)
357+
SRC_PATTERNS += vectorio/%
356358
endif
357359
ifeq ($(CIRCUITPY_VIDEOCORE),1)
358360
SRC_PATTERNS += videocore/%
@@ -363,11 +365,8 @@ endif
363365
ifeq ($(CIRCUITPY_WIFI),1)
364366
SRC_PATTERNS += wifi/%
365367
endif
366-
ifeq ($(CIRCUITPY_PEW),1)
367-
SRC_PATTERNS += _pew/%
368-
endif
369-
ifeq ($(CIRCUITPY_MSGPACK),1)
370-
SRC_PATTERNS += msgpack/%
368+
ifeq ($(CIRCUITPY_ZLIB),1)
369+
SRC_PATTERNS += zlib/%
371370
endif
372371

373372
# All possible sources are listed here, and are filtered by SRC_PATTERNS in SRC_COMMON_HAL
@@ -511,6 +510,7 @@ $(filter $(SRC_PATTERNS), \
511510
qrio/PixelPolicy.c \
512511
qrio/QRInfo.c \
513512
supervisor/RunReason.c \
513+
supervisor/StatusBar.c \
514514
wifi/AuthMode.c \
515515
wifi/Packet.c \
516516
)
@@ -611,6 +611,8 @@ SRC_SHARED_MODULE_ALL = \
611611
socket/__init__.c \
612612
storage/__init__.c \
613613
struct/__init__.c \
614+
supervisor/__init__.c \
615+
supervisor/StatusBar.c \
614616
synthio/MidiTrack.c \
615617
synthio/__init__.c \
616618
terminalio/Terminal.c \

0 commit comments

Comments
 (0)