I am sort of stubborn and am curious on how one might use LVGL, so started experimenting some with how to do it...
I think the fundamental issue you ran into is that you need to define the canvas buffer.
Here is a simple version:
#include <MemoryHexDump.h>
#include "Arduino.h"
#include "Arduino_H7_Video.h"
#include "lvgl.h"
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
#define CANVAS_WIDTH 240
#define CANVAS_HEIGHT 240
void setup() {
Serial.begin(115200);
while (!Serial && millis() < 5000)
;
Serial.print("LV_COLOR_DEPTH : ");
Serial.println(LV_COLOR_DEPTH);
Display.begin();
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
Serial.print("sizeof lv_color_t:");
Serial.print(sizeof(lv_color_t), DEC);
lv_obj_t* canvas = lv_canvas_create(lv_scr_act());
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR);
lv_obj_align(canvas, LV_ALIGN_CENTER, 0, 0);
lv_canvas_fill_bg(canvas, lv_color_make(100, 0, 0), LV_OPA_COVER);
lv_color_t c = lv_color_make(0, 100, 0);
for (int i = 0; i < CANVAS_WIDTH; i++) {
lv_canvas_set_px(canvas, i, i, c); //https://docs.lvgl.io/8.0/overview/color.html?highlight=color
lv_canvas_set_px(canvas, i, (CANVAS_WIDTH - 1) - i, c);
}
lv_refr_now(lv_disp_get_default());
Serial.print("CBUF Size: ");
Serial.println(sizeof(cbuf), DEC);
// dump a few rows...
MemoryHexDump(Serial, cbuf, sizeof(cbuf) / (CANVAS_HEIGHT / 8), true);
Serial.println("Image ready");
}
void loop() {
lv_timer_handler();
}
The use of my MemoryHexDump is obviously optional, but wanted to see what the backing buffer is filled with. Also appears to be 4 bytes per pixel with this setup.
LV_COLOR_DEPTH : 16
sizeof lv_color_t:2CBUF Size: 230400
240014B0 - 20 03 00 60 00 60 00 60 00 60 00 60 00 60 00 60 : ..`.`.` .`.`.`.`
240014C0 - 00 60 00 60 00 60 00 60 00 60 00 60 00 60 00 60 : .`.`.`.` .`.`.`.`
... 26 duplicate line(s) removed.
24001670 - 00 60 00 60 00 60 00 60 00 60 00 60 00 60 00 60 : .`.`.`.` .`.`.`.`
24001680 - 00 60 00 60 00 60 00 60 00 60 00 60 00 60 20 03 : .`.`.`.` .`.`.` .
24001690 - 00 60 20 03 00 60 00 60 00 60 00 60 00 60 00 60 : .` ..`.` .`.`.`.`
240016A0 - 00 60 00 60 00 60 00 60 00 60 00 60 00 60 00 60 : .`.`.`.` .`.`.`.`
... 26 duplicate line(s) removed.
Next up see if I can set the backing buffer to be on Color16 (565) setup