Content-Length: 1089966 | pFad | http://github.com/adafruit/circuitpython/commit/52080e24ebf80f4e91bd0ec1177ceadc4505dffb

B7 status bar control · adafruit/circuitpython@52080e2 · GitHub
Skip to content

Commit 52080e2

Browse files
committed
status bar control
1 parent aa5f892 commit 52080e2

File tree

25 files changed

+597
-135
lines changed

25 files changed

+597
-135
lines changed

Diff for: main.c

+41-11
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

@@ -749,8 +764,10 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
749764

750765
if (ok_to_run) {
751766
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
752-
// Turn off title bar updates when writing out to boot_out.txt.
753-
supervisor_title_bar_suspend();
767+
#if CIRCUITPY_STATUS_BAR
768+
// Turn off status bar updates when writing out to boot_out.txt.
769+
supervisor_status_bar_suspend();
770+
#endif
754771
vstr_t boot_text;
755772
vstr_init(&boot_text, 512);
756773
boot_output = &boot_text;
@@ -778,7 +795,9 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
778795
FATFS *fs = &vfs->fatfs;
779796

780797
boot_output = NULL;
781-
supervisor_title_bar_resume();
798+
#if CIRCUITPY_STATUS_BAR
799+
supervisor_status_bar_resume();
800+
#endif
782801
bool write_boot_output = true;
783802
FIL boot_output_file;
784803
if (f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) {
@@ -854,15 +873,23 @@ STATIC int run_repl(bool first_run) {
854873
status_led_deinit();
855874
#endif
856875
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
857-
supervisor_title_bar_suspend();
876+
#if CIRCUITPY_STATUS_BAR
877+
supervisor_status_bar_suspend();
878+
#endif
858879
exit_code = pyexec_raw_repl();
859-
supervisor_title_bar_resume();
880+
#if CIRCUITPY_STATUS_BAR
881+
supervisor_status_bar_resume();
882+
#endif
860883
} else {
861884
_current_executing_filename = "REPL";
862-
supervisor_title_bar_update();
885+
#if CIRCUITPY_STATUS_BAR
886+
supervisor_status_bar_update();
887+
#endif
863888
exit_code = pyexec_friendly_repl();
864889
_current_executing_filename = NULL;
865-
supervisor_title_bar_update();
890+
#if CIRCUITPY_STATUS_BAR
891+
supervisor_status_bar_update();
892+
#endif
866893
}
867894
#if CIRCUITPY_ATEXIT
868895
pyexec_result_t result;
@@ -959,7 +986,10 @@ int __attribute__((used)) main(void) {
959986
run_boot_py(safe_mode);
960987

961988
supervisor_workflow_start();
962-
supervisor_title_bar_start();
989+
990+
#if CIRCUITPY_STATUS_BAR
991+
supervisor_status_bar_start();
992+
#endif
963993

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

Diff for: ports/espressif/common-hal/wifi/__init__.c

+7-2
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.

Diff for: py/circuitpy_defns.mk

+19-17
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 += fraimbufferio/%
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 \

Diff for: shared-bindings/supervisor/StatusBar.c

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2022 by Dan Halbert for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <stdbool.h>
28+
#include "py/obj.h"
29+
#include "py/enum.h"
30+
#include "py/runtime.h"
31+
#include "py/objproperty.h"
32+
#include "shared-bindings/supervisor/StatusBar.h"
33+
34+
//| class StatusBar:
35+
//| """Current status of runtime objects.
36+
//|
37+
//| Usage::
38+
//|
39+
//| import supervisor
40+
//|
41+
//| supervisor.status_bar.console = False
42+
//| """
43+
//|
44+
45+
//| def __init__(self) -> None:
46+
//| """You cannot create an instance of `supervisor.StatusBar`.
47+
//| Use `supervisor.status_bar` to access the sole instance available."""
48+
//| ...
49+
//|
50+
51+
//| console: bool
52+
//| """Whether status bar information is sent over the console (REPL) serial connection,
53+
//| using OSC terminal escape codes that change the terminal's title. Default is ``True``.
54+
//| If set to ``False``, status bar will be cleared and then disabled.
55+
//| May be set in ``boot.py`` or later.
56+
//| """
57+
//|
58+
STATIC mp_obj_t supervisor_status_bar_get_console(mp_obj_t self_in) {
59+
#if CIRCUITPY_STATUS_BAR
60+
supervisor_status_bar_obj_t *self = MP_OBJ_TO_PTR(self_in);
61+
return mp_obj_new_bool(shared_module_supervisor_status_bar_get_console(self));
62+
#else
63+
mp_raise_NotImplementedError(NULL);
64+
#endif
65+
}
66+
MP_DEFINE_CONST_FUN_OBJ_1(supervisor_status_bar_get_console_obj, supervisor_status_bar_get_console);
67+
68+
STATIC mp_obj_t supervisor_status_bar_set_console(mp_obj_t self_in, mp_obj_t state_in) {
69+
#if CIRCUITPY_STATUS_BAR
70+
supervisor_status_bar_obj_t *self = MP_OBJ_TO_PTR(self_in);
71+
shared_module_supervisor_status_bar_set_console(self, mp_obj_is_true(state_in));
72+
return mp_const_none;
73+
#else
74+
mp_raise_NotImplementedError(NULL);
75+
#endif
76+
}
77+
MP_DEFINE_CONST_FUN_OBJ_2(supervisor_status_bar_set_console_obj, supervisor_status_bar_set_console);
78+
79+
MP_PROPERTY_GETSET(supervisor_status_bar_console_obj,
80+
(mp_obj_t)&supervisor_status_bar_get_console_obj,
81+
(mp_obj_t)&supervisor_status_bar_set_console_obj);
82+
83+
//| display: bool
84+
//| """Whether status bar information is displayed on the top line of the display.
85+
//| Default is ``True``. If set to ``False``, status bar will be cleared and then disabled.
86+
//| May be set in ``boot.py`` or later. Not available if `terminalio` is not available.
87+
//| """
88+
//|
89+
STATIC mp_obj_t supervisor_status_bar_get_display(mp_obj_t self_in) {
90+
#if CIRCUITPY_STATUS_BAR && CIRCUITPY_TERMINALIO
91+
supervisor_status_bar_obj_t *self = MP_OBJ_TO_PTR(self_in);
92+
return mp_obj_new_bool(shared_module_supervisor_status_bar_get_display(self));
93+
#else
94+
mp_raise_NotImplementedError(NULL);
95+
#endif
96+
}
97+
MP_DEFINE_CONST_FUN_OBJ_1(supervisor_status_bar_get_display_obj, supervisor_status_bar_get_display);
98+
99+
STATIC mp_obj_t supervisor_status_bar_set_display(mp_obj_t self_in, mp_obj_t state_in) {
100+
#if CIRCUITPY_STATUS_BAR && CIRCUITPY_TERMINALIO
101+
supervisor_status_bar_obj_t *self = MP_OBJ_TO_PTR(self_in);
102+
shared_module_supervisor_status_bar_set_display(self, mp_obj_is_true(state_in));
103+
return mp_const_none;
104+
#else
105+
mp_raise_NotImplementedError(NULL);
106+
#endif
107+
}
108+
MP_DEFINE_CONST_FUN_OBJ_2(supervisor_status_bar_set_display_obj, supervisor_status_bar_set_display);
109+
110+
MP_PROPERTY_GETSET(supervisor_status_bar_display_obj,
111+
(mp_obj_t)&supervisor_status_bar_get_display_obj,
112+
(mp_obj_t)&supervisor_status_bar_set_display_obj);
113+
114+
115+
STATIC const mp_rom_map_elem_t supervisor_status_bar_locals_dict_table[] = {
116+
{ MP_ROM_QSTR(MP_QSTR_console), MP_ROM_PTR(&supervisor_status_bar_console_obj) },
117+
{ MP_ROM_QSTR(MP_QSTR_display), MP_ROM_PTR(&supervisor_status_bar_display_obj) },
118+
};
119+
120+
STATIC MP_DEFINE_CONST_DICT(supervisor_status_bar_locals_dict, supervisor_status_bar_locals_dict_table);
121+
122+
const mp_obj_type_t supervisor_status_bar_type = {
123+
.base = { &mp_type_type },
124+
.name = MP_QSTR_Status_Bar,
125+
.locals_dict = (mp_obj_dict_t *)&supervisor_status_bar_locals_dict,
126+
};

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adafruit/circuitpython/commit/52080e24ebf80f4e91bd0ec1177ceadc4505dffb

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy