diff --git a/internal_filesystem/apps/com.example.imutest/res/mipmap-mdpi/icon_64x64.bin b/internal_filesystem/apps/com.example.imutest/res/mipmap-mdpi/icon_64x64.bin index ddf9eb8d..1b456071 100644 Binary files a/internal_filesystem/apps/com.example.imutest/res/mipmap-mdpi/icon_64x64.bin and b/internal_filesystem/apps/com.example.imutest/res/mipmap-mdpi/icon_64x64.bin differ diff --git a/internal_filesystem/apps/com.example.launcher/assets/launcher.py b/internal_filesystem/apps/com.example.launcher/assets/launcher.py index f919f9de..db372140 100644 --- a/internal_filesystem/apps/com.example.launcher/assets/launcher.py +++ b/internal_filesystem/apps/com.example.launcher/assets/launcher.py @@ -29,6 +29,23 @@ iconcont_height = icon_size + label_height import time start = time.ticks_ms() +def load_icon(icon_path): + with open(icon_path, 'rb') as f: + f.seek(12) # first 12 bytes are headers + image_data = f.read() + image_dsc = lv.image_dsc_t({ + "header": { + "magic": lv.IMAGE_HEADER_MAGIC, + "w": 64, + "h": 64, + "stride": 64 * 2, + "cf": lv.COLOR_FORMAT.RGB565A8 + }, + 'data_size': len(image_data), + 'data': image_data + }) + return image_dsc + # Get list of app directories # Should we skip 'Launcher' apps from the list here? apps_dir = "/apps" @@ -43,27 +60,17 @@ for app_dir in [d for d in uos.listdir(apps_dir) if uos.stat(f"{apps_dir}/{d}")[ app_cont.set_style_pad_all(0, 0) # Load and display icon icon_path = f"{app_dir_fullpath}/res/mipmap-mdpi/icon_64x64.bin" - #icon_path = "/resources/default_icon_64x64.bin" image = lv.image(app_cont) try: - with open(icon_path, 'rb') as f: - f.seek(12) # first 12 bytes are headers - image_data = f.read() - image_dsc = lv.image_dsc_t({ - "header": { - "magic": lv.IMAGE_HEADER_MAGIC, - "w": 64, - "h": 64, - "stride": 64 * 2, - "cf": lv.COLOR_FORMAT.RGB565A8 - }, - 'data_size': len(image_data), - 'data': image_data - }) - image.set_src(image_dsc) + image.set_src(load_icon(icon_path)) except Exception as e: - print(f"Error loading icon {icon_path}: {e}") - image.set_src(lv.SYMBOL.STOP) # square block + print(f"Error loading icon {icon_path}: {e} - loading default icon") + icon_path = "/resources/default_icon_64x64.bin" + try: + image.set_src(load_icon(icon_path)) + except Exception as e: + print(f"Error loading default icon {icon_path}: {e} - using symbol") + image.set_src(lv.SYMBOL.STOP) # square block image.align(lv.ALIGN.TOP_MID, 0, 0) image.set_size(icon_size, icon_size) # Create label diff --git a/internal_filesystem/main.py b/internal_filesystem/main.py index fcdb9111..b956e30f 100644 --- a/internal_filesystem/main.py +++ b/internal_filesystem/main.py @@ -349,11 +349,8 @@ def start_app(app_dir, is_launcher=False): start_script_fullpath = f"{app_dir}/{start_script}" execute_script_new_thread(start_script_fullpath, True, is_launcher, True) -def run_launcher(): - start_app("/apps/com.example.launcher", True) - execute_script_new_thread("/autorun.py", True, False, False) -run_launcher() +start_app("/apps/com.example.launcher", True) # If we got this far without crashing, then no need to rollback the update import ota.rollback diff --git a/pngtobin.sh b/pngtobin.sh index fe588746..7a361848 100755 --- a/pngtobin.sh +++ b/pngtobin.sh @@ -1,2 +1,3 @@ #~/sources/lvgl_micropython/lib/lvgl/scripts/LVGLImage.py --ofmt BIN --cf RGB565 -o icon_64x64.bin icon_64x64.png -~/sources/lvgl_micropython/lib/lvgl/scripts/LVGLImage.py --ofmt BIN --cf RGB565 icon_64x64.png +#~/sources/lvgl_micropython/lib/lvgl/scripts/LVGLImage.py --ofmt BIN --cf RGB565 icon_64x64.png +~/sources/lvgl_micropython/lib/lvgl/scripts/LVGLImage.py --ofmt BIN --cf RGB565A8 "$1"