Really trying to understand displaying pixels on Canvas


What MCU/Processor/Board and compiler are you using?

Arduino IDE and Arduino Giga R1 and Arduino Giga Display

What LVGL version are you using?


What do you want to achieve?

Simply printing some pixels on a Canvas. Well actually, even more simple, I want to print pixels on the active screen, nothing more, nothing less.

What have you tried so far?

Reading and rereading the documentation, using LVGL examples provide by Arduino, a lot of trial and error.
I have provide my simple code. The screen turns yellow, which is okay. I see a blue square, which is okay. But then I hoped to see some white pixels on the screen. But nothing shows up.

Any help is welcome.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:


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

GigaDisplay_GFX Display;

#define CANVAS_WIDTH  200
#define CANVAS_HEIGHT 200

#define MASK_WIDTH 100
#define MASK_HEIGHT 45

#define WHITE 0xffff
#define BLACK 0x0000

#define GC9A01A_CYAN    0x07FF
#define GC9A01A_RED     0xf800
#define GC9A01A_BLUE    0x001F
#define GC9A01A_GREEN   0x07E0
#define GC9A01A_MAGENTA 0xF81F
#define GC9A01A_WHITE   0xffff
#define GC9A01A_BLACK   0x0000
#define GC9A01A_YELLOW  0xFFE0
#define WHITE 0xffff
#define BLACK 0x0000

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

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

  Serial.print("LV_COLOR_DEPTH : ");

  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(250, 100, 100);

  Display.fillScreen(GC9A01A_YELLOW); // This command does work, screen is yellow

  Display.fillRect(120, 180, 120, 180, GC9A01A_BLUE); // This command work, I see a blue rectangle

  static lv_opa_t mask_map[MASK_WIDTH * MASK_HEIGHT]; // Dont know why i am doing this, got it from an example

  lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
  lv_canvas_set_buffer(canvas, mask_map, MASK_WIDTH, MASK_HEIGHT, LV_IMG_CF_TRUE_COLOR); //LV_IMG_CF_ALPHA_8BIT);
  lv_canvas_fill_bg(canvas, lv_color_black(), LV_OPA_50); 
  lv_color_t c1 = lv_color_white(); //lv_color_make(0, 200, 0);

  for (int i=0;i<300;i++)
     lv_canvas_set_px(canvas, i, i, c1); //




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


Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Just taking a quick glance at this it looks like you’re not calling lv_tick_inc which means the timers wont ever run which means your screen will never be refreshed.

Thank you, indeed a mistake. In the meantime I am trying to get a png image displayed, ha ha.