Skip to content

Commit 4680a7a

Browse files
Fix image viewer by adding filesystem driver
1 parent 863d5be commit 4680a7a

File tree

6 files changed

+36
-17
lines changed

6 files changed

+36
-17
lines changed

draft_code/saved_functions.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,28 @@ def show_block_height():
8989

9090

9191

92-
9392
# Create file explorer widget
94-
file_explorer = lv.file_explorer(subwindow)
95-
file_explorer.set_root_path("/")
96-
file_explorer.explorer_open_dir('/')
93+
file_explorer = lv.file_explorer(lv.screen_active())
94+
#file_explorer.set_root_path("/")
95+
#file_explorer.explorer_open_dir('/')
96+
file_explorer.explorer_open_dir('P:.') # POSIX works, fs_driver doesn't because it doesn't have dir_open, dir_read, dir_close
97+
#file_explorer.explorer_open_dir('S:/')
9798
file_explorer.set_size(210, 210)
98-
file_explorer.set_mode(lv.FILE_EXPLORER.MODE.DEFAULT) # Default browsing mode
99-
file_explorer.set_sort(lv.FILE_EXPLORER.SORT.NAME_ASC) # Sort by name, ascending
99+
#file_explorer.set_mode(lv.FILE_EXPLORER.MODE.DEFAULT) # Default browsing mode
100+
#file_explorer.set_sort(lv.FILE_EXPLORER.SORT.NAME_ASC) # Sort by name, ascending
100101
file_explorer.align(lv.ALIGN.CENTER, 0, 0)
101102
def file_explorer_event_cb(e):
102103
code = e.get_code()
104+
print(f"file_explorer_event_cb {code}")
103105
obj = e.get_target_obj()
104106
if code == lv.EVENT.VALUE_CHANGED:
105107
#selected_path = obj.get_selected_file_name()
106-
selected_path = file_explorer.explorer_get_selected_file_name
108+
selected_path = file_explorer.explorer_get_selected_file_name()
107109
print("Selected:", selected_path)
108-
if obj.is_selected_dir():
109-
print("This is a directory")
110-
else:
111-
print("This is a file")
110+
#if obj.is_selected_dir():
111+
# print("This is a directory")
112+
#else:
113+
# print("This is a file")
112114

113115

114116
# Attach event callback
@@ -664,3 +666,14 @@ def print_fps():
664666

665667
import _thread
666668
_thread.stack_size(0)
669+
670+
671+
672+
import fs_driver
673+
fs_drv = lv.fs_drv_t()
674+
fs_driver.fs_register(fs_drv, 'M')
675+
676+
img = lv.image(lv.screen_active())
677+
#img.set_src("P:/data/images/icon_64x64.jpg")
678+
img.set_src("P:../artwork/icon_64x64.jpg")
679+

internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
class ImageView(Activity):
77

88
#imagedir = "../icons/"
9-
imagedir = "../artwork/"
9+
#imagedir = "../artwork/"
10+
imagedir = "data/images"
1011
#imagedir = "/home/user/Downloads/"
1112
#imagedir = "/home/user/images/"
1213
images = []
@@ -82,13 +83,13 @@ def show_next_image(self, event=None):
8283
def show_image(self, name):
8384
try:
8485
self.label.set_text(name)
85-
self.image.set_src(f"P:{name}")
86+
self.image.set_src(f"M:{name}")
8687
print(f"the LVGL image has size: {self.image.get_width()}x{self.image.get_height()}")
8788
header = lv.image_header_t()
8889
self.image.decoder_get_info(self.image.get_src(), header)
8990
print(f"the real image has size: {header.w}x{header.h}")
9091
#image.set_size(128, 128)
91-
self.image.set_scale(512)
92+
#self.image.set_scale(512)
9293
print(f"after set_scale, the LVGL image has size: {self.image.get_width()}x{self.image.get_height()}")
9394
except Exception as e:
9495
print(f"show_image got exception: {e}")
-2.07 KB
Loading

internal_filesystem/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import task_handler
22

3-
import mpos.ui
3+
# Allow LVGL M:/path/to/file or M:relative/path/to/file to work for image set_src etc
4+
import fs_driver
5+
fs_drv = lv.fs_drv_t()
6+
fs_driver.fs_register(fs_drv, 'M')
47

8+
import mpos.ui
59

610
RED = lv.palette_main(lv.PALETTE.RED)
7-
811
DARKPINK = lv.color_hex(0xEC048C)
912
MEDIUMPINK = lv.color_hex(0xF480C5)
1013
LIGHTPINK = lv.color_hex(0xF9E9F2)
1114
DARKYELLOW = lv.color_hex(0xFBDC05)
1215
LIGHTYELLOW = lv.color_hex(0xFBE499)
13-
1416
theme = lv.theme_default_init(display._disp_drv, DARKPINK, DARKYELLOW, False, lv.font_montserrat_12)
1517
#theme = lv.theme_default_init(display._disp_drv, DARKPINK, DARKYELLOW, True, lv.font_montserrat_12)
1618

scripts/build_lvgl_micropython.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ if [ "$target" == "esp32" ]; then
3434
# CONFIG_FREERTOS_USE_TRACE_FACILITY=y
3535
# CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y
3636
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
37+
#python3 make.py --ota --partition-size=4194304 --flash-size=16 esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT DISPLAY=st7789 INDEV=cst816s USER_C_MODULE=/home/user/sources/micropython-camera-API/src/micropython.cmake USER_C_MODULE=/home/user/projects/MicroPythonOS/secp256k1-embedded-ecdh/micropython.cmake USER_C_MODULE=/home/user/sources/MicroPythonOS/c_mpos/micropython.cmake CONFIG_FREERTOS_USE_TRACE_FACILITY=y CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y "$manifest"
3738
python3 make.py --ota --partition-size=4194304 --flash-size=16 esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT DISPLAY=st7789 INDEV=cst816s USER_C_MODULE=/home/user/sources/micropython-camera-API/src/micropython.cmake USER_C_MODULE=/home/user/projects/MicroPythonOS/secp256k1-embedded-ecdh/micropython.cmake USER_C_MODULE=/home/user/sources/MicroPythonOS/c_mpos/micropython.cmake CONFIG_FREERTOS_USE_TRACE_FACILITY=y CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y "$manifest"
3839
# ffmpeg failed because time_t conflict time.h /home/user/sources/lvgl_micropython/lib/esp-idf/components/mbedtls/mbedtls/include/mbedtls/platform_time.h
3940
#python3 make.py --ota --partition-size=4194304 --flash-size=16 esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT DISPLAY=st7789 INDEV=cst816s USER_C_MODULE=/home/user/sources/micropython-camera-API/src/micropython.cmake USER_C_MODULE=/home/user/projects/MicroPythonOS/secp256k1-embedded-ecdh/micropython.cmake USER_C_MODULE=/home/user/sources/MicroPythonOS/c_mpos/micropython.cmake USER_C_MODULE=/home/user/sources/MicroPythonOS/c_mpos/ffmpeg.cmake CONFIG_FREERTOS_USE_TRACE_FACILITY=y CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y "$manifest"

scripts/install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ fi
4848
~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp -r builtin :/
4949
~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp -r lib :/
5050
~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp -r resources :/
51+
5152
#~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp -r data :/
53+
#~/sources/lvgl_micropython/lib/micropython/tools/mpremote/mpremote.py fs cp -r data/images :/data/
5254

5355
popd
5456

0 commit comments

Comments
 (0)