Update to LVGL 9.0.0 (#47)

- Updated LVGL from 8.3 to 9.0 (removed example/docs/demo folders)
- Updated esp_lvgl_port  to current status of the `lvgl9` branch on `esp-bsp`: https://github.com/espressif/esp-bsp/tree/lvgl9
- Updated all boards and drivers
- Removed `libs/lv_drivers` subproject as SDL is now supported by LVGL directly (although keyboard input seems broken)
- Updated `libs/lv_screenshot`
- Fixed the way `tt_statusbar` widget works due to behaviour change in LVGL
- Updated other lvgl code
This commit is contained in:
Ken Van Hoeylandt
2024-02-18 17:40:02 +01:00
committed by GitHub
parent 5fef25fb13
commit 473fb673bd
1630 changed files with 142517 additions and 182264 deletions
+4 -2
View File
@@ -44,7 +44,7 @@ void tdeck_backlight_set(uint8_t duty) {
}
}
lv_disp_t* tdeck_display_init() {
lv_display_t* tdeck_display_init() {
const esp_lcd_panel_io_spi_config_t panel_io_config = {
.cs_gpio_num = TDECK_LCD_PIN_CS,
.dc_gpio_num = TDECK_LCD_PIN_DC,
@@ -134,10 +134,12 @@ lv_disp_t* tdeck_display_init() {
.flags = {
.buff_dma = false,
.buff_spiram = true,
.sw_rotate = false,
.swap_bytes = true
}
};
lv_disp_t* display = lvgl_port_add_disp(&disp_cfg);
lv_display_t* display = lvgl_port_add_disp(&disp_cfg);
return display;
}
+2 -2
View File
@@ -1,13 +1,13 @@
#pragma once
#include "hal/lv_hal_disp.h"
#include "lvgl.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
lv_disp_t* tdeck_display_init();
lv_display_t* tdeck_display_init();
bool tdeck_backlight_init();
+6 -14
View File
@@ -1,6 +1,6 @@
#include "keyboard.h"
#include "config.h"
#include "hal/lv_hal.h"
#include "lvgl.h"
#include "tactility_core.h"
#include "ui/lvgl_keypad.h"
#include <driver/i2c.h>
@@ -8,7 +8,6 @@
#define TAG "tdeck_keyboard"
typedef struct {
lv_indev_drv_t* driver;
lv_indev_t* device;
} KeyboardData;
@@ -44,7 +43,7 @@ void keyboard_wait_for_response() {
* @param indev_drv
* @param data
*/
static void keyboard_read_callback(TT_UNUSED struct _lv_indev_drv_t* indev_drv, lv_indev_data_t* data) {
static void keyboard_read_callback(TT_UNUSED lv_indev_t* indev, lv_indev_data_t* data) {
static uint8_t last_buffer = 0x00;
uint8_t read_buffer = 0x00;
@@ -70,16 +69,10 @@ static void keyboard_read_callback(TT_UNUSED struct _lv_indev_drv_t* indev_drv,
Keyboard keyboard_alloc(_Nullable lv_disp_t* display) {
KeyboardData* data = malloc(sizeof(KeyboardData));
data->driver = malloc(sizeof(lv_indev_drv_t));
memset(data->driver, 0, sizeof(lv_indev_drv_t));
lv_indev_drv_init(data->driver);
data->driver->type = LV_INDEV_TYPE_KEYPAD;
data->driver->read_cb = &keyboard_read_callback;
data->driver->disp = display;
data->device = lv_indev_drv_register(data->driver);
tt_check(data->device != NULL);
data->device = lv_indev_create();
lv_indev_set_type(data->device, LV_INDEV_TYPE_KEYPAD);
lv_indev_set_read_cb(data->device, &keyboard_read_callback);
lv_indev_set_display(data->device, display);
tt_lvgl_keypad_set_indev(data->device);
@@ -89,6 +82,5 @@ Keyboard keyboard_alloc(_Nullable lv_disp_t* display) {
void keyboard_free(Keyboard keyboard) {
KeyboardData* data = (KeyboardData*)keyboard;
lv_indev_delete(data->device);
free(data->driver);
free(data);
}
-1
View File
@@ -29,7 +29,6 @@
#define WAVESHARE_LCD_PIN_NUM_DATA15 40 // R7
#define WAVESHARE_LCD_PIN_NUM_DISP_EN (-1)
#define WAVESHARE_LCD_BUFFER_HEIGHT (WAVESHARE_LCD_VER_RES / 3) // How many rows of pixels to buffer - 1/3rd is about 1MB
#define WAVESHARE_LCD_BUFFER_SIZE (WAVESHARE_LCD_HOR_RES * WAVESHARE_LCD_BUFFER_HEIGHT * sizeof(lv_color_t))
#define WAVESHARE_LCD_USE_DOUBLE_FB true // Performance boost at the cost of about extra PSRAM(SPIRAM)
+17 -29
View File
@@ -81,8 +81,8 @@ static void lvgl_tick_task(TT_UNUSED void* arg) {
lv_tick_inc(WAVESHARE_LVGL_TICK_PERIOD_MS);
}
static void display_flush_callback(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;
static void display_flush_callback(lv_display_t* disp, const lv_area_t* area, uint8_t* px_map) {
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t)lv_display_get_user_data(disp);
int offsetx1 = area->x1;
int offsetx2 = area->x2;
int offsety1 = area->y1;
@@ -90,14 +90,12 @@ static void display_flush_callback(lv_disp_drv_t* drv, const lv_area_t* area, lv
xSemaphoreGive(sem_gui_ready);
xSemaphoreTake(sem_vsync_end, portMAX_DELAY);
// pass the draw buffer to the driver
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map);
lv_disp_flush_ready(drv);
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, px_map);
lv_disp_flush_ready(disp);
}
lv_disp_t* ws3t_display_create() {
TT_LOG_I(TAG, "display init");
static lv_disp_drv_t display_driver;
static lv_disp_draw_buf_t display_buffer;
sem_vsync_end = xSemaphoreCreateBinary();
tt_assert(sem_vsync_end);
@@ -151,7 +149,7 @@ lv_disp_t* ws3t_display_create() {
.on_bounce_empty = NULL,
.on_bounce_frame_finish = NULL
};
if (esp_lcd_rgb_panel_register_event_callbacks(panel_handle, &cbs, &display_driver) != ESP_OK) {
if (esp_lcd_rgb_panel_register_event_callbacks(panel_handle, &cbs, NULL) != ESP_OK) {
TT_LOG_E(TAG, "Failed to register callbacks");
return NULL;
}
@@ -170,33 +168,23 @@ lv_disp_t* ws3t_display_create() {
NULL;
#if WAVESHARE_LCD_USE_DOUBLE_FB
void* buffer1 = heap_caps_malloc(WAVESHARE_LCD_BUFFER_SIZE, MALLOC_CAP_SPIRAM);
void* buffer2 = heap_caps_malloc(WAVESHARE_LCD_BUFFER_SIZE, MALLOC_CAP_SPIRAM);
// initialize LVGL draw buffers
lv_draw_buf_t* buffer1 = lv_draw_buf_create(WAVESHARE_LCD_HOR_RES, WAVESHARE_LCD_BUFFER_HEIGHT, LV_COLOR_FORMAT_RGB565, 0);
lv_draw_buf_t* buffer2 = lv_draw_buf_create(WAVESHARE_LCD_HOR_RES, WAVESHARE_LCD_BUFFER_HEIGHT, LV_COLOR_FORMAT_RGB565, 0);
tt_assert(buffer1);
tt_assert(buffer2);
// initialize LVGL draw buffers
lv_disp_draw_buf_init(&display_buffer, buffer1, buffer2, WAVESHARE_LCD_HOR_RES * WAVESHARE_LCD_BUFFER_HEIGHT);
#else
ESP_LOGI(TAG, "Allocate separate LVGL draw buffers from PSRAM");
void* buffer = heap_caps_malloc(WAVESHARE_LCD_BUFFER_SIZE, MALLOC_CAP_SPIRAM);
tt_assert(buffer);
lv_disp_draw_buf_init(&display_buffer, buffer, NULL, WAVESHARE_LCD_H_RES * WAVESHARE_BUFFER_HEIGHT);
lv_draw_buf_t* buffer1 = lv_draw_buf_create(WAVESHARE_LCD_HOR_RES, WAVESHARE_LCD_VER_RES, LV_COLOR_FORMAT_RGB565, 0);
lv_draw_buf_t* buffer2 = NULL;
tt_assert(buffer1);
#endif // WAVESHARE_USE_DOUBLE_FB
lv_disp_drv_init(&display_driver);
display_driver.hor_res = WAVESHARE_LCD_HOR_RES;
display_driver.ver_res = WAVESHARE_LCD_VER_RES;
display_driver.flush_cb = display_flush_callback;
display_driver.draw_buf = &display_buffer;
display_driver.user_data = panel_handle;
display_driver.antialiasing = false;
display_driver.direct_mode = false;
display_driver.sw_rotate = false;
display_driver.rotated = 0;
display_driver.screen_transp = false;
display_driver.full_refresh = WAVESHARE_LCD_USE_DOUBLE_FB; // Maintains the synchronization between the two frame buffers
lv_disp_t* display = lv_disp_drv_register(&display_driver);
lv_display_t* display = lv_display_create(WAVESHARE_LCD_HOR_RES, WAVESHARE_LCD_VER_RES);
lv_display_set_draw_buffers(display, buffer1, buffer2);
lv_display_set_flush_cb(display, &display_flush_callback);
lv_display_set_user_data(display, panel_handle);
lv_display_set_antialiasing(display, false);
lv_display_set_render_mode(display, LV_DISPLAY_RENDER_MODE_PARTIAL);
const esp_timer_create_args_t lvgl_tick_timer_args = {
.callback = &lvgl_tick_task,
+2 -2
View File
@@ -1,6 +1,6 @@
#pragma once
#include "hal/lv_hal_disp.h"
#include "lvgl.h"
#include <stdbool.h>
#include <stdint.h>
@@ -11,7 +11,7 @@ extern "C" {
bool ws3t_display_lock(uint32_t timeout_ms);
void ws3t_display_unlock(void);
lv_disp_t* ws3t_display_create();
lv_display_t* ws3t_display_create();
void ws3t_display_destroy();
#ifdef __cplusplus
+1 -1
View File
@@ -7,7 +7,7 @@
bool ws3t_init_lvgl() {
tt_lvgl_sync_set(&ws3t_display_lock, &ws3t_display_unlock);
lv_disp_t* display = ws3t_display_create();
lv_display_t* display = ws3t_display_create();
if (display == NULL) {
return false;
}
+13 -12
View File
@@ -4,7 +4,7 @@
#include "esp_err.h"
#include "esp_lcd_touch_gt911.h"
#include "esp_log.h"
#include "lv_api_map.h"
#include "lvgl.h"
#define TAG "waveshare_s3_touch_i2c"
@@ -33,16 +33,17 @@ static esp_lcd_touch_handle_t touch_init_internal() {
return tp;
}
static void touch_callback(lv_indev_drv_t* drv, lv_indev_data_t* data) {
static void touch_callback(lv_indev_t* indev, lv_indev_data_t* data) {
uint16_t touchpad_x[1] = {0};
uint16_t touchpad_y[1] = {0};
uint8_t touchpad_cnt = 0;
/* Read touch controller data */
esp_lcd_touch_read_data(drv->user_data);
esp_lcd_touch_handle_t touch_handle = lv_indev_get_user_data(indev);
esp_lcd_touch_read_data(touch_handle);
/* Get coordinates */
bool touchpad_pressed = esp_lcd_touch_get_coordinates(drv->user_data, touchpad_x, touchpad_y, NULL, &touchpad_cnt, 1);
bool touchpad_pressed = esp_lcd_touch_get_coordinates(touch_handle, touchpad_x, touchpad_y, NULL, &touchpad_cnt, 1);
if (touchpad_pressed && touchpad_cnt > 0) {
data->point.x = touchpad_x[0];
@@ -53,15 +54,15 @@ static void touch_callback(lv_indev_drv_t* drv, lv_indev_data_t* data) {
}
}
void ws3t_touch_init(lv_disp_t* display) {
void ws3t_touch_init(lv_display_t* display) {
esp_lcd_touch_handle_t touch_handle = touch_init_internal();
ESP_LOGI(TAG, "Register display indev to LVGL");
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.disp = display;
indev_drv.read_cb = &touch_callback;
indev_drv.user_data = touch_handle;
lv_indev_drv_register(&indev_drv); // TODO: store result for deinit purposes
static lv_indev_t* device = NULL;
device = lv_indev_create();
lv_indev_set_type(device, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(device, &touch_callback);
lv_indev_set_display(device, display);
lv_indev_set_user_data(device, touch_handle);
}
+2 -2
View File
@@ -1,12 +1,12 @@
#pragma once
#include "hal/lv_hal.h"
#include "lvgl.h"
#ifdef __cplusplus
extern "C" {
#endif
void ws3t_touch_init(lv_disp_t* display);
void ws3t_touch_init(lv_display_t* display);
#ifdef __cplusplus
}
+4 -2
View File
@@ -8,7 +8,6 @@
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lvgl_port.h"
#include "hal/lv_hal_disp.h"
#define TAG "twodotfour_ili9341"
@@ -117,10 +116,13 @@ lv_disp_t* twodotfour_display_init() {
},
.flags = {
.buff_dma = true,
.buff_spiram = false,
.sw_rotate = false,
.swap_bytes = true
}
};
lv_disp_t* display = lvgl_port_add_disp(&disp_cfg);
lv_display_t* display = lvgl_port_add_disp(&disp_cfg);
return display;
}
+2 -2
View File
@@ -5,11 +5,11 @@
#define TAG "twodotfour_lvgl"
lv_disp_t* twodotfour_display_init();
lv_display_t* twodotfour_display_init();
bool twodotfour_touch_init(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle);
bool twodotfour_lvgl_init() {
static lv_disp_t* display = NULL;
static lv_display_t* display = NULL;
static esp_lcd_panel_io_handle_t touch_io_handle;
static esp_lcd_touch_handle_t touch_handle;