|
| 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 | + |
1 | 12 | import uos |
2 | 13 |
|
3 | 14 | # Create a container for the grid |
|
12 | 23 | iconcont_width = icon_size + 24 |
13 | 24 | iconcont_height = icon_size + label_height |
14 | 25 |
|
| 26 | +import time |
| 27 | +start = time.ticks_ms() |
| 28 | + |
15 | 29 | # Get list of app directories |
16 | 30 | # Should we skip 'Launcher' apps from the list here? |
17 | 31 | apps_dir = "/apps" |
|
25 | 39 | app_cont.set_style_border_width(0, 0) |
26 | 40 | app_cont.set_style_pad_all(0, 0) |
27 | 41 | # 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" |
31 | 44 | image = lv.image(app_cont) |
32 | 45 | try: |
33 | 46 | with open(icon_path, 'rb') as f: |
| 47 | + f.seek(12) # first 12 bytes are headers |
34 | 48 | image_data = f.read() |
35 | 49 | 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 | + }, |
36 | 57 | 'data_size': len(image_data), |
37 | 58 | 'data': image_data |
38 | 59 | }) |
|
51 | 72 | label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) |
52 | 73 | app_cont.add_event_cb(lambda e, app_dir_fullpath=app_dir_fullpath: start_app(app_dir_fullpath), lv.EVENT.CLICKED, None) |
53 | 74 |
|
54 | | - |
| 75 | +end = time.ticks_ms() |
| 76 | +print(f"Displaying all icons took: {end-start}ms") |
0 commit comments