diff --git a/modules/app_launcher/__init__.py b/modules/app_launcher/__init__.py index 71eb008..c8b22d8 100644 --- a/modules/app_launcher/__init__.py +++ b/modules/app_launcher/__init__.py @@ -7,6 +7,7 @@ import ujson import os import functools +import settings def path_isfile(path): # Wow totally an elegant way to do os.path.isfile... @@ -93,7 +94,20 @@ def choices(self): # Boot entry point def main(self): sys.path[0:0] = ["/apps"] - get_scheduler().main(self) + + if settings.get("uart_menu_app", True): + # Then we run ourselves in a thread and let the terminal be the main thread + import _thread + import tidal + _thread.stack_size(16 * 1024) + menu_thread = _thread.start_new_thread(get_scheduler().main, (self,)) + + from term_menu import UartMenu + term_menu = UartMenu(gts=tidal.system_power_off, pm=None) + term_menu.main() + else: + # Run directly + get_scheduler().main(self) def as_terminal_app(self): while True: @@ -124,6 +138,7 @@ def on_start(self): def on_activate(self): self.update_title(redraw=False) + self.window.set_choices(self.choices, False) super().on_activate() def update_title(self, redraw): @@ -154,6 +169,6 @@ def charge_state_changed(self, charging): get_scheduler().usb_plug_event(charging) def refresh(): - self.update_title(False) - self.window.set_choices(self.choices, False) + self.update_title(redraw=False) + self.window.set_choices(self.choices, redraw=False) self.window.redraw() diff --git a/modules/boot.py b/modules/boot.py index 0e204dd..c0905d3 100644 --- a/modules/boot.py +++ b/modules/boot.py @@ -13,7 +13,6 @@ # Boot to the recovery menu from bootmenu import BootMenu menu = BootMenu() - menu.main() else: import emf_png import lodepng @@ -23,15 +22,7 @@ from app_launcher import Launcher menu = Launcher() -import _thread -import tidal -_thread.stack_size(16 * 1024) -menu_thread = _thread.start_new_thread(menu.main, ()) - # If we've made it to here, any OTA update has _probably_ gone ok... Partition.mark_app_valid_cancel_rollback() -from term_menu import UartMenu -term_menu = UartMenu(gts=tidal.system_power_off, pm=None) -term_menu.main() - +menu.main() diff --git a/modules/settings_app/__init__.py b/modules/settings_app/__init__.py index 234879e..384116d 100644 --- a/modules/settings_app/__init__.py +++ b/modules/settings_app/__init__.py @@ -100,6 +100,9 @@ def fmt_backlight(val): else: return "Min" +def fmt_on_off(val): + return "On" if val else "Off" + class SettingsApp(MenuApp): TITLE = "Settings" @@ -139,6 +142,7 @@ def refresh(self): self.make_choice("Boot sleep delay", None, "boot_nosleep_time", 15, fmt_time, (5, 15, 30, 60, 5*60, 10*60, 30*60, 60*60, 8*60*60)), self.make_choice("USB sleep delay", None, "usb_nosleep_time", 15, fmt_time, (15, 30, 60)), + self.make_choice("UART menu app", None, "uart_menu_app", True, fmt_on_off, (True, False)), ) self.window.set_choices(choices)