Skip to content

Commit 7bfa309

Browse files
Back to .bin because it's a bit faster
1 parent 8e999e1 commit 7bfa309

File tree

1 file changed

+26
-4
lines changed
  • internal_filesystem/apps/com.example.launcher/assets

1 file changed

+26
-4
lines changed

internal_filesystem/apps/com.example.launcher/assets/launcher.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# bin files:
2+
# All icons took: 1085ms
3+
# All icons took: 1051ms
4+
# All icons took: 1032ms
5+
# All icons took: 1118ms
6+
# png files:
7+
# All icons took: 1258ms
8+
# All icons took: 1457ms
9+
# All icons took: 1250ms
10+
11+
112
import uos
213

314
# Create a container for the grid
@@ -12,6 +23,9 @@
1223
iconcont_width = icon_size + 24
1324
iconcont_height = icon_size + label_height
1425

26+
import time
27+
start = time.ticks_ms()
28+
1529
# Get list of app directories
1630
# Should we skip 'Launcher' apps from the list here?
1731
apps_dir = "/apps"
@@ -25,14 +39,21 @@
2539
app_cont.set_style_border_width(0, 0)
2640
app_cont.set_style_pad_all(0, 0)
2741
# Load and display icon
28-
#icon_path = f"{app_dir_fullpath}/res/mipmap-mdpi/launcher_icon.png"
29-
icon_path = "/resources/icon_64x64.bin"
30-
#icon_path = "/resources/icon_64x64.png"
42+
icon_path = f"{app_dir_fullpath}/res/mipmap-mdpi/icon_64x64.bin"
43+
#icon_path = "/resources/default_icon_64x64.bin"
3144
image = lv.image(app_cont)
3245
try:
3346
with open(icon_path, 'rb') as f:
47+
f.seek(12) # first 12 bytes are headers
3448
image_data = f.read()
3549
image_dsc = lv.image_dsc_t({
50+
"header": {
51+
"magic": lv.IMAGE_HEADER_MAGIC,
52+
"w": 64,
53+
"h": 64,
54+
"stride": 64 * 2,
55+
"cf": lv.COLOR_FORMAT.RGB565
56+
},
3657
'data_size': len(image_data),
3758
'data': image_data
3859
})
@@ -51,4 +72,5 @@
5172
label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
5273
app_cont.add_event_cb(lambda e, app_dir_fullpath=app_dir_fullpath: start_app(app_dir_fullpath), lv.EVENT.CLICKED, None)
5374

54-
75+
end = time.ticks_ms()
76+
print(f"Displaying all icons took: {end-start}ms")

0 commit comments

Comments
 (0)