work towards jpeg support

This commit is contained in:
Thomas Farstrike
2025-06-10 00:00:04 +02:00
parent 7f20419455
commit 51be28f298
3 changed files with 29 additions and 7 deletions
+1 -1
View File
@@ -602,7 +602,7 @@ def log_callback(level, log_str):
# Convert log_str to string if it's a bytes object
log_str = log_str.decode() if isinstance(log_str, bytes) else log_str
# Optional: Print for debugging
#print(f"Level: {level}, Log: {log_str}")
print(f"Level: {level}, Log: {log_str}")
# Log message format: "sysmon: 25 FPS (refr_cnt: 8 | redraw_cnt: 1), ..."
if "sysmon:" in log_str and "FPS" in log_str:
try:
@@ -5,7 +5,10 @@ from mpos.apps import Activity
class ImageView(Activity):
imagedir = "../icons/"
#imagedir = "../icons/"
imagedir = "../artwork/"
#imagedir = "/home/user/Downloads/"
#imagedir = "/home/user/images/"
images = []
image_nr = 0
image_timer = None
@@ -20,19 +23,27 @@ class ImageView(Activity):
self.image = lv.image(screen)
self.image.set_size(128, 128)
self.image.align(lv.ALIGN.BOTTOM_MID,0,0)
self.image_dsc = lv.image_dsc_t()
self.image.set_src(self.image_dsc)
self.setContentView(screen)
def onResume(self, screen):
#lv.libjpeg_turbo_init()
#first = lv.image_decoder_t()
#decoder = lv.image.decoder_get_next(first)
#decoder = lv.image_decoder_t.get_next(first)
#decoder.delete()
self.images.clear()
for item in os.listdir(self.imagedir):
print(item)
#if item.endswith(".jpg") or item.endswith(".jpeg"):
if item.endswith(".jpg") or item.endswith(".jpeg") or item.endswith(".png"):
#if item.endswith(".png"):
fullname = f"{self.imagedir}/{item}"
size = os.stat(fullname)[6]
print(f"size: {size}")
#if size > 1024*1024:
if size > 60000:
if size > 1024*1024:
#if size > 60000:
print(f"Skipping file of size {size}")
continue
self.images.append(fullname)
@@ -61,13 +72,22 @@ class ImageView(Activity):
image_data = f.read()
print(f"loaded {len(image_data)} bytes")
f.close()
#self.image_dsc.data_size = len(image_data)
#self.image_dsc.data = image_data
self.image_dsc = None
#self.image.set_src(self.image_dsc)
self.image_dsc = lv.image_dsc_t({
'data_size': len(image_data),
'data': image_data
})
h = lv.image_header_t()
lv.image.decoder_get_info(self.image_dsc, h)
print("image info:")
print(h)
print(f"widthxheight: {h.w}x{h.h}")
self.image.set_src(self.image_dsc)
#image.set_size(128, 128)
#image.set_scale(512)
self.image.set_src(self.image_dsc)
print(f"done with show_image({name})")
except Exception as e:
print("show_image got exception: {e}")
print(f"show_image got exception: {e}")
+3 -1
View File
@@ -35,6 +35,8 @@ if [ "$target" == "esp32" ]; then
# CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
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"
# ffmpeg failed because time_t conflict time.h /home/user/sources/lvgl_micropython/lib/esp-idf/components/mbedtls/mbedtls/include/mbedtls/platform_time.h
#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"
elif [ "$target" == "unix" -o "$target" == "macos" ]; then
if [ "$buildtype" == "prod" ]; then
manifest="FROZEN_MANIFEST=/home/user/sources/MicroPythonOS/manifest_unix.py"
@@ -43,7 +45,7 @@ elif [ "$target" == "unix" -o "$target" == "macos" ]; then
#python3 make.py "$target" DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest"
# LV_CFLAGS are passed to USER_C_MODULES
# STRIP= makes it so that debug symbols are kept
python3 make.py "$target" LV_CFLAGS="-g -O0 -ggdb" STRIP= DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest"
python3 make.py "$target" LV_CFLAGS="-g -O0 -ggdb -ljpeg" STRIP= DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest"
else
echo "invalid target $target"
fi