From 58b5a17eb87d44ce92fa6fd660bd0ca1eb69c4df Mon Sep 17 00:00:00 2001 From: Daniel Hoffend <dh@dotlan.net> Date: Thu, 22 Aug 2019 14:18:41 +0200 Subject: [PATCH] feat(menu) after timeout go back to main.py --- preload/menu.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/preload/menu.py b/preload/menu.py index 94462132..7dd46275 100644 --- a/preload/menu.py +++ b/preload/menu.py @@ -16,6 +16,7 @@ import sys BUTTON_TIMER_POPPED = -1 COLOR1, COLOR2 = (color.CHAOSBLUE_DARK, color.CHAOSBLUE) MAXCHARS = 11 +HOMEAPP = "main.py" def create_folders(): @@ -48,10 +49,10 @@ def list_apps(): # add main application for mainFile in os.listdir("/"): - if mainFile == "main.py": + if mainFile == HOMEAPP: apps.append( [ - "/main.py", + "/%s" % HOMEAPP, { "author": "card10badge Team", "name": "Home", @@ -209,6 +210,7 @@ def main(): timerscrollspeed = 1 timerstartscroll = 5 timercountpopped = 0 + timerinactivity = 100 for ev in button_events(10): if numapps == 0: disp.clear(color.COMMYELLOW) @@ -249,6 +251,16 @@ def main(): ): lineoffset += 1 + if applist[0][0] == "/%s" % HOMEAPP and timercountpopped >= timerinactivity: + print("Inactivity timer popped") + disp.clear().update() + disp.close() + try: + os.exec("/%s" % HOMEAPP) + except OSError as e: + print("Loading failed: ", e) + os.exit(1) + elif ev == buttons.TOP_RIGHT: # Select & start disp.clear().update() -- GitLab