Skip to content

Commit 51be28f

Browse files
work towards jpeg support
1 parent 7f20419 commit 51be28f

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

draft_code/saved_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ def log_callback(level, log_str):
602602
# Convert log_str to string if it's a bytes object
603603
log_str = log_str.decode() if isinstance(log_str, bytes) else log_str
604604
# Optional: Print for debugging
605-
#print(f"Level: {level}, Log: {log_str}")
605+
print(f"Level: {level}, Log: {log_str}")
606606
# Log message format: "sysmon: 25 FPS (refr_cnt: 8 | redraw_cnt: 1), ..."
607607
if "sysmon:" in log_str and "FPS" in log_str:
608608
try:

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
class ImageView(Activity):
77

8-
imagedir = "../icons/"
8+
#imagedir = "../icons/"
9+
imagedir = "../artwork/"
10+
#imagedir = "/home/user/Downloads/"
11+
#imagedir = "/home/user/images/"
912
images = []
1013
image_nr = 0
1114
image_timer = None
@@ -20,19 +23,27 @@ def onCreate(self):
2023
self.image = lv.image(screen)
2124
self.image.set_size(128, 128)
2225
self.image.align(lv.ALIGN.BOTTOM_MID,0,0)
26+
self.image_dsc = lv.image_dsc_t()
27+
self.image.set_src(self.image_dsc)
2328
self.setContentView(screen)
2429

2530
def onResume(self, screen):
31+
#lv.libjpeg_turbo_init()
32+
#first = lv.image_decoder_t()
33+
#decoder = lv.image.decoder_get_next(first)
34+
#decoder = lv.image_decoder_t.get_next(first)
35+
#decoder.delete()
2636
self.images.clear()
2737
for item in os.listdir(self.imagedir):
2838
print(item)
39+
#if item.endswith(".jpg") or item.endswith(".jpeg"):
2940
if item.endswith(".jpg") or item.endswith(".jpeg") or item.endswith(".png"):
3041
#if item.endswith(".png"):
3142
fullname = f"{self.imagedir}/{item}"
3243
size = os.stat(fullname)[6]
3344
print(f"size: {size}")
34-
#if size > 1024*1024:
35-
if size > 60000:
45+
if size > 1024*1024:
46+
#if size > 60000:
3647
print(f"Skipping file of size {size}")
3748
continue
3849
self.images.append(fullname)
@@ -61,13 +72,22 @@ def show_image(self, name):
6172
image_data = f.read()
6273
print(f"loaded {len(image_data)} bytes")
6374
f.close()
75+
#self.image_dsc.data_size = len(image_data)
76+
#self.image_dsc.data = image_data
77+
self.image_dsc = None
78+
#self.image.set_src(self.image_dsc)
6479
self.image_dsc = lv.image_dsc_t({
6580
'data_size': len(image_data),
6681
'data': image_data
6782
})
83+
h = lv.image_header_t()
84+
lv.image.decoder_get_info(self.image_dsc, h)
85+
print("image info:")
86+
print(h)
87+
print(f"widthxheight: {h.w}x{h.h}")
88+
self.image.set_src(self.image_dsc)
6889
#image.set_size(128, 128)
6990
#image.set_scale(512)
70-
self.image.set_src(self.image_dsc)
7191
print(f"done with show_image({name})")
7292
except Exception as e:
73-
print("show_image got exception: {e}")
93+
print(f"show_image got exception: {e}")

scripts/build_lvgl_micropython.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ if [ "$target" == "esp32" ]; then
3535
# CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y
3636
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
3737
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"
38+
# ffmpeg failed because time_t conflict time.h /home/user/sources/lvgl_micropython/lib/esp-idf/components/mbedtls/mbedtls/include/mbedtls/platform_time.h
39+
#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"
3840
elif [ "$target" == "unix" -o "$target" == "macos" ]; then
3941
if [ "$buildtype" == "prod" ]; then
4042
manifest="FROZEN_MANIFEST=/home/user/sources/MicroPythonOS/manifest_unix.py"
@@ -43,7 +45,7 @@ elif [ "$target" == "unix" -o "$target" == "macos" ]; then
4345
#python3 make.py "$target" DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest"
4446
# LV_CFLAGS are passed to USER_C_MODULES
4547
# STRIP= makes it so that debug symbols are kept
46-
python3 make.py "$target" LV_CFLAGS="-g -O0 -ggdb" STRIP= DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest"
48+
python3 make.py "$target" LV_CFLAGS="-g -O0 -ggdb -ljpeg" STRIP= DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest"
4749
else
4850
echo "invalid target $target"
4951
fi

0 commit comments

Comments
 (0)