Help needed: Simple full example of displaying a JPG from SD card on ESP32 with LVGL 9.0?

Description

I need a simple example showing how I can open a JPG file from SD card and display it in LVGL.
I feel like this is a very common use case but somehow there are no examples that show the complete, working solution.
I could find examples where someone was writing their own “FS driver” for LVGL just to be able to achieve that.
It all gets more confusing as there are multiple moving parts that need to work together: jpeg decoder, file system, and the SD card initialization.

What MCU/Processor/Board and compiler are you using?

ESP32-S3 with a 480x480 parallel RGB LCD

What LVGL version are you using?

9.0

What do you want to achieve?

Image is displayed

What have you tried so far?

I tried to enable FATFS but i just don’t know how to get it all working together with the SD, the decoder etc.
I can read and list the content of the SD card in simple sketch without LVGL

Additionally, it would be great if someone could show how to make it run memory-efficient (as I want to load a 480x480 background image, which, I assume, would occupy a lot of RAM…? Could the buffer for the image be stored in PSRAM? Do I need to allocate it there explicitly? Or is that not necessary at all?

I have the same problem and can’t find an example of esp-idf v5.5.0, LVGL 9.3.0, and SD card. I need to display an image from an SD card on a display. There is a display connection. There is integration from the example /examples/storage/sd_card/sdspi, where a text file is read from the card. But lv_image_set_src(img, “A:1.jpg”); does not work. Neither does:
const char file_nihao = / MOUNT_POINT */ “A:nihao.txt”;
memset(data, 0, EXAMPLE_MAX_CHAR_SIZE);
snprintf(data, EXAMPLE_MAX_CHAR_SIZE, “Hell Andrey”);
ret = s_example_write_file(file_nihao, data);
if (ret != ESP_OK) {
return;
}
menuconfig

3rd Party Libraries

CONFIG_LV_FS_DEFAULT_DRIVER_LETTER=0

CONFIG_LV_USE_FS_STDIO is not set

CONFIG_LV_USE_FS_POSIX is not set

CONFIG_LV_USE_FS_WIN32 is not set

CONFIG_LV_USE_FS_FATFS=y
CONFIG_LV_FS_FATFS_LETTER=65
CONFIG_LV_FS_FATFS_PATH=“/sdcard”
CONFIG_LV_FS_FATFS_CACHE_SIZE=0

This is an ESP-IDF project I’ve been working on. It’s an educational voting machine. It loads .bin image files from sd card and shows it on LVGL: GitHub - giobauermeister/urna-esp32s3-lvgl: Electronic Voting Machine with ESP32-S3, ESP-IDF and LVGL (WIP)

Here is a video of it working: https://www.youtube.com/watch?v=sTdV_2BXQLM&ab_channel=Bauertronix

1 Like

Thank you.