Good evening. I would like to load images from my pendrive and display them on my arduino’s display. I only want to use tiny images, for example: 100x100. Unfortunately, the images wont get displayed. When it comes to arduino and c++ I’m a beginner.
Later on I tried to use Claude to help me fix this problem. It didn’t really help.
While chatting with Claude I also checked the documentation.
Then I tried to find a solution on the web, but nothing.
I also didn’t receive any error and Claude recommended me to try to open my image with fopen, which was successful.
I made BGLImage in order to customize how I and my code use image widgets and Im 100% sure that it works correctly.
The other files just help me to organize my code.
Environment
MCU/MPU/Board: Arduino Giga R1 Wifi
LVGL version: 9.5.0
Also I use VSC with PlatformIO for coding and Arduino IDE for installing libraries and I use Win11.
Thanks for the link! I checked it out, unfortunately it only mentioned how to display an image from a C binary. I also copied a piece of your code which you provided.
I checked my pendrive and the image is located at the root folder and the size of it’s is 139x138.
---- Opened the serial port COM3 ---- Successfully mounted USB! /usb/mate.png -> exists ---- Closed the serial port COM3 ----
Now I can see where the image should be on the screen because of the red border. However, it is empty. I genuinely dont know what could be the problem.
Try another file type, BIN converted to screen format is the better to test, PNG is complex to load so first test if lvlg can load any files then try to load a PNG
As it turns out PlatformIO had created a different LVGL config file which I didn’t know of. After I enabled the logging module I saw that LVGL couldn’t find my image because the drive letter was unrecognized. I tried to enable POSIX, STDIO and FATFS (one at a time of course), but I always got an error. I will try to find a way to fix it tho I might need to write a custom driver. If you would know an easy fix for this, please tell me.
Here’s the error I get:
In file included from c:\users\scynthi.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\dirent.h:7:0, from C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c:16: c:\users\scynthi.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\sys\dirent.h:10:2: error: #error "<dirent.h> not supported" #error "<dirent.h> not supported" ^~~~~ Compiling .pio\build\giga_r1_m7\lib1bf\lvgl\libs\svg\lv_svg_token.c.o Compiling .pio\build\giga_r1_m7\lib1bf\lvgl\libs\thorvg\tvgAccessor.cpp.o Compiling .pio\build\giga_r1_m7\lib1bf\lvgl\libs\thorvg\tvgAnimation.cpp.o C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c: In function 'fs_dir_open': C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c:271:18: warning: implicit declaration of function 'opendir'; did you mean 'openat'? [-Wimplicit-function-declaration] void * dir = opendir(buf); ^~~~~~~ openat C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c:271:18: warning: initialization makes pointer from integer without a cast [-Wint-conversion] C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c: In function 'fs_dir_read': C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c:296:17: warning: implicit declaration of function 'readdir'; did you mean 'readlink'? [-Wimplicit-function-declaration] entry = readdir(dir_p); ^~~~~~~ readlink C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c:296:15: warning: assignment makes pointer from integer without a cast [-Wint-conversion] entry = readdir(dir_p); ^ C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c:298:21: error: dereferencing pointer to incomplete type 'struct dirent' if(entry->d_type == DT_DIR) lv_snprintf(fn, fn_len, "/%s", entry->d_name); ^~ C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c:298:33: error: 'DT_DIR' undeclared (first use in this function); did you mean 'EISDIR'? if(entry->d_type == DT_DIR) lv_snprintf(fn, fn_len, "/%s", entry->d_name); ^~~~~~ EISDIR C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c:298:33: note: each undeclared identifier is reported only once for each function it appears in C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c: In function 'fs_dir_close': C:\Users\scynthi\Documents\Arduino\libraries\lvgl\src\libs\fsdrv\lv_fs_posix.c:319:15: warning: implicit declaration of function 'closedir'; did you mean 'close'? [-Wimplicit-function-declaration] int ret = closedir(dir_p); ^~~~~~~~ close *** [.pio\build\giga_r1_m7\lib1bf\lvgl\libs\fsdrv\lv_fs_posix.c.o] Error 1
Thanks for the link! I checked it out and I chose to make a custom driver. After it I had problems with lodepng, because it couldn’t allocate enough memory.
At the end I converted the image to a bin file and now it works!