Drawing a few pixels on Giga Display Shield

So, I am still struggling with my Giga Display. I now try to draw a few pixels on the screen.
I dont see anything happening, so it is clear I must be missing something.
Any suggestions

#include "Arduino.h"
#include "Arduino_H7_Video.h"
#include "lvgl.h"
#include <TJpg_Decoder.h> // I am not sure why to include this one

Arduino_H7_Video          Display(800, 480, GigaDisplayShield);



void setup() {
  Serial.begin( 115200 );

  while (!Serial && millis() < 5000);

  Serial.print("LV_COLOR_DEPTH : ");
  Serial.println(LV_COLOR_DEPTH);

  Display.begin();

  lv_obj_t * screen = lv_obj_create(lv_scr_act());
  lv_obj_set_size(screen, Display.width(), Display.height());

  lv_color_t c = lv_color_make(50, 50, 50);

  for (int i=0;i<30;i++)
    {
     lv_canvas_set_px(screen, i, i, c); //https://docs.lvgl.io/8.0/overview/color.html?highlight=color
    lv_canvas_set_px(screen, i, i+1, c);
    lv_canvas_set_px(screen, i, i-1, c);
    }

      lv_refr_now(lv_disp_get_default());

  Serial.println("Image ready");
}

void loop() {
  // put your main code here, to run repeatedly:

}

Dear @MeandMrsJones,
You're missing the lv_timer_handler() in loop() function.

See this example:

Thanks, in the may iterations that one got dropped.
However, included it (again), no pixels are shown.
Any other pointers for me?
Thanks

Hi @MeandMrsJones , if you want to achieve more basic things like drawing pixels, you should consider the GFX library. Drawing a pixel can be done like this: drawPixel(x, y, color).

Here are some resources:

Thank you,
but actually the basic thing I am trying to achieve is to draw a JPG image. Ha Ha.
LVGL does not have this standard function as I believe, so I im thinking about creating it myself.
Regards

I have given up on LVGL for this. Got it working with GFX. See my other post. Thanks

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

It appears to be in color 16 mode. The issue with the buffer being to big is the
example I took some of the buffer stuff from was wrong.

The type should be uint8_t and not lv_color_t for the buffer. as the
LV_CANVAS_BUF_SIZE_TRUE_COLOR()
is defined to be the count of bytes per color * width * height, so it already adjusted the
size of the array for the size of the per pixel...

Dear KurtE.
I see that we share this stubbornness and thanks for all you work. I am trying to understand your last remark. Could it be that the size of c_buf should be the same size as the number of bytes of the JPG file that needs to be displayed? Regards

The backing buffer for the canvas needs to be large enough to hold whatever size you told the canvas to be with the number of bytes needed to hold the color scheme.

So for this line:
static /*lv_color_t*/ uint8_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];

The macro: LV_CANVAS_BUF_SIZE_TRUE_COLOR
is defined as:
#define LV_CANVAS_BUF_SIZE_TRUE_COLOR(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR(w, h)
where
#define LV_IMG_BUF_SIZE_TRUE_COLOR(w, h) ((LV_COLOR_SIZE / 8) * w * h)

where LV_COLOR_SIZE is 16:
So it defines the buffer to be in my case: 2402402 bytes...
Or you can simply get away with:
uint8_t cbuf[CANVAS_WIDTH*CANVAS_HEIGHT*sizeof(lv_color_t)];
or:
lv_color_t cbuf[CANVAS_WIDTH*CANVAS_HEIGHT];

Or in our case
uint16_t cbuf[CANVAS_WIDTH*CANVAS_HEIGHT];

All of which should allocate the same size of memory...

As for JPEG files, that is another complete topic.

I may try an approach to display them, from my other one using GFX. Where I will write directly into this buffer... (will be different size), maybe for fun have it display file name and size in other fields... And still use jpegdec pngdec, and the like.

Alternatively, they have some of this built in... I think. Where you can maybe load the whole file into memory and then call their memory version... OR, you can have them load it from a file. However unclear what file systems does the GIGA implemention expose (if any), or do you need to write a file system object, which you register as a logical drive letter. Example s: for SD card... And then forward all of the calls to the SDFat library... don't know...

However unclear what file systems does the GIGA implemention expose (if any), or do you need to write a file system object, which you register as a logical drive letter. Example s: for SD card... And then forward all of the calls to the SDFat library... don't know...

Have you seen this link yet? May be a little bit of useful info to be gleaned here. Might try the other link mentioned there.

https://forum.pjrc.com/index.php?threads/display-images-using-lvgl-library-teensy-4-0-sdfat-sdio-microsd-card.71005/

The best solution to what type of filesystem to use would be to optimize usage of Giga's built-in USB port. I think I read that OpenMV does not support it yet. All Giga R1 users need the experts at Arduino or others to write a better MBED5 library to get full speed capability of this port, which would be much faster than the current version, as I have read somewhere.

Here is my attempt at a 12x12 Neopixel representation of a 640x480 JPEG. The real neopix is worse.