From 3eb69875e97bb234f211a7f584413b4a1492cfab Mon Sep 17 00:00:00 2001 From: moon2 <moon2protonmail@protonmail.com> Date: Tue, 24 Dec 2024 01:27:11 +0100 Subject: [PATCH 1/2] system: add help texts --- python_payload/st3m/main_menu.py | 45 +++++++++++++++++++++--- python_payload/st3m/settings_menu.py | 10 ++++++ python_payload/st3m/ui/elements/menus.py | 9 ++++- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/python_payload/st3m/main_menu.py b/python_payload/st3m/main_menu.py index d24f918248..23c1763cce 100644 --- a/python_payload/st3m/main_menu.py +++ b/python_payload/st3m/main_menu.py @@ -234,12 +234,30 @@ class RestoreMenu(OSMenu): class ApplicationMenu(RestoreMenu): - def __init__(self, items: List[MenuItem]) -> None: + def __init__(self, items: List[MenuItem], name=None) -> None: super().__init__(items) self._button_latch = True self.input.buttons.app.middle.repeat_enable(1000, 1000) self._vm = None self._update_tags() + self._name = name + + def get_help(self): + if self._name is None: + ret = f"This is an app launcher menu." + else: + ret = f"This is the app launcher menu of the {self._name} category." + + ret += "\n\n" + ( + "You can long-press the app button to open a context menu that " + "allows you to delete apps, sort them to the top of the list " + 'with the "<3" option or start them automatically at boot with the ' + '"boot" option.' + ) + + ret += "\n\n" + super().get_help() + + return ret def _update_tags(self): for item in self._items: @@ -359,6 +377,16 @@ class MenuItemApplicationMenu(MenuItemForeground): ctx.restore() +class SystemMenu(RestoreMenu): + def get_help(self): + ret = ( + "This is the system menu of flow3r, where you can access the app store, " + "change settings, update your firmware and more!" + ) + ret += "\n\n" + super().get_help() + return ret + + class MainMenu(SunMenu): def __init__(self, bundles: Optional[list] = None) -> None: if bundles: @@ -369,6 +397,15 @@ class MainMenu(SunMenu): self.load_menu(reload_bundles=False) + def get_help(self): + ret = ( + "Welcome to flow3r! This is the main menu, where you can select different " + "app categories or download apps and updates and change settings " + "in the System option." + ) + ret += "\n\n" + super().get_help() + return ret + def load_menu(self, reload_bundles: bool = True) -> None: """ (Re)loads the menu. @@ -382,10 +419,9 @@ class MainMenu(SunMenu): def build_menu_items(self) -> None: menu_settings = settings.build_menu() - menu_system = RestoreMenu( + menu_system = SystemMenu( [ MenuItemBack(), - MenuItemLaunchPersistentView("About", About), MenuItemForeground("Settings", menu_settings), MenuItemAppLaunch(BundleMetadata("/flash/sys/apps/gr33nhouse")), MenuItemAppLaunch(BundleMetadata("/flash/sys/apps/updat3r")), @@ -394,6 +430,7 @@ class MainMenu(SunMenu): MenuItemAction("Yeet Local Changes", _yeet_local_changes), MenuItemAction("Clear Autostart", _clear_autostart), MenuItemAction("Reboot", machine.reset), + MenuItemLaunchPersistentView("About", About), ], ) @@ -405,7 +442,7 @@ class MainMenu(SunMenu): categories = [ MenuItemApplicationMenu( - kind, ApplicationMenu([MenuItemApplicationBack()] + entries) + kind, ApplicationMenu([MenuItemApplicationBack()] + entries, name=kind) ) for kind in menu_categories if (entries := _get_bundle_menu_entries(self._bundles, kind)) diff --git a/python_payload/st3m/settings_menu.py b/python_payload/st3m/settings_menu.py index aaf0052ef8..70bb54bd27 100644 --- a/python_payload/st3m/settings_menu.py +++ b/python_payload/st3m/settings_menu.py @@ -214,6 +214,16 @@ class SettingsMenu(OSMenu): super().select() self.captouch_active = onoff_touch_os.value + def get_help(self): + ret = ( + "This is the settings menu. Right now it's a bit of a unstructured mix " + "with both user-facing and debug options, apologies! You probably don't " + 'want to use "Show FPS", "Debug: ftop" and "Touch Overlay" in regular ' + "operation as these may slow down or outright block regular functionality. " + ) + ret += "\n\n" + super().get_help() + return ret + SIZE_LARGE = 20 SIZE_SMALL = 15 diff --git a/python_payload/st3m/ui/elements/menus.py b/python_payload/st3m/ui/elements/menus.py index 902b57fa59..92a565b289 100644 --- a/python_payload/st3m/ui/elements/menus.py +++ b/python_payload/st3m/ui/elements/menus.py @@ -45,13 +45,20 @@ class SimpleMenu(MenuController): item.draw(ctx) ctx.restore() + def get_help(self): + ret = ( + "You can scroll though this menu with the app button left and right. To go " + "back use the os button middle, to go forward use the app button middle." + ) + return ret + class OSMenu(SimpleMenu): def get_help(self): if self.captouch_active: ret = ( "You can scroll though this menu by swiping across petals 2 and 8 or by " - "tapping the other top petals or the app button l/r. To go back use " + "tapping the other top petals or the app button left/right. To go back use " "petals 1 or 9 or the os button middle, to go forward use petals 3 and 7 " "or the app button middle." ) -- GitLab From 994b980722d282ab82fb735b71d366863a0c77e4 Mon Sep 17 00:00:00 2001 From: moon2 <moon2protonmail@protonmail.com> Date: Tue, 24 Dec 2024 01:30:29 +0100 Subject: [PATCH 2/2] Touchable, CapScrollController: add deprecation warnings --- python_payload/apps/demo_scroll/__init__.py | 2 ++ python_payload/st3m/input.py | 2 ++ python_payload/st3m/ui/interactions.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/python_payload/apps/demo_scroll/__init__.py b/python_payload/apps/demo_scroll/__init__.py index c6efb3abc7..0fd2231310 100644 --- a/python_payload/apps/demo_scroll/__init__.py +++ b/python_payload/apps/demo_scroll/__init__.py @@ -18,6 +18,8 @@ class ScrollDemo(Application): def __init__(self, app_ctx: ApplicationContext) -> None: super().__init__(app_ctx) + # this class is deprecated, please don't use it for new apps + # check out st3m.ui.widgets.Scroller instead! self.scroll = CapScrollController() def draw(self, ctx: Context) -> None: diff --git a/python_payload/st3m/input.py b/python_payload/st3m/input.py index 00aebf7966..023b540746 100644 --- a/python_payload/st3m/input.py +++ b/python_payload/st3m/input.py @@ -285,6 +285,8 @@ class TouchableState(Enum): class Touchable: """ + Deprecated, don't use for new applications! + A Touchable processes incoming captouch positional state into higher-level simple gestures. diff --git a/python_payload/st3m/ui/interactions.py b/python_payload/st3m/ui/interactions.py index c0fb5fd66e..b316e197c5 100644 --- a/python_payload/st3m/ui/interactions.py +++ b/python_payload/st3m/ui/interactions.py @@ -175,6 +175,8 @@ class ScrollController(st3m.Responder): class CapScrollController: """ + Deprecated, use st3m.ui.widgets.Scroller instead! + A Capacitive Touch based Scroll Controller. You can think of it as a virtual trackball controlled by a touch petal. It -- GitLab