To be honest, the only reason why we are considering this very expensive combination (Arduino giga R1 and the Arduino Display in our projects), is the combination of LVGL and touch. For to many days we have been struggling here to het even the most simple example to work.
LVGL lib 8.3.11.
I have include the simple code and settings in lv_conf.h.
wink.png is available and is indeed a png file.
The screen shows nothing.
All combinations of memory settings and color settings have been applied.
Any idea?
#include "Arduino_H7_Video.h"
#include "lvgl.h"
#include "SD.h"
#include "SdFat.h"
#include <stdio.h>
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
File myFile;
void setup() {
Serial.begin(115200);
while (!Serial && millis() < 5000);
if (!SD.begin(52))
{
Serial.println("SD card failed!");
}
else
{
Serial.println("SD card success!");
}
int char_teller=0;
int bytes_read=0;
char ch;
myFile = SD.open("wink.png"); //https://docs.fileformat.com/image/png/
while (myFile.available())
{
ch=myFile.read();
Serial.print(ch,HEX);
Serial.print(" (");
Serial.print(ch,DEC);
Serial.print(") ");
bytes_read++;
Serial.print(" ");
char_teller++;
if (char_teller>16) {Serial.println();char_teller=0;}
}
// close the file:
myFile.close();
Serial.println();
Serial.print("Bytes read : ");
Serial.println(bytes_read);
Display.begin();
lv_png_init();
_lv_img_decoder_init();
lv_obj_t * screen = lv_obj_create(lv_scr_act());
lv_obj_set_size(screen, Display.width(), Display.height());
lv_obj_t * img;
img = lv_img_create(lv_scr_act());
lv_img_set_src(img, "S:/wink.png");
//lv_obj_align(img, LV_ALIGN_RIGHT_MID, -20, 0);
lv_obj_align(img, LV_ALIGN_RIGHT_MID, 300, 300);
Serial.println("Done");
while(1)
{
lv_timer_handler();
delay(300);
}
/*====================
COLOR SETTINGS
*====================*/
//Een bewuste fout
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#define LV_COLOR_DEPTH 8
/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/
#define LV_COLOR_16_SWAP 0
/*Enable features to draw on transparent background.
*It's required if opa, and transform_* style properties are used.
*Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/
#define LV_COLOR_SCREEN_TRANSP 0
/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
#define LV_COLOR_MIX_ROUND_OFS 0
/*Images pixels with this color will not be drawn if they are chroma keyed)*/
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green 0x00ff00 */
/*=========================
MEMORY SETTINGS
*=========================*/
/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
//#define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/ //origineel
#define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
#define LV_MEM_ADR 0 /*0: unused*/
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
#if LV_MEM_ADR == 0
#undef LV_MEM_POOL_INCLUDE
#undef LV_MEM_POOL_ALLOC
#endif
#else /*LV_MEM_CUSTOM*/
#define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
#define LV_MEM_CUSTOM_ALLOC malloc
#define LV_MEM_CUSTOM_FREE free
#define LV_MEM_CUSTOM_REALLOC realloc
#endif /*LV_MEM_CUSTOM*/
/*File system interfaces for common APIs */
/*API for fopen, fread, etc*/
#define LV_USE_FS_STDIO 0
#if LV_USE_FS_STDIO
#define LV_FS_STDIO_LETTER 'S' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
#define LV_FS_STDIO_CACHE_SIZE 1024 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*API for open, read, etc*/
#define LV_USE_FS_POSIX 0
#if LV_USE_FS_POSIX
#define LV_FS_POSIX_LETTER 'S' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
#define LV_FS_POSIX_CACHE_SIZE 1024 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*API for CreateFile, ReadFile, etc*/
#define LV_USE_FS_WIN32 0
#if LV_USE_FS_WIN32
#define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
#define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
#define LV_USE_FS_FATFS 0
#if LV_USE_FS_FATFS
#define LV_FS_FATFS_LETTER 'S' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_FATFS_CACHE_SIZE 1024 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*API for LittleFS (library needs to be added separately). Uses lfs_file_open, lfs_file_read, etc*/
#define LV_USE_FS_LITTLEFS 1
#if LV_USE_FS_LITTLEFS
#define LV_FS_LITTLEFS_LETTER 'S' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_LITTLEFS_CACHE_SIZE 1024 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*PNG decoder library*/
#define LV_USE_PNG 1