Assets on sd-card

What do you want to achieve?

Want to load images from SD-Card

What have you tried so far?

Change Settings and export UI

Screenshot or video

image

// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 8.3.11
// Project name: test

#include “…/ui.h”

// IMAGE DATA: assets/img/splashlogo.png
const char * ui_img_img_splashlogo_png = “S:assets/img/splashlogo.png”;

Others

  • SquareLine Studio version: 1.4.1
  • Operating system: WIndows 11
  • Target hardware: ESP32 Arduino

The images are in my assets folder and i put in there into an img folder

I want to put the images into and folder /img/ on my sd-card to store it.

Whats settings is needed to export the ui_files for setting the right path?

const char * ui_img_img_splashlogo_png = “S:assets/img/splashlogo.png”;

should be: const char * ui_img_img_splashlogo_png = “S:/img/splashlogo.png”;

The ‘assets’ folder is currently hard-coded but thanks for pointing out this use-case. The path field in project settings has no effect for FAT32 which you’ll probably use for the SDcard (it has no PATH field in lv_conf.h), and it only sets the folder to be used as a virtual drive for the others (STDIO, POSIX, WIN32).

Okay. I use this libray to read and write the SD Card.

What should i add to read my assets from my sd-Card. I put the assets on and folder “assets” but nothing is loaded so far.

#include “…/ui.h”

// IMAGE DATA: assets/splashlogo.png
const char * ui_img_splashlogo_png = “S:assets/splashlogo.png”;

Your documentation is very basic in this case…

My memory is low and thas why i need to load pictures from SD. I try binary LVGL as format and get the original png files.

Thanks in advance

Just in case you missed, the related document can be found here: Managing Assets on External Drive | SquareLine Studio

For the image loader to work from SD-card, the lv_fs LVGL subsystem and ‘S:’ drive-letter should be initialized with the mounted FAT32 (or maybe LittleFS) partition. In other words you need to connect the functionality of Arduino ‘SD’ library with LVGL ‘fs’. Corresponding LVGL documentation: File system — LVGL documentation and File System Interfaces — LVGL documentation.
( See the notes: ‘You still need to provide the drivers and libraries, this extension provides only the bridge between FATFS, LittleFS, STDIO, POSIX, WIN32 and LVGL.’ and ‘Bridge for FatFS. FatFS itself is not part of LVGL, but can be added and initialized externally.’ There’s a more thorough explanation for LittleFS through an ESP-IDF example.)

Okay. I missed the settings in lvlg.conf

But i use until now the this library for my SD-Card access:

#include “SD.h”

and it use

File file = fs.open(path);

for reading. Is this compatible to one of the offered options ?

The LVGL lv_fs_fatsfs (which is used by LVGL for filesystem-operations when you select FATFS in lv_conf.h) has an lv_fs_fatfs_init function called internally by lv_init() at startup. This assigns the open/read/etc. functions to the FatFS library by default. But this library is a generic FAT32/exFAT library and can’t use the SD-card directly. To mount and use the SD-card by it would take configuration that’s covered by FatFS’s own documentation, maybe you can use it together with the SD library somehow.

But the SD library which you’d like to use seems to have the mounting and FAT filesystem support already built in, so you might follow an easier path by not using the preconfigured FATFS in lv_conf.h but registering the SD.open/read/etc. functions of the SD library to a new lv_fs_drv_t and give it the drive letter as seen in the linked LVGL-document example at File system — LVGL documentation.
There’s another forum topic covering this use-case where I answered nearly the same: Upload Image C array file from SD Card - #5 by dbtronics
For further info and more specific examples you can follow the LVGL forum, for example: How do I correctly make the SD Card work for image widgets on an ESP32 Dev Kit with LVGL v.8.3? - How-to - LVGL Forum