Update LVGL (master 9.2+) and related libraries (#130)

- LVGL 9.2+ (master commit)
- esp_lvgl_port (master with my PR hotfix changes)
- espressif/esp_lcd_touch_gt911 1.1.1~2
This commit is contained in:
Ken Van Hoeylandt
2024-12-16 23:30:57 +01:00
committed by GitHub
parent e4b8519f67
commit 80b69b7f45
90 changed files with 7328 additions and 469 deletions
@@ -12,11 +12,11 @@
#pragma once
#include "esp_err.h"
#include "esp_lvgl_port_button.h"
#include "esp_lvgl_port_compatibility.h"
#include "lvgl.h"
#include "esp_lvgl_port_disp.h"
#include "esp_lvgl_port_knob.h"
#include "esp_lvgl_port_touch.h"
#include "esp_lvgl_port_knob.h"
#include "esp_lvgl_port_button.h"
#include "esp_lvgl_port_usbhid.h"
#if LVGL_VERSION_MAJOR == 8
@@ -27,6 +27,23 @@
extern "C" {
#endif
/**
* @brief LVGL Port task event type
*/
typedef enum {
LVGL_PORT_EVENT_DISPLAY = 1,
LVGL_PORT_EVENT_TOUCH = 2,
LVGL_PORT_EVENT_USER = 99,
} lvgl_port_event_type_t;
/**
* @brief LVGL Port task events
*/
typedef struct {
lvgl_port_event_type_t type;
void *param;
} lvgl_port_event_t;
/**
* @brief Init configuration structure
*/
@@ -72,6 +89,7 @@ esp_err_t lvgl_port_init(const lvgl_port_cfg_t *cfg);
*
* @return
* - ESP_OK on success
* - ESP_ERR_TIMEOUT when stopping the LVGL task times out
*/
esp_err_t lvgl_port_deinit(void);
@@ -101,7 +119,7 @@ void lvgl_port_unlock(void);
void lvgl_port_flush_ready(lv_display_t *disp);
/**
* @brief Stop lvgl task
* @brief Stop lvgl timer
*
*
* @return
@@ -111,7 +129,7 @@ void lvgl_port_flush_ready(lv_display_t *disp);
esp_err_t lvgl_port_stop(void);
/**
* @brief Resume lvgl task
* @brief Resume lvgl timer
*
*
* @return
@@ -120,6 +138,20 @@ esp_err_t lvgl_port_stop(void);
*/
esp_err_t lvgl_port_resume(void);
/**
* @brief Notify LVGL task, that display need reload
*
* @note It is called from LVGL events and touch interrupts
*
* @param event event type
* @param param user param
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if it is not implemented
* - ESP_ERR_INVALID_STATE if queue is not initialized (can be returned after LVGL deinit)
*/
esp_err_t lvgl_port_task_wake(lvgl_port_event_type_t event, void *param);
#ifdef __cplusplus
}
#endif
@@ -19,6 +19,13 @@ extern "C" {
* @brief Backward compatibility with LVGL 8
*/
typedef lv_disp_t lv_display_t;
typedef enum {
LV_DISPLAY_ROTATION_0 = LV_DISP_ROT_NONE,
LV_DISPLAY_ROTATION_90 = LV_DISP_ROT_90,
LV_DISPLAY_ROTATION_180 = LV_DISP_ROT_180,
LV_DISPLAY_ROTATION_270 = LV_DISP_ROT_270
} lv_disp_rotation_t;
typedef lv_disp_rotation_t lv_display_rotation_t;
#ifdef __cplusplus
}
@@ -39,24 +39,54 @@ typedef struct {
typedef struct {
esp_lcd_panel_io_handle_t io_handle; /*!< LCD panel IO handle */
esp_lcd_panel_handle_t panel_handle; /*!< LCD panel handle */
uint32_t buffer_size; /*!< Size of the buffer for the screen in pixels */
bool double_buffer; /*!< True, if should be allocated two buffers */
uint32_t trans_size; /*!< Allocated buffer will be in SRAM to move framebuf */
esp_lcd_panel_handle_t control_handle; /*!< LCD panel control handle */
uint32_t buffer_size; /*!< Size of the buffer for the screen in pixels */
bool double_buffer; /*!< True, if should be allocated two buffers */
uint32_t trans_size; /*!< Allocated buffer will be in SRAM to move framebuf (optional) */
uint32_t hres; /*!< LCD display horizontal resolution */
uint32_t vres; /*!< LCD display vertical resolution */
bool monochrome; /*!< True, if display is monochrome and using 1bit for 1px */
lvgl_port_rotation_cfg_t rotation; /*!< Default values of the screen rotation */
bool monochrome; /*!< True, if display is monochrome and using 1bit for 1px */
lvgl_port_rotation_cfg_t rotation; /*!< Default values of the screen rotation (Only HW state. Not supported for default SW rotation!) */
#if LVGL_VERSION_MAJOR >= 9
lv_color_format_t color_format; /*!< The color format of the display */
#endif
struct {
unsigned int buff_dma: 1; /*!< Allocated LVGL buffer will be DMA capable */
unsigned int buff_spiram: 1; /*!< Allocated LVGL buffer will be in PSRAM */
unsigned int sw_rotate: 1; /*!< Use software rotation (slower) */
unsigned int swap_bytes: 1; /*!< Swap bytes in RGB656 (16-bit) before send to LCD driver */
unsigned int sw_rotate: 1; /*!< Use software rotation (slower) or PPA if available */
#if LVGL_VERSION_MAJOR >= 9
unsigned int swap_bytes: 1; /*!< Swap bytes in RGB656 (16-bit) color format before send to LCD driver */
#endif
unsigned int full_refresh: 1;/*!< 1: Always make the whole screen redrawn */
unsigned int direct_mode: 1; /*!< 1: Use screen-sized buffers and draw to absolute coordinates */
} flags;
} lvgl_port_display_cfg_t;
/**
* @brief Add display handling to LVGL
* @brief Configuration RGB display structure
*/
typedef struct {
struct {
unsigned int bb_mode: 1; /*!< 1: Use bounce buffer mode */
unsigned int avoid_tearing: 1; /*!< 1: Use internal RGB buffers as a LVGL draw buffers to avoid tearing effect, enabling this option requires over two LCD buffers and may reduce the frame rate */
} flags;
} lvgl_port_display_rgb_cfg_t;
/**
* @brief Configuration MIPI-DSI display structure
*/
typedef struct {
struct {
unsigned int avoid_tearing: 1; /*!< 1: Use internal MIPI-DSI buffers as a LVGL draw buffers to avoid tearing effect, enabling this option requires over two LCD buffers and may reduce the frame rate */
} flags;
} lvgl_port_display_dsi_cfg_t;
/**
* @brief Add I2C/SPI/I8080 display handling to LVGL
*
* @note Allocated memory in this function is not free in deinit. You must call lvgl_port_remove_disp for free all memory!
*
@@ -65,6 +95,28 @@ typedef struct {
*/
lv_display_t *lvgl_port_add_disp(const lvgl_port_display_cfg_t *disp_cfg);
/**
* @brief Add MIPI-DSI display handling to LVGL
*
* @note Allocated memory in this function is not free in deinit. You must call lvgl_port_remove_disp for free all memory!
*
* @param disp_cfg Display configuration structure
* @param dsi_cfg MIPI-DSI display specific configuration structure
* @return Pointer to LVGL display or NULL when error occurred
*/
lv_display_t *lvgl_port_add_disp_dsi(const lvgl_port_display_cfg_t *disp_cfg, const lvgl_port_display_dsi_cfg_t *dsi_cfg);
/**
* @brief Add RGB display handling to LVGL
*
* @note Allocated memory in this function is not free in deinit. You must call lvgl_port_remove_disp for free all memory!
*
* @param disp_cfg Display configuration structure
* @param rgb_cfg RGB display specific configuration structure
* @return Pointer to LVGL display or NULL when error occurred
*/
lv_display_t *lvgl_port_add_disp_rgb(const lvgl_port_display_cfg_t *disp_cfg, const lvgl_port_display_rgb_cfg_t *rgb_cfg);
/**
* @brief Remove display handling from LVGL
*
@@ -15,6 +15,9 @@
#include "lvgl.h"
#if __has_include ("iot_knob.h")
#if !__has_include("iot_button.h")
#error LVLG Knob requires button component. Please add it with idf.py add-dependency espressif/button
#endif
#include "iot_knob.h"
#include "iot_button.h"
#define ESP_LVGL_PORT_KNOB_COMPONENT 1
@@ -0,0 +1,90 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#if !CONFIG_LV_DRAW_SW_ASM_CUSTOM
#warning "esp_lvgl_port_lv_blend.h included, but CONFIG_LV_DRAW_SW_ASM_CUSTOM not set. Assembly rendering not used"
#else
/*********************
* DEFINES
*********************/
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_ARGB8888
#define LV_DRAW_SW_COLOR_BLEND_TO_ARGB8888(dsc) \
_lv_color_blend_to_argb8888_esp(dsc)
#endif
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_RGB565
#define LV_DRAW_SW_COLOR_BLEND_TO_RGB565(dsc) \
_lv_color_blend_to_rgb565_esp(dsc)
#endif
/**********************
* TYPEDEFS
**********************/
typedef struct {
uint32_t opa;
void *dst_buf;
uint32_t dst_w;
uint32_t dst_h;
uint32_t dst_stride;
const void *src_buf;
uint32_t src_stride;
const lv_opa_t *mask_buf;
uint32_t mask_stride;
} asm_dsc_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
extern int lv_color_blend_to_argb8888_esp(asm_dsc_t *asm_dsc);
static inline lv_result_t _lv_color_blend_to_argb8888_esp(_lv_draw_sw_blend_fill_dsc_t *dsc)
{
asm_dsc_t asm_dsc = {
.dst_buf = dsc->dest_buf,
.dst_w = dsc->dest_w,
.dst_h = dsc->dest_h,
.dst_stride = dsc->dest_stride,
.src_buf = &dsc->color,
};
return lv_color_blend_to_argb8888_esp(&asm_dsc);
}
extern int lv_color_blend_to_rgb565_esp(asm_dsc_t *asm_dsc);
static inline lv_result_t _lv_color_blend_to_rgb565_esp(_lv_draw_sw_blend_fill_dsc_t *dsc)
{
asm_dsc_t asm_dsc = {
.dst_buf = dsc->dest_buf,
.dst_w = dsc->dest_w,
.dst_h = dsc->dest_h,
.dst_stride = dsc->dest_stride,
.src_buf = &dsc->color,
};
return lv_color_blend_to_rgb565_esp(&asm_dsc);
}
#endif // CONFIG_LV_DRAW_SW_ASM_CUSTOM
#ifdef __cplusplus
} /*extern "C"*/
#endif