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