What do you want to achieve?
I want the generated code to run error-free!
// IMAGE DATA: assets/boot.png
const char *ui_img_boot_png = "L:assets/boot.png";
The generated code leads to a fatal error and there is no picture on the display
[ 2824][E][vfs_api.cpp:28] open(): assets/boot.png does not start with /
What have you tried so far?
Adding an beginning slash in path fixes the error.
// IMAGE DATA: assets/boot.png
const char *ui_img_boot_png = "L:/assets/boot.png";
Screenshot or video
Others
- LVGL version:
9.2.2 - SquareLine Studio version:
1.5.1 - Operating system:
- Target hardware:
ESP32
Discrepancies in the documentation.
Usage example here
The example below shows how to read from a file:
lv_fs_file_t f;
lv_fs_res_t res;
res = lv_fs_open(&f, "S:folder/file.txt", LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) my_error_handling();
uint32_t read_num;
uint8_t buf[8];
res = lv_fs_read(&f, buf, 8, &read_num);
if(res != LV_FS_RES_OK || read_num != 8) my_error_handling();
lv_fs_close(&f);
This example shows how to read a directory’s content. It’s up to the driver how to mark directories in the result but it can be a good practice to insert a /
in front of each directory name.
lv_fs_dir_t dir;
lv_fs_res_t res;
res = lv_fs_dir_open(&dir, "S:/folder");
if(res != LV_FS_RES_OK) my_error_handling();
char fn[256];
while(1) {
res = lv_fs_dir_read(&dir, fn, sizeof(fn));
if(res != LV_FS_RES_OK) {
my_error_handling();
break;
}
/*fn is empty, if not more files to read*/
if(strlen(fn) == 0) {
break;
}
printf("%s\n", fn);
}
lv_fs_dir_close(&dir);
As practice has shown, It’s up to the driver does not decide anything by himself, and “good practice” must be the rule?
I have a dozen images in my project, and after each export, correcting the code manually is very tiring.