Commit 5f4b1a8e authored by schneider's avatar schneider

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

parent 1887124d
Pipeline #4530 failed with stages
......@@ -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")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment