Hi,
does anyone know what versions are compatible with ESP-IDF. Currently i have ESPv5.3.1 with lvgl 9.2.2. I keep getting errors in my code.
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "driver/spi_master.h"
#include "driver/gpio.h"
#include "lvgl.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#define TAG "ST7789"
// Define SPI pins
#define PIN_NUM_MOSI 13
#define PIN_NUM_CLK 14
#define PIN_NUM_CS 15
#define PIN_NUM_DC 2
#define PIN_NUM_RST -1
#define PIN_NUM_BL 21
// LVGL buffer size
#define DISP_BUF_SIZE (240 * 20)
static const spi_host_device_t HOST_ID = SPI2_HOST;
// LVGL flush callback
void disp_driver_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) {
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t)drv->user_data;
esp_lcd_panel_draw_bitmap(panel_handle, area->x1, area->y1, area->x2 + 1, area->y2 + 1, color_map);
lv_disp_flush_ready(drv);
}
void app_main() {
// Initialize SPI bus
spi_bus_config_t buscfg = {
.sclk_io_num = PIN_NUM_CLK,
.mosi_io_num = PIN_NUM_MOSI,
.miso_io_num = -1,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.max_transfer_sz = 320 * 240 * 2 + 10,
};
ESP_ERROR_CHECK(spi_bus_initialize(HOST_ID, &buscfg, SPI_DMA_CH_AUTO));
// Configure panel IO
esp_lcd_panel_io_spi_config_t io_config = {
.dc_gpio_num = PIN_NUM_DC,
.cs_gpio_num = PIN_NUM_CS,
.pclk_hz = 40 * 1000 * 1000,
.spi_mode = 0,
.trans_queue_depth = 10,
};
esp_lcd_panel_io_handle_t io_handle;
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi(HOST_ID, &io_config, &io_handle));
// Configure panel
esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = PIN_NUM_RST,
.rgb_endian = ESP_LCD_COLOR_SPACE_BGR,
.bits_per_pixel = 16,
};
esp_lcd_panel_handle_t panel_handle;
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
if (PIN_NUM_BL != -1) {
gpio_config_t bk_gpio_config = {
.pin_bit_mask = 1ULL << PIN_NUM_BL,
.mode = GPIO_MODE_OUTPUT,
};
gpio_config(&bk_gpio_config);
gpio_set_level(PIN_NUM_BL, 1);
}
// Initialize LVGL
lv_init();
// Configure LVGL buffer
static lv_color_t buf1[DISP_BUF_SIZE];
static lv_color_t buf2[DISP_BUF_SIZE];
static lv_disp_draw_buf_t disp_buf;
lv_disp_draw_buf_init(&disp_buf, buf1, buf2, DISP_BUF_SIZE);
// Register the display driver in LVGL
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.flush_cb = disp_driver_flush;
disp_drv.draw_buf = &disp_buf;
disp_drv.hor_res = 240;
disp_drv.ver_res = 320;
disp_drv.user_data = panel_handle;
lv_disp_drv_register(&disp_drv);
// Create a simple label
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "Hello, ST7789 with LVGL!");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
ESP_LOGI(TAG, "Initialization complete, entering LVGL task loop");
while (1) {
lv_task_handler();
vTaskDelay(pdMS_TO_TICKS(10));
}
}
[{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "unknown type name 'lv_disp_drv_t'; did you mean 'lv_fs_drv_t'?",
"startLineNumber": 27,
"startColumn": 24,
"endLineNumber": 27,
"endColumn": 24
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "C/C++: IntelliSense",
"code": "20",
"severity": 8,
"message": "identifier \"lv_disp_drv_t\" is undefined",
"source": "C/C++",
"startLineNumber": 27,
"startColumn": 24,
"endLineNumber": 27,
"endColumn": 37
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "unknown type name 'lv_disp_draw_buf_t'",
"startLineNumber": 84,
"startColumn": 12,
"endLineNumber": 84,
"endColumn": 12
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "C/C++: IntelliSense",
"code": "20",
"severity": 8,
"message": "identifier \"lv_disp_draw_buf_t\" is undefined",
"source": "C/C++",
"startLineNumber": 84,
"startColumn": 12,
"endLineNumber": 84,
"endColumn": 30
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "implicit declaration of function 'lv_disp_draw_buf_init'; did you mean 'lv_draw_buf_init'? [-Werror=implicit-function-declaration]",
"startLineNumber": 85,
"startColumn": 5,
"endLineNumber": 85,
"endColumn": 5
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "unknown type name 'lv_disp_drv_t'; did you mean 'lv_fs_drv_t'?",
"startLineNumber": 88,
"startColumn": 5,
"endLineNumber": 88,
"endColumn": 5
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "C/C++: IntelliSense",
"code": "20",
"severity": 8,
"message": "identifier \"lv_disp_drv_t\" is undefined",
"source": "C/C++",
"startLineNumber": 88,
"startColumn": 5,
"endLineNumber": 88,
"endColumn": 18
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "implicit declaration of function 'lv_disp_drv_init'; did you mean 'lv_fs_drv_init'? [-Werror=implicit-function-declaration]",
"startLineNumber": 89,
"startColumn": 5,
"endLineNumber": 89,
"endColumn": 5
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "request for member 'flush_cb' in something not a structure or union",
"startLineNumber": 90,
"startColumn": 13,
"endLineNumber": 90,
"endColumn": 13
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "'disp_driver_flush' undeclared (first use in this function)",
"startLineNumber": 90,
"startColumn": 25,
"endLineNumber": 90,
"endColumn": 25
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "request for member 'draw_buf' in something not a structure or union",
"startLineNumber": 91,
"startColumn": 13,
"endLineNumber": 91,
"endColumn": 13
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "request for member 'hor_res' in something not a structure or union",
"startLineNumber": 92,
"startColumn": 13,
"endLineNumber": 92,
"endColumn": 13
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "request for member 'ver_res' in something not a structure or union",
"startLineNumber": 93,
"startColumn": 13,
"endLineNumber": 93,
"endColumn": 13
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "request for member 'user_data' in something not a structure or union",
"startLineNumber": 94,
"startColumn": 13,
"endLineNumber": 94,
"endColumn": 13
},{
"resource": "/c:/Workspace/ESP-IDF/test/main/hello_world_main.c",
"owner": "cpp",
"severity": 8,
"message": "implicit declaration of function 'lv_disp_drv_register'; did you mean 'lv_fs_drv_register'? [-Werror=implicit-function-declaration]",
"startLineNumber": 95,
"startColumn": 5,
"endLineNumber": 95,
"endColumn": 5
}]