From 0f7b99e2daa364005e105a7e2ffdf5b51f91f27c Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 14 Nov 2021 00:03:04 -0500 Subject: [PATCH] [bsp][stm32l475] update lvgl driver --- .../board/ports/lvgl/lv_port_disp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/lvgl/lv_port_disp.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/lvgl/lv_port_disp.c index 513ea763c4..dc89df722f 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/ports/lvgl/lv_port_disp.c +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/lvgl/lv_port_disp.c @@ -11,13 +11,14 @@ #include #define MY_DISP_HOR_RES LCD_W +#define DISP_BUFFER_LINES 10 /*A static or global variable to store the buffers*/ static lv_disp_draw_buf_t disp_buf; /*Static or global buffer(s). The second buffer is optional*/ -static lv_color_t buf_1[MY_DISP_HOR_RES * 10]; -static lv_color_t buf_2[MY_DISP_HOR_RES * 10]; +static lv_color_t buf_1[MY_DISP_HOR_RES * DISP_BUFFER_LINES]; +static lv_color_t buf_2[MY_DISP_HOR_RES * DISP_BUFFER_LINES]; static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ @@ -26,6 +27,7 @@ static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ *'lv_disp_flush_ready()' has to be called when finished.*/ static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) { + /* color_p is a buffer pointer; the buffer is provided by LVGL */ lcd_fill_array(area->x1, area->y1, area->x2, area->y2, color_p); /*IMPORTANT!!! @@ -36,13 +38,13 @@ static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_colo void lv_port_disp_init(void) { /*Initialize `disp_buf` with the buffer(s). With only one buffer use NULL instead buf_2 */ - lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, MY_DISP_HOR_RES*10); + lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, MY_DISP_HOR_RES * DISP_BUFFER_LINES); lv_disp_drv_init(&disp_drv); /*Basic initialization*/ /*Set the resolution of the display*/ - disp_drv.hor_res = MY_DISP_HOR_RES; - disp_drv.ver_res = MY_DISP_HOR_RES; + disp_drv.hor_res = LCD_W; + disp_drv.ver_res = LCD_H; /*Set a display buffer*/ disp_drv.draw_buf = &disp_buf;