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:
committed by
GitHub
parent
5fef25fb13
commit
473fb673bd
@@ -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)
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user