Dear All,
I spent weeks try to find a solution and spare this humble community with my lack of talent.
Here is the pitch:
First i am a noob ! I bought the Giga display bundle (with the board and the touch screen).
I want for a project, to use LVGL lib to display an image. I succeeded to include images in the code but with 8 pictures i am using all the memory (LVGL converter and .c files stuff).
So i am now using an USB to load the picture and to read some .txt files.
Mounting the USB done
Reading the .txt files done
Reading all images files titles done.
Trying to display the pictures in every way possible.... Fail... the printf tells me it is displaying the picture but I end up with a white screen. I have tried all sorts of images type, .bmp . jpg ,800x480 pixels, 300x300 pixels, 100x100 pixels, 24 bits, 16bits.
I went through out the forums trying to do it on my own .... any one have an idea ?
Thank you in advance
#include <Arduino_H7_Video.h> // GIGA display driver (includes LVGL)
#include <lvgl.h> // LVGL library
#include <Arduino_USBHostMbed5.h> // USB Host for GIGA R1
#include <FATFileSystem.h> // FAT file system (mbed)
// Display object
Arduino_H7_Video Display;
// USB mass storage object
USBHostMSD usb;
// File system mounted on "/usb"
mbed::FATFileSystem fs("usb");
// Global pointer for the LVGL image object
lv_obj_t *img_obj = NULL;
// Variables for image switching
bool showingBmp = true;
unsigned long lastSwitch = 0;
void setup() {
Serial.begin(115200);
// Initialize LVGL and display
lv_init();
Display.begin(); // Configure the screen and LVGL
// Connecting USB stick
Serial.print("Connecting USB...");
while (!usb.connect()) {
Serial.println("Waiting for the USB stick...");
delay(100);
}
Serial.println("USB stick connected.");
// Mounting USB file system
Serial.print("Mounting file system...");
int err = fs.mount(&usb);
if (err != 0) {
char buffer[50];
sprintf(buffer, "Mount error (%d)", err);
Serial.println(buffer);
} else {
Serial.println("File system mounted!");
}
// Checking for file existence in the testimages folder
FILE *f = fopen("/usb/testimages/logo300bittest.bmp", "rb");
if (!f) {
Serial.println("BMP file not found (check path and filename).");
} else {
Serial.println("BMP file found.");
fclose(f);
}
f = fopen("/usb/testimages/logo300bittest.jpg", "rb");
if (!f) {
Serial.println("JPG file not found (check path and filename).");
} else {
Serial.println("JPG file found.");
fclose(f);
}
// Initial creation of the image object and display of the BMP
img_obj = lv_img_create(lv_scr_act());
// Note: For LVGL via STDIO, the path must be prefixed with "S:" (letter assigned to the driver)
lv_img_set_src(img_obj, "S:/usb/testimages/logo300bittest.bmp");
lv_obj_align(img_obj, LV_ALIGN_CENTER, 0, 0);
// Indicate that the BMP is initially displayed and initialize the timer
showingBmp = true;
lastSwitch = millis();
}
void loop() {
// Periodic LVGL handling
lv_timer_handler();
delay(5);
// Image change every 5000 ms
if (millis() - lastSwitch > 5000) {
lastSwitch = millis();
// Delete the previous image
lv_obj_del(img_obj);
// Create a new image
img_obj = lv_img_create(lv_scr_act());
if (showingBmp) {
Serial.println("Displaying logo300bittest.jpg");
lv_img_set_src(img_obj, "S:/usb/testimages/logo300bittest.jpg");
}
else {
Serial.println("Displaying logo300bittest.bmp");
lv_img_set_src(img_obj, "S:/usb/testimages/logo300bittest.bmp");
}
lv_obj_align(img_obj, LV_ALIGN_CENTER, 0, 0);
// Toggle the flag for the next switch
showingBmp = !showingBmp;
}
}