From ccf3ef6a05f3df82503defd08cd28c131d6826ce Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Thu, 24 Apr 2025 14:01:30 +0200 Subject: [PATCH] Add autostart.py mechanism --- install.sh | 1 + main.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 80b9701a..92e32dc4 100755 --- a/install.sh +++ b/install.sh @@ -2,6 +2,7 @@ pkill -f "python.*mpremote" ~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp boot.py :/boot.py ~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp main.py :/main.py +~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp autostart.py :/autostart.py ~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp -r apps :/ ~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp -r lib :/ diff --git a/main.py b/main.py index 3b778a3e..46303ca3 100644 --- a/main.py +++ b/main.py @@ -89,6 +89,7 @@ wifi_icon = lv.label(notification_bar) wifi_icon.set_text(lv.SYMBOL.WIFI) wifi_icon.align(lv.ALIGN.RIGHT_MID, OFFSET_WIFI_ICON, 0) wifi_icon.set_style_text_color(COLOR_TEXT_WHITE, 0) +wifi_icon.add_flag(lv.obj.FLAG.HIDDEN) # Battery icon battery_icon = lv.label(notification_bar) @@ -103,7 +104,7 @@ battery_label.align(lv.ALIGN.RIGHT_MID, 0, 0) battery_label.set_style_text_color(COLOR_TEXT_WHITE, 0) -# Timer to update time every second +# Update time import time def update_time(timer): ticks = time.ticks_ms() @@ -113,6 +114,14 @@ def update_time(timer): milliseconds = ticks % 1000 time_label.set_text(f"{hours:02d}:{minutes:02d}:{seconds:02d}.{milliseconds:03d}") +import wlan +def update_wifi_icon(timer): + if network.WLAN(network.STA_IF).isconnected(): + global wifi_icon + wifi_icon.remove_flag(lv.obj.FLAG.HIDDEN) + else: + wifi_icon.add_flag(lv.obj.FLAG.HIDDEN) + lv.timer_create(update_time, CLOCK_UPDATE_INTERVAL, None) notification_bar.add_event_cb(toggle_drawer, lv.EVENT.CLICKED, None) @@ -275,4 +284,8 @@ def run_app(scriptname, is_file, return_to_launcher=True): def run_launcher(): run_app("/apps/com.example.launcher/assets/main.py", True, False) -run_launcher() +#run_app("/autostart.py", True, subwindow, False) + +execute_script("/autostart.py", True, subwindow, False) + +run_launcher() # not needed because autostart.py will return_to_launcher