2025-04-29 13:10:38 +02:00
|
|
|
import task_handler
|
2025-06-13 09:02:30 +02:00
|
|
|
import _thread
|
2025-06-19 19:57:29 +02:00
|
|
|
import lvgl as lv
|
2025-05-14 13:35:07 +02:00
|
|
|
|
2025-06-10 11:13:54 +02:00
|
|
|
# Allow LVGL M:/path/to/file or M:relative/path/to/file to work for image set_src etc
|
|
|
|
|
import fs_driver
|
|
|
|
|
fs_drv = lv.fs_drv_t()
|
|
|
|
|
fs_driver.fs_register(fs_drv, 'M')
|
|
|
|
|
|
2025-06-13 14:50:03 +02:00
|
|
|
import mpos.apps
|
2025-06-17 10:45:29 +02:00
|
|
|
import mpos.config
|
2025-05-12 00:05:56 +02:00
|
|
|
import mpos.ui
|
2025-06-06 10:58:27 +02:00
|
|
|
|
2025-06-17 10:45:29 +02:00
|
|
|
prefs = mpos.config.SharedPreferences("com.micropythonos.settings")
|
|
|
|
|
|
|
|
|
|
# Load and set theme:
|
|
|
|
|
theme_light_dark = prefs.get_string("theme_light_dark", "light") # default to a light theme
|
|
|
|
|
theme_dark_bool = ( theme_light_dark == "dark" )
|
|
|
|
|
primary_color = lv.theme_get_color_primary(None)
|
|
|
|
|
color_string = prefs.get_string("theme_primary_color")
|
|
|
|
|
if color_string:
|
2025-06-24 12:33:09 +02:00
|
|
|
try:
|
|
|
|
|
color_string = color_string.replace("0x", "").replace("#", "").strip().lower()
|
|
|
|
|
color_int = int(color_string, 16)
|
|
|
|
|
print(f"Setting primary color: {color_int}")
|
|
|
|
|
primary_color = lv.color_hex(color_int)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"Converting color setting '{color_string}' to lv_color_hex() got exception: {e}")
|
2025-06-17 10:45:29 +02:00
|
|
|
theme = lv.theme_default_init(display._disp_drv, primary_color, lv.color_hex(0xFBDC05), theme_dark_bool, lv.font_montserrat_12)
|
2025-06-06 10:58:27 +02:00
|
|
|
|
|
|
|
|
#display.set_theme(theme)
|
|
|
|
|
|
|
|
|
|
mpos.ui.init_rootscreen()
|
2025-05-12 00:05:56 +02:00
|
|
|
mpos.ui.create_notification_bar()
|
|
|
|
|
mpos.ui.create_drawer(display)
|
2025-05-25 11:36:49 +02:00
|
|
|
mpos.ui.handle_back_swipe()
|
|
|
|
|
mpos.ui.handle_top_swipe()
|
2025-05-14 13:35:07 +02:00
|
|
|
mpos.ui.th = task_handler.TaskHandler(duration=5) # 5ms is recommended for MicroPython+LVGL on desktop
|
2025-04-21 11:37:30 +02:00
|
|
|
|
2025-04-29 17:09:37 +02:00
|
|
|
try:
|
2025-04-30 13:49:42 +02:00
|
|
|
import freezefs_mount_builtin
|
2025-04-29 17:09:37 +02:00
|
|
|
except Exception as e:
|
2025-06-13 14:50:03 +02:00
|
|
|
# This will throw an exception if there is already a "/builtin" folder present
|
2025-05-10 17:27:16 +02:00
|
|
|
print("main.py: WARNING: could not import/run freezefs_mount_builtin: ", e)
|
2025-04-29 17:09:37 +02:00
|
|
|
|
2025-05-11 23:55:18 +02:00
|
|
|
from mpos import apps
|
2025-06-10 17:45:46 +02:00
|
|
|
|
2025-05-24 18:02:18 +02:00
|
|
|
apps.execute_script("builtin/system/button.py", True) # Install button handler through IRQ
|
2025-05-20 21:29:24 +02:00
|
|
|
|
2025-06-13 09:02:30 +02:00
|
|
|
try:
|
|
|
|
|
import mpos.wifi
|
|
|
|
|
import mpos.apps
|
|
|
|
|
_thread.stack_size(mpos.apps.good_stack_size())
|
|
|
|
|
_thread.start_new_thread(mpos.wifi.WifiService.auto_connect, ())
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"Couldn't start mpos.wifi.WifiService.auto_connect thread because: {e}")
|
2025-05-20 21:29:24 +02:00
|
|
|
|
2025-05-11 23:55:18 +02:00
|
|
|
apps.restart_launcher()
|
2025-05-01 15:44:12 +02:00
|
|
|
|
2025-05-11 23:55:18 +02:00
|
|
|
# If we got this far without crashing, then no need to rollback the update:
|
2025-05-10 17:27:16 +02:00
|
|
|
try:
|
|
|
|
|
import ota.rollback
|
|
|
|
|
ota.rollback.cancel()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print("main.py: warning: could not mark this update as valid:", e)
|