diff --git a/preload/menu.py b/preload/menu.py index 7a9ad11b9105a9f79564895d478b60c5fa067903..1ace36aa43f5d5ccfe0106eba245320517263ca6 100644 --- a/preload/menu.py +++ b/preload/menu.py @@ -90,6 +90,24 @@ def usb_mode(disp): os.exit(0) +class SubMenu(simple_menu.Menu): + timeout = 30.0 + + def on_select(self, name, index): + print(name) + if name == "Make Default": + self.disp.clear(color.CHAOSBLUE) + self.disp.print("Making", posx=0, posy=20) + self.disp.print(self.app.name, posx=0, posy=40) + self.disp.print("default", posx=0, posy=60) + self.disp.update() + import config + + config.set_string("default_app", self.app.path) + utime.sleep(1) + self.exit() + + class MainMenu(simple_menu.Menu): timeout = 30.0 @@ -112,6 +130,14 @@ class MainMenu(simple_menu.Menu): utime.sleep(1.0) os.exit(1) + def on_long_select(self, app, index): + print("Long press\n") + if app.path not in ["main.py", "USB_STORAGE_FLAG"]: + # sm = SubMenu(("Make Default", "Fav", "Unfav", "Delete", "Exit")) + sm = SubMenu(("Make Default", "Exit", "", "")) + sm.app = app + sm.run() + def on_timeout(self): try: f = open("main.py")