Description
I have a project that will switch between a lot of relatively large images. Because the spiflash-based FATFS
is used on the hardware, the loading speed is estimated to be slower, which is not very friendly to interaction. So I want to preload the picture bin file in FATFS
into PSRAM
.
What MCU/Processor/Board and compiler are you using?
Windows simulator。
ESP32S3 N16R8
What LVGL version are you using?
v8.3.0
What do you want to achieve?
preload images from fatfs
What have you tried so far?
I tried it on a windows simulator:
FILE* f = fopen("E:\\**\\**.bin", "rb");
if (f == NULL)
{
printf("can't open file\n");
exit(1);
}
fseek(f, 0, SEEK_END);
size_t fSize = ftell(f);
fseek(f, 0, SEEK_SET);
char* buffer = (char*)malloc(sizeof(char) * fSize);
if (buffer == NULL)
{
printf("can't malloc buffer\n");
exit(1);
}
size_t result = fread(buffer, 1, fSize, f);
if (result != fSize)
{
printf("can't load data\n");
exit(1);
}
lv_img_dsc_t* img_dsc = (lv_img_dsc_t*)buffer;
lv_obj_t* img = lv_img_create(lv_scr_act());
lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
lv_img_set_src(img, img_dsc);
But the picture is not displayed. Through breakpoint debugging, I found that img_dsc->header
reads the width and height of the picture correctly, but the value of img_dsc->data_size
is 0, and img_dsc->data
points to NULL
Code to reproduce
As shown above