Skip to content
Snippets Groups Projects
Commit 5f4b1a8e authored by schneider's avatar schneider
Browse files

feat(menu): Add a sub menu to set the default app via a long press

parent 1887124d
No related branches found
No related tags found
1 merge request!375Default main app selector
Pipeline #4530 failed
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment