How to start with LVGL

Hi, I just want to start learning LVGL with ESP32-8048S070C display.
I want to use Visual Studio with PlatformIO.
I follow the instructions in the page Quick overview.
I make a project in PlatformIO and I add the library LVGL (the last one, 9.0.0)
I try to write the first code following the instructions, but i get some errors.
This is my code:

/*******************************************************************************
 * LVGL Test
 ******************************************************************************/
#include <Arduino.h>

#include <lvgl.h>

#define MY_DISP_HOR_RES 800
#define MY_DISP_VER_RES 480

static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf1[MY_DISP_HOR_RES * MY_DISP_VER_RES / 10];                        /*Declare a buffer for 1/10 screen size*/

//=================================================================================
// Implement and register a function which can copy the rendered image to an area 
// of your display:
//=================================================================================
static lv_disp_t disp_drv;        /*Descriptor of a display driver*/

void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
    int32_t x, y;
    /*It's a very slow but simple implementation.
     *`set_pixel` needs to be written by you to a set pixel on the screen*/
    for(y = area->y1; y <= area->y2; y++) {
        for(x = area->x1; x <= area->x2; x++) {
            set_pixel(x, y, *color_p);
            color_p++;
        }
    }
   lv_disp_flush_ready(disp);
}

//=================================================================================
// Touchpad read
//=================================================================================
static lv_indev_t indev_drv;           /*Descriptor of a input device driver*/

void my_touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
    /*`touchpad_is_pressed` and `touchpad_get_xy` needs to be implemented by you*/
    if(touchpad_is_pressed()) {
      data->state = LV_INDEV_STATE_PRESSED;
      touchpad_get_xy(&data->point.x, &data->point.y);
    } else {
      data->state = LV_INDEV_STATE_RELEASED;
    }

}

//=================================================================================
//                                   SETUP
//=================================================================================
void setup()
{
   Serial.begin(115200);
   while (!Serial);
   Serial.println("======= Test LVGL ======");


   lv_disp_draw_buf_init(&draw_buf, buf1, NULL, MY_DISP_HOR_RES * MY_DISP_VER_RES / 10);  /*Initialize the display buffer.*/

   lv_disp_drv_init(&disp_drv);          /*Basic initialization*/
   disp_drv.flush_cb = my_disp_flush;    /*Set your driver function*/
   disp_drv.draw_buf = &draw_buf;        /*Assign the buffer to the display*/
   disp_drv.hor_res = MY_DISP_HOR_RES;   /*Set the horizontal resolution of the display*/
   disp_drv.ver_res = MY_DISP_VER_RES;   /*Set the vertical resolution of the display*/
   lv_disp_drv_register(&disp_drv);      /*Finally register the driver*/

   lv_indev_drv_init(&indev_drv);             /*Basic initialization*/
   indev_drv.type = LV_INDEV_TYPE_POINTER;    /*Touch pad is a pointer-like device*/
   indev_drv.read_cb = my_touchpad_read;      /*Set your driver function*/
   lv_indev_drv_register(&indev_drv);         /*Finally register the driver*/

   lv_init();
}

//=================================================================================
//                                   LOOP
//=================================================================================

void loop()
{
   lv_timer_handler(); /* let the GUI do its work */
   delay(5);
}

I get the error:
src/main.cpp:12:8: error: ‘lv_disp_draw_buf_t’ does not name a type; did you mean ‘lv_draw_buf_t’?
src/main.cpp:19:18: error: aggregate ‘lv_disp_t disp_drv’ has incomplete type and cannot be defined
src/main.cpp:21:20: error: variable or field ‘my_disp_flush’ declared void
src/main.cpp:21:35: error: ‘disp’ was not declared in this scope
src/main.cpp:21:76: error: ‘color_p’ was not declared in this scope
… and more
If I use the library LVGL version 8.3.9 I have different errors:
src/main.cpp:28:13: error: ‘set_pixel’ was not declared in this scope
src/main.cpp:43:8: error: ‘touchpad_is_pressed’ was not declared in this scope
src/main.cpp:45:7: error: ‘touchpad_get_xy’ was not declared in this scope
src/main.cpp:64:21: error: cannot convert ‘lv_disp_t*’ {aka ‘_lv_disp_t*’} to ‘lv_disp_drv_t*’ {aka ‘_lv_disp_drv_t*’}
src/main.cpp:65:13: error: ‘lv_disp_t’ {aka ‘struct _lv_disp_t’} has no member named ‘flush_cb’
src/main.cpp:66:13: error: ‘lv_disp_t’ {aka ‘struct _lv_disp_t’} has no member named ‘draw_buf’
… and more

What is wrong?
many thanks to anyone who can help me to find the errors or to find a code working just to start.
Livio

I’m not sure I can help you, but some things I notices in your post.

You state that you want to use “Visual Studio with PlatformIO”. That is simply not possible. I assume you mean “Visual Studio Code with PlatformIO”.

You see: Visual Studio is the closed source IDE from Microsoft. Visual Studio Code is the open source IDE from Microsoft. PlatformIO is indeed written for Visual Studio Code.
(Yes I know it’s confusing)

Since you use PlatformIO, can you also post your platformio.ini file. This includes more detailed information about the versions used.
Also, once you start the upload, PlatformIO generates a “Dependency Graph” and looks like this.

Dependency Graph
|-- LVGL @ ...

My best guess is that you are using the display template from version 8 and the library from version 9.

Thank you for you answer.
Yes, sorry, Visual Studio Code.
After many attempts I managed to get the 7" display (ESP32-8048S070C) to work.
My file platform.ini is:

[env:sunton_s3]
platform = espressif32@6.3.1
board = sunton_s3
framework = arduino
monitor_speed = 115200
upload_protocol = esptool
lib_deps = 
	moononournation/GFX Library for Arduino@1.2.8
	lvgl/lvgl@8.3.6
	tamctec/TAMC_GT911@^1.0.2

I have also add a file:


{
  "build": {
    "arduino": {
      "ldscript": "esp32s3_out.ld",
      "partitions": "default_16MB.csv",
      "memory_type": "qio_opi"
    },
    "core": "esp32",
    "extra_flags": [
      "-DARDUINO_ESP32S3_DEV",
      "-DBOARD_HAS_PSRAM",
      "-DARDUINO_USB_MODE=1",
      "-DARDUINO_RUNNING_CORE=1",
      "-DARDUINO_EVENT_RUNNING_CORE=1",
      "-DARDUINO_USB_CDC_ON_BOOT=0"
    ],
    "f_cpu": "240000000L",
    "f_flash": "80000000L",
    "flash_mode": "qio",
    "hwids": [
      [
        "0x303A",
        "0x1001"
      ]
    ],
    "mcu": "esp32s3",
    "variant": "esp32s3"
  },
  "connectivity": [
    "wifi"
  ],
  "debug": {
    "openocd_target": "esp32s3.cfg"
  },
  "frameworks": [
    "arduino",
    "espidf"
  ],
  "name": "Sunton ESP32-S3",
  "upload": {
    "flash_size": "16MB",
    "maximum_ram_size": 327680,
    "maximum_size": 16777216,    
    "use_1200bps_touch": true,
    "wait_for_upload_port": true,
    "require_upload_port": true,
    "speed": 460800
  },
  "url": "https://www.makerfabs.com/sunton-esp32-s3-7-inch-tn-display-with-touch.html",
  "vendor": "Sunton"
}


This file is stored under the name sunton_s3.json in the local user directory C:\Users\username.platformio\platforms\espressif32\boards\

I use the library LVGL version 8.3.6 because the last one, version 9, gives too many errors with the examples I found, may be in the future I will be able to understand the changes I need.

Thank you again.
Livio