From 81a36703ea8743553788c5e8a718642738a07de9 Mon Sep 17 00:00:00 2001 From: Vilem Zavodny Date: Fri, 26 Apr 2024 15:01:51 +0200 Subject: [PATCH] update --- .../esp32_p4_function_ev_board.c | 2 - .../examples/rgb_lcd/main/main.c | 15 +++---- .../include/esp_lvgl_port_disp.h | 2 +- .../priv_include/esp_lvgl_port_priv.h | 7 +++ .../src/lvgl8/esp_lvgl_port_disp.c | 38 +++++++++------- .../src/lvgl9/esp_lvgl_port_disp.c | 44 +++++++++++-------- 6 files changed, 61 insertions(+), 47 deletions(-) diff --git a/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c b/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c index 7c0a7acd9..d8e4004d1 100644 --- a/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c +++ b/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c @@ -348,7 +348,6 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) .control_handle = lcd_panels.control, .buffer_size = cfg->buffer_size, .double_buffer = cfg->double_buffer, - .trans_size = (cfg->flags.sw_rotate ? BSP_LCD_H_RES * 50 : 0), .hres = BSP_LCD_V_RES, .vres = BSP_LCD_H_RES, .monochrome = false, @@ -362,7 +361,6 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) .buff_dma = cfg->flags.buff_dma, .buff_spiram = cfg->flags.buff_spiram, .swap_bytes = (BSP_LCD_BIGENDIAN ? true : false), - .sw_rotate = cfg->flags.sw_rotate, /* Only SW rotation is supported for 90° and 270° */ } }; diff --git a/components/esp_lvgl_port/examples/rgb_lcd/main/main.c b/components/esp_lvgl_port/examples/rgb_lcd/main/main.c index cf445550b..450b41868 100644 --- a/components/esp_lvgl_port/examples/rgb_lcd/main/main.c +++ b/components/esp_lvgl_port/examples/rgb_lcd/main/main.c @@ -179,8 +179,6 @@ static esp_err_t app_touch_init(void) static esp_err_t app_lvgl_init(void) { - void *user_buf1 = NULL; - void *user_buf2 = NULL; /* Initialize LVGL */ const lvgl_port_cfg_t lvgl_cfg = { .task_priority = 4, /* LVGL task priority */ @@ -196,19 +194,11 @@ static esp_err_t app_lvgl_init(void) buff_size = EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES; #endif -#if EXAMPLE_LCD_LVGL_AVOID_TEAR - buff_size = EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES; - ESP_RETURN_ON_ERROR(esp_lcd_rgb_panel_get_frame_buffer(lcd_panel, 2, &user_buf1, &user_buf2), TAG, "Get RGB buffers failed"); - assert(user_buf1); - assert(user_buf2); -#endif - /* Add LCD screen */ ESP_LOGD(TAG, "Add LCD screen"); const lvgl_port_display_cfg_t disp_cfg = { .panel_handle = lcd_panel, .buffer_size = buff_size, - .user_buffers = {user_buf1, user_buf2}, .double_buffer = EXAMPLE_LCD_DRAW_BUFF_DOUBLE, .hres = EXAMPLE_LCD_H_RES, .vres = EXAMPLE_LCD_V_RES, @@ -240,6 +230,11 @@ static esp_err_t app_lvgl_init(void) .bb_mode = true, #else .bb_mode = false, +#endif +#if EXAMPLE_LCD_LVGL_AVOID_TEAR + .avoid_tearing = true, +#else + .avoid_tearing = false, #endif } }; diff --git a/components/esp_lvgl_port/include/esp_lvgl_port_disp.h b/components/esp_lvgl_port/include/esp_lvgl_port_disp.h index f7b66b050..f78d70c2e 100644 --- a/components/esp_lvgl_port/include/esp_lvgl_port_disp.h +++ b/components/esp_lvgl_port/include/esp_lvgl_port_disp.h @@ -44,7 +44,6 @@ typedef struct { 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) */ - void *user_buffers[2]; /*!< Put own buffers for LVGL (optional) */ uint32_t hres; /*!< LCD display horizontal resolution */ uint32_t vres; /*!< LCD display vertical resolution */ @@ -75,6 +74,7 @@ typedef struct { 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 */ } flags; } lvgl_port_display_rgb_cfg_t; diff --git a/components/esp_lvgl_port/priv_include/esp_lvgl_port_priv.h b/components/esp_lvgl_port/priv_include/esp_lvgl_port_priv.h index f50cf4481..16bdca3bd 100644 --- a/components/esp_lvgl_port/priv_include/esp_lvgl_port_priv.h +++ b/components/esp_lvgl_port/priv_include/esp_lvgl_port_priv.h @@ -24,6 +24,13 @@ typedef enum { LVGL_PORT_DISP_TYPE_RGB, } lvgl_port_disp_type_t; +/** + * @brief Rotation configuration + */ +typedef struct { + unsigned int avoid_tearing: 1; /*!< Use internal RGB buffers as a LVGL draw buffers to avoid tearing effect */ +} lvgl_port_disp_priv_cfg_t; + /** * @brief Notify LVGL task * diff --git a/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_disp.c b/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_disp.c index d7237dcd9..da9f91639 100644 --- a/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_disp.c +++ b/components/esp_lvgl_port/src/lvgl8/esp_lvgl_port_disp.c @@ -52,7 +52,7 @@ typedef struct { /******************************************************************************* * Function definitions *******************************************************************************/ -static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cfg); +static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cfg, const lvgl_port_disp_priv_cfg_t *priv_cfg); static lvgl_port_display_ctx_t *lvgl_port_get_display_ctx(lv_disp_t *disp); #if LVGL_PORT_HANDLE_FLUSH_READY static bool lvgl_port_flush_io_ready_callback(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx); @@ -73,7 +73,7 @@ static void lvgl_port_pix_monochrome_callback(lv_disp_drv_t *drv, uint8_t *buf, lv_disp_t *lvgl_port_add_disp(const lvgl_port_display_cfg_t *disp_cfg) { - lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg); + lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, NULL); if (disp != NULL) { lvgl_port_display_ctx_t *disp_ctx = lvgl_port_get_display_ctx(disp); @@ -93,7 +93,7 @@ lv_disp_t *lvgl_port_add_disp(const lvgl_port_display_cfg_t *disp_cfg) 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) { - lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg); + lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, NULL); if (disp != NULL) { lvgl_port_display_ctx_t *disp_ctx = lvgl_port_get_display_ctx(disp); @@ -117,7 +117,10 @@ lv_display_t *lvgl_port_add_disp_dsi(const lvgl_port_display_cfg_t *disp_cfg, co 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) { assert(rgb_cfg != NULL); - lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg); + const lvgl_port_disp_priv_cfg_t priv_cfg = { + .avoid_tearing = rgb_cfg->flags.avoid_tearing, + }; + lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, &priv_cfg); if (disp != NULL) { lvgl_port_display_ctx_t *disp_ctx = lvgl_port_get_display_ctx(disp); @@ -198,13 +201,14 @@ static lvgl_port_display_ctx_t *lvgl_port_get_display_ctx(lv_disp_t *disp) return disp_ctx; } -static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cfg) +static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cfg, const lvgl_port_disp_priv_cfg_t *priv_cfg) { esp_err_t ret = ESP_OK; lv_disp_t *disp = NULL; lv_color_t *buf1 = NULL; lv_color_t *buf2 = NULL; lv_color_t *buf3 = NULL; + uint32_t buffer_size = 0; SemaphoreHandle_t trans_sem = NULL; assert(disp_cfg != NULL); assert(disp_cfg->panel_handle != NULL); @@ -224,10 +228,12 @@ static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cf disp_ctx->rotation.mirror_y = disp_cfg->rotation.mirror_y; disp_ctx->trans_size = disp_cfg->trans_size; - /* Use user buffers */ - if (disp_cfg->user_buffers[0] || disp_cfg->user_buffers[1]) { - buf1 = disp_cfg->user_buffers[0]; - buf2 = disp_cfg->user_buffers[1]; + buffer_size = disp_cfg->buffer_size; + + /* Use RGB internal buffers for avoid tearing effect */ + if (priv_cfg && priv_cfg->avoid_tearing) { + buffer_size = disp_cfg->hres * disp_cfg->vres; + ESP_GOTO_ON_ERROR(esp_lcd_rgb_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); } else { uint32_t buff_caps = MALLOC_CAP_DEFAULT; if (disp_cfg->flags.buff_dma && disp_cfg->flags.buff_spiram && (0 == disp_cfg->trans_size)) { @@ -250,10 +256,10 @@ static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cf /* alloc draw buffers used by LVGL */ /* it's recommended to choose the size of the draw buffer(s) to be at least 1/10 screen sized */ - buf1 = heap_caps_malloc(disp_cfg->buffer_size * sizeof(lv_color_t), buff_caps); + buf1 = heap_caps_malloc(buffer_size * sizeof(lv_color_t), buff_caps); ESP_GOTO_ON_FALSE(buf1, ESP_ERR_NO_MEM, err, TAG, "Not enough memory for LVGL buffer (buf1) allocation!"); if (disp_cfg->double_buffer) { - buf2 = heap_caps_malloc(disp_cfg->buffer_size * sizeof(lv_color_t), buff_caps); + buf2 = heap_caps_malloc(buffer_size * sizeof(lv_color_t), buff_caps); ESP_GOTO_ON_FALSE(buf2, ESP_ERR_NO_MEM, err, TAG, "Not enough memory for LVGL buffer (buf2) allocation!"); } } @@ -262,7 +268,7 @@ static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cf ESP_GOTO_ON_FALSE(disp_buf, ESP_ERR_NO_MEM, err, TAG, "Not enough memory for LVGL display buffer allocation!"); /* initialize LVGL draw buffers */ - lv_disp_draw_buf_init(disp_buf, buf1, buf2, disp_cfg->buffer_size); + lv_disp_draw_buf_init(disp_buf, buf1, buf2, buffer_size); ESP_LOGD(TAG, "Register display driver to LVGL"); lv_disp_drv_init(&disp_ctx->disp_drv); @@ -280,18 +286,18 @@ static lv_disp_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cf /* Monochrome display settings */ if (disp_cfg->monochrome) { /* When using monochromatic display, there must be used full bufer! */ - ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == disp_cfg->buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Monochromatic display must using full buffer!"); + ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Monochromatic display must using full buffer!"); disp_ctx->disp_drv.full_refresh = 1; disp_ctx->disp_drv.set_px_cb = lvgl_port_pix_monochrome_callback; } else if (disp_cfg->flags.direct_mode) { /* When using direct_mode, there must be used full bufer! */ - ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == disp_cfg->buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Direct mode must using full buffer!"); + ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Direct mode must using full buffer!"); disp_ctx->disp_drv.direct_mode = 1; } else if (disp_cfg->flags.full_refresh) { /* When using full_refresh, there must be used full bufer! */ - ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == disp_cfg->buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Full refresh must using full buffer!"); + ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Full refresh must using full buffer!"); disp_ctx->disp_drv.full_refresh = 1; } @@ -365,7 +371,7 @@ static bool lvgl_port_flush_vsync_ready_callback(esp_lcd_panel_handle_t panel_io { BaseType_t need_yield = pdFALSE; - lv_disp_drv_t *disp_drv = (lv_display_t *)user_ctx; + lv_disp_drv_t *disp_drv = (lv_disp_drv_t *)user_ctx; assert(disp_drv != NULL); need_yield = lvgl_port_task_notify(ULONG_MAX); diff --git a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c index 427eee335..9d90ee5ee 100644 --- a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c +++ b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c @@ -53,7 +53,7 @@ typedef struct { /******************************************************************************* * Function definitions *******************************************************************************/ -static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cfg); +static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cfg, const lvgl_port_disp_priv_cfg_t *priv_cfg); #if LVGL_PORT_HANDLE_FLUSH_READY static bool lvgl_port_flush_io_ready_callback(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx); #if CONFIG_IDF_TARGET_ESP32S3 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) @@ -74,7 +74,7 @@ static void lvgl_port_display_invalidate_callback(lv_event_t *e); lv_display_t *lvgl_port_add_disp(const lvgl_port_display_cfg_t *disp_cfg) { - lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg); + lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, NULL); if (disp != NULL) { lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(disp); @@ -97,7 +97,7 @@ lv_display_t *lvgl_port_add_disp(const lvgl_port_display_cfg_t *disp_cfg) 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) { - lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg); + lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, NULL); if (disp != NULL) { lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(disp); @@ -123,7 +123,11 @@ lv_display_t *lvgl_port_add_disp_dsi(const lvgl_port_display_cfg_t *disp_cfg, co 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) { - lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg); + assert(rgb_cfg != NULL); + const lvgl_port_disp_priv_cfg_t priv_cfg = { + .avoid_tearing = rgb_cfg->flags.avoid_tearing, + }; + lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, &priv_cfg); if (disp != NULL) { lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(disp); @@ -190,18 +194,21 @@ void lvgl_port_flush_ready(lv_display_t *disp) * Private functions *******************************************************************************/ -static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cfg) +static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp_cfg, const lvgl_port_disp_priv_cfg_t *priv_cfg) { esp_err_t ret = ESP_OK; lv_display_t *disp = NULL; lv_color_t *buf1 = NULL; lv_color_t *buf2 = NULL; + uint32_t buffer_size = 0; assert(disp_cfg != NULL); assert(disp_cfg->panel_handle != NULL); assert(disp_cfg->buffer_size > 0); assert(disp_cfg->hres > 0); assert(disp_cfg->vres > 0); + buffer_size = disp_cfg->buffer_size; + /* Check supported display color formats */ ESP_RETURN_ON_FALSE(disp_cfg->color_format == 0 || disp_cfg->color_format == LV_COLOR_FORMAT_RGB565 || disp_cfg->color_format == LV_COLOR_FORMAT_RGB888 || disp_cfg->color_format == LV_COLOR_FORMAT_XRGB8888 || disp_cfg->color_format == LV_COLOR_FORMAT_ARGB8888, NULL, TAG, "Not supported display color format!"); @@ -228,10 +235,10 @@ static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp disp_ctx->rotation.mirror_y = disp_cfg->rotation.mirror_y; disp_ctx->flags.swap_bytes = disp_cfg->flags.swap_bytes; - /* Use user buffers */ - if (disp_cfg->user_buffers[0] || disp_cfg->user_buffers[1]) { - buf1 = disp_cfg->user_buffers[0]; - buf2 = disp_cfg->user_buffers[1]; + /* Use RGB internal buffers for avoid tearing effect */ + if (priv_cfg && priv_cfg->avoid_tearing) { + buffer_size = disp_cfg->hres * disp_cfg->vres; + ESP_GOTO_ON_ERROR(esp_lcd_rgb_panel_get_frame_buffer(disp_cfg->panel_handle, 2, (void *)&buf1, (void *)&buf2), err, TAG, "Get RGB buffers failed"); } else { uint32_t buff_caps = MALLOC_CAP_DEFAULT; if (disp_cfg->flags.buff_dma && disp_cfg->flags.buff_spiram) { @@ -244,10 +251,10 @@ static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp /* alloc draw buffers used by LVGL */ /* it's recommended to choose the size of the draw buffer(s) to be at least 1/10 screen sized */ - buf1 = heap_caps_malloc(disp_cfg->buffer_size * sizeof(lv_color_t), buff_caps); + buf1 = heap_caps_malloc(buffer_size * sizeof(lv_color_t), buff_caps); ESP_GOTO_ON_FALSE(buf1, ESP_ERR_NO_MEM, err, TAG, "Not enough memory for LVGL buffer (buf1) allocation!"); if (disp_cfg->double_buffer) { - buf2 = heap_caps_malloc(disp_cfg->buffer_size * sizeof(lv_color_t), buff_caps); + buf2 = heap_caps_malloc(buffer_size * sizeof(lv_color_t), buff_caps); ESP_GOTO_ON_FALSE(buf2, ESP_ERR_NO_MEM, err, TAG, "Not enough memory for LVGL buffer (buf2) allocation!"); } @@ -261,30 +268,31 @@ static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp /* Monochrome display settings */ if (disp_cfg->monochrome) { /* When using monochromatic display, there must be used full bufer! */ - ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == disp_cfg->buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Monochromatic display must using full buffer!"); + ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Monochromatic display must using full buffer!"); disp_ctx->flags.monochrome = 1; - lv_display_set_buffers(disp, buf1, buf2, disp_cfg->buffer_size * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_FULL); + lv_display_set_buffers(disp, buf1, buf2, buffer_size * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_FULL); } else if (disp_cfg->flags.direct_mode) { /* When using direct_mode, there must be used full bufer! */ - ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == disp_cfg->buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Direct mode must using full buffer!"); + ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Direct mode must using full buffer!"); disp_ctx->flags.direct_mode = 1; - lv_display_set_buffers(disp, buf1, buf2, disp_cfg->buffer_size * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_DIRECT); + lv_display_set_buffers(disp, buf1, buf2, buffer_size * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_DIRECT); } else if (disp_cfg->flags.full_refresh) { /* When using full_refresh, there must be used full bufer! */ - ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == disp_cfg->buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Full refresh must using full buffer!"); + ESP_GOTO_ON_FALSE((disp_cfg->hres * disp_cfg->vres == buffer_size), ESP_ERR_INVALID_ARG, err, TAG, "Full refresh must using full buffer!"); disp_ctx->flags.full_refresh = 1; - lv_display_set_buffers(disp, buf1, buf2, disp_cfg->buffer_size * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_FULL); + lv_display_set_buffers(disp, buf1, buf2, buffer_size * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_FULL); } else { - lv_display_set_buffers(disp, buf1, buf2, disp_cfg->buffer_size * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_PARTIAL); + lv_display_set_buffers(disp, buf1, buf2, buffer_size * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_PARTIAL); } lv_display_set_color_format(disp, display_color_format); lv_display_set_flush_cb(disp, lvgl_port_flush_callback); lv_display_add_event_cb(disp, lvgl_port_disp_size_update_callback, LV_EVENT_RESOLUTION_CHANGED, disp_ctx); lv_display_add_event_cb(disp, lvgl_port_display_invalidate_callback, LV_EVENT_INVALIDATE_AREA, disp_ctx); + lv_display_add_event_cb(disp, lvgl_port_display_invalidate_callback, LV_EVENT_REFR_REQUEST, disp_ctx); lv_display_set_user_data(disp, disp_ctx); disp_ctx->disp_drv = disp;