I can display a custom image with the following example code (from the Arduino examples):
#include "Arduino_H7_Video.h"
#include "ArduinoGraphics.h"
#define INCBIN_PREFIX
#include "incbin.h"
INCBIN(test, "/home/reza/Arduino/custom_image/GIGADisplayShieldBack.bin");
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
Image img_arduinologo(ENCODING_RGB16, (uint8_t *) testData, 643, 482);
void setup() {
Display.begin();
Display.beginDraw();
Display.image(img_arduinologo, (Display.width() - img_arduinologo.width())/2, (Display.height() - img_arduinologo.height())/2);
Display.endDraw();
}
void loop() { }
However when I try the same exercise using LVGL code (again from Arduino examples), the screen does not display the custom image:
#include "Arduino_H7_Video.h"
#include "lvgl.h"
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
void setup() {
Display.begin();
lv_obj_t * screen = lv_obj_create(lv_scr_act());
lv_obj_set_size(screen, Display.width(), Display.height());
static lv_coord_t col_dsc[] = { 642, LV_GRID_TEMPLATE_LAST};
static lv_coord_t row_dsc[] = { 483, LV_GRID_TEMPLATE_LAST};
lv_obj_t * grid = lv_obj_create(lv_scr_act());
lv_obj_set_grid_dsc_array(grid, col_dsc, row_dsc);
lv_obj_set_size(grid, Display.width(), Display.height());
lv_obj_center(grid);
lv_obj_t * obj;
lv_obj_t * img1;
obj = lv_obj_create(grid);
lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 0, 1,
LV_GRID_ALIGN_STRETCH, 0, 1);
LV_IMG_DECLARE(custom_image);
img1 = lv_img_create(obj);
lv_img_set_src(img1, "/home/reza/Arduino/custom_image_lvgl/GIGADisplayShieldBack.bin");
lv_obj_align(img1, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_size(img1, 642, 483);
}
void loop() {
lv_timer_handler();
}
The call to lv_img_set_src does not return any error (i.e. custom image file was read). The custom image resolution is 642x483 but no partial image is displayed let alone the full image that gets rendered when using the ArduinoGraphics library. I've also checked and found that the variable img1 is not NULL.
Suggestions on any workaround are welcome. Thanks.
Regards.