Skip to content

Commit 8693f07

Browse files
Restart launcher after appstore
1 parent 855d54e commit 8693f07

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pushd internal_filesystem/
44

55
~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp boot.py :/boot.py
66
~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp main.py :/main.py
7-
~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp autorun.py :/autorun.py
7+
#~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp autorun.py :/autorun.py
88

99
~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp -r apps :/
1010
~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp -r lib :/

internal_filesystem/builtin/apps/com.example.appstore/assets/appstore.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,5 +341,7 @@ def back_to_main(event):
341341
import time
342342
while mainscreen == lv.screen_active() or app_detail_screen == lv.screen_active():
343343
time.sleep_ms(100)
344+
print("User navigated away from the appstore, restarting launcher to refresh...")
345+
restart_launcher() # refresh the launcher
344346

345347
print("appstore.py ending")
-13.9 KB
Loading

internal_filesystem/main.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import lvgl as lv
22
import task_handler
3+
import machine
34

45
# Constants
56
CURRENT_VERSION = "0.0.1"
@@ -192,19 +193,19 @@ def wifi_event(e):
192193

193194
wifi_btn.add_event_cb(wifi_event,lv.EVENT.CLICKED,None)
194195
#
195-
settings_btn=lv.button(drawer)
196-
settings_btn.set_size(BUTTON_WIDTH,BUTTON_HEIGHT)
197-
settings_btn.align(lv.ALIGN.RIGHT_MID,-PADDING_MEDIUM,0)
198-
settings_btn.set_style_bg_color(COLOR_DRAWER_BUTTON_BG,0)
199-
settings_label=lv.label(settings_btn)
200-
settings_label.set_text(lv.SYMBOL.SETTINGS+" Settings")
201-
settings_label.center()
202-
settings_label.set_style_text_color(COLOR_DRAWER_BUTTONTEXT,0)
203-
def settings_event(e):
204-
global drawer_open
205-
close_drawer()
206-
207-
settings_btn.add_event_cb(settings_event,lv.EVENT.CLICKED,None)
196+
#settings_btn=lv.button(drawer)
197+
#settings_btn.set_size(BUTTON_WIDTH,BUTTON_HEIGHT)
198+
#settings_btn.align(lv.ALIGN.RIGHT_MID,-PADDING_MEDIUM,0)
199+
#settings_btn.set_style_bg_color(COLOR_DRAWER_BUTTON_BG,0)
200+
#settings_label=lv.label(settings_btn)
201+
#settings_label.set_text(lv.SYMBOL.SETTINGS+" Settings")
202+
#settings_label.center()
203+
#settings_label.set_style_text_color(COLOR_DRAWER_BUTTONTEXT,0)
204+
#def settings_event(e):
205+
# global drawer_open
206+
# close_drawer()
207+
208+
#settings_btn.add_event_cb(settings_event,lv.EVENT.CLICKED,None)
208209
#
209210
launcher_btn=lv.button(drawer)
210211
launcher_btn.set_size(BUTTON_WIDTH,BUTTON_HEIGHT)
@@ -224,7 +225,7 @@ def launcher_event(e):
224225
#
225226
restart_btn=lv.button(drawer)
226227
restart_btn.set_size(BUTTON_WIDTH,BUTTON_HEIGHT)
227-
restart_btn.align(lv.ALIGN.BOTTOM_RIGHT,-PADDING_MEDIUM,-PADDING_MEDIUM)
228+
restart_btn.align(lv.ALIGN.RIGHT_MID,-PADDING_MEDIUM,0)
228229
restart_btn.set_style_bg_color(COLOR_DRAWER_BUTTON_BG,0)
229230
restart_label=lv.label(restart_btn)
230231
restart_label.set_text(lv.SYMBOL.POWER+" Reset")
@@ -307,6 +308,7 @@ def execute_script(script_source, is_file, is_launcher, is_graphical):
307308
'subwindow': subwindow,
308309
'start_app': start_app, # for launcher apps
309310
'parse_manifest': parse_manifest, # for launcher apps
311+
'restart_launcher': restart_launcher, # for appstore apps
310312
'__name__': "__main__"
311313
}
312314
print(f"Thread {thread_id}: starting script")
@@ -352,6 +354,18 @@ def start_app(app_dir, is_launcher=False):
352354
start_script_fullpath = f"{app_dir}/{start_script}"
353355
execute_script_new_thread(start_script_fullpath, True, is_launcher, True)
354356

357+
358+
def restart_launcher():
359+
# The launcher might have been updated from the builtin one, so check that:
360+
custom_launcher = "/apps/com.example.launcher"
361+
builtin_launcher = "/builtin/apps/com.example.launcher"
362+
try:
363+
stat = uos.stat(custom_launcher)
364+
start_app(custom_launcher, True)
365+
except OSError:
366+
start_app(builtin_launcher, True)
367+
368+
355369
# Execute this if it exists
356370
execute_script_new_thread("/autorun.py", True, False, False)
357371

@@ -376,14 +390,7 @@ def start_app(app_dir, is_launcher=False):
376390
except OSError:
377391
print("Couldn't execute {builtin_auto_connect}, continuing...")
378392

379-
# The launcher might have been updated from the builtin one, so check that:
380-
custom_launcher = "/apps/com.example.launcher"
381-
builtin_launcher = "/builtin/apps/com.example.launcher"
382-
try:
383-
stat = uos.stat(custom_launcher)
384-
start_app(custom_launcher, True)
385-
except OSError:
386-
start_app(builtin_launcher, True)
393+
restart_launcher()
387394

388395
# If we got this far without crashing, then no need to rollback the update
389396
import ota.rollback

0 commit comments

Comments
 (0)