How to correct display SJPG files with LVGL

Description

Hi,

I am trying to display images using the SJPG format, but I can’t get to display them correctly, I know I am doing something because I have a glitched image shown on my screen.

I know how to display images from .c files, but I would like to use files from system so I won’t need to recompile my code. I already tried to use the PNG decoder, but I couldn’t at all make it work or do something. Since my code runs on an embedded system, I figure out that using SJPG might be a better option.

What MCU/Processor/Board and compiler are you using?

The board is the Colibri iMX7 512MB and I am compiling it with GCC and Make. Our system is based on a Yocto Linux image.

What LVGL version are you using?

v8.2.0

What do you want to achieve?

I want to display SJPG on my screen from system files without recompiling my code

What have you tried so far?

I did enable in lv_conf.h the use of SJPG decoder library #define LV_USE_SJPG 1 and since I couldn’t figure out how to create my own driver (too complicated for me) I did try to use both STDIO #define LV_USE_FS_STDIO 0 and POSIX #define LV_USE_FS_POSIX 1, but none of them gave different results, both gave me a glitched image.

I did set the correct PATH to my SJPG file "/home/FTC/images/" and set a cache size of (4U * 64U * 1024U) (we have lots of memory).

/*API for fopen, fread, etc*/
#define LV_USE_FS_STDIO 1
#if LV_USE_FS_STDIO
    #define LV_FS_STDIO_LETTER 'Z'     /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
    #define LV_FS_STDIO_PATH "/home/FTC/images/"         /*Set the working directory. File/directory paths will be appended to it.*/
    #define LV_FS_STDIO_CACHE_SIZE (4U * 64U * 1024U)    /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
 
/*API for open, read, etc*/
#define LV_USE_FS_POSIX 1
#if LV_USE_FS_POSIX
    #define LV_FS_POSIX_LETTER 'A'     /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
    #define LV_FS_POSIX_PATH "/home/FTC/images/"         /*Set the working directory. File/directory paths will be appended to it.*/
    #define LV_FS_POSIX_CACHE_SIZE (4U * 64U * 1024U)    /*>0 to cache this number of bytes in lv_fs_read()*/
#endif

/* JPG + split JPG decoder library.
 * Split JPG is a custom format optimized for embedded systems. */
#define LV_USE_SJPG 1

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

void displayImage(void)
{
    lv_split_jpeg_init();

    lv_obj_t * img;

    img = lv_img_create(lv_scr_act());
    /* Assuming a File system is attached to letter 'A'
     * E.g. set LV_USE_FS_STDIO 'A' in lv_conf.h */
    lv_img_set_src(img, "A:teste.sjpg");
    //lv_img_set_src(img, "Z:teste.sjpg"); // One or another
}