LVGL is not loading image file with FatFS - no data
What MCU/Processor/Board and compiler are you using?
STM32F767ZI
What LVGL version are you using?
V8.3.2
What do you want to achieve?
I want to load images preloaded on to SPI flash using FatFS (ready to use driver)
What have you tried so far?
I’ve confirmed the files are there and I am able to see them: I can see LVGL is able to see the image file.
If I purposely direct to the wrong file / missing then no image box is drawn.
I’ve also tried loading the image direct using PNG decoder but to no avail
Code to reproduce
lv_config.h
/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
#define LV_USE_FS_FATFS 1
#if LV_USE_FS_FATFS
#define LV_FS_FATFS_LETTER 'A' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
setup()
if (!flash.begin())
{ // start the flash
debugSerial.println(F("Error, failed to initialise flash chip!"));
while (1)
yield();
}
else
debugSerial.println(F("flash chip initialised"));
delay(100);
FATFS fatfs;
FIL fil; // File handle
FRESULT r = f_mount(&fatfs, "0:", 1); // 0: mounts to the Flash
if (r != FR_OK)
{
debugSerial.print(F("Error, f_mount failed with error code: "));
debugSerial.println(r, DEC);
while (1)
yield();
}
else
debugSerial.println(F("f_mount successful"));
// Check the image file is there
r = f_open(&fil, "favicon.bin", FA_READ);
if (r != FR_OK) {
debugSerial.printf("f_open error (%i)\r\n");
} else
debugSerial.printf("I was able to open 'favicon.bin' for reading!\r\n");
f_close(&fil);
/** Initialise LVGL FatFs Handler **/
lv_fs_fatfs_init();
Image load
void lv_example_bin_3(void)
{
lv_obj_t * img;
img = lv_img_create(lv_scr_act());
lv_img_set_src(img, "A:favicon.bin");
lv_obj_align(img, LV_ALIGN_RIGHT_MID, -20, 0);
}
Serial output - Logging ‘warn’ enabled
flash chip initialised
f_mount successful
I was able to open 'favicon.bin' for reading!
[Warn] (0.276, +276) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.286, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.295, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.305, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.314, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.324, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.333, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.343, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.352, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.362, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.371, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.381, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.390, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.400, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.409, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.419, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.428, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.438, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.447, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.457, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.466, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.476, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.485, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.495, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.504, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.514, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.523, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.533, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.542, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.552, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[Warn] (0.561, +9) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[Warn] (0.571, +10) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
Screenshot and/or video
converted image favicon.bin