From f4aa860d8b302d6ee351fd9eb5aef485fa252a5f Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 17 Dec 2021 09:18:48 -0500 Subject: [PATCH] =?UTF-8?q?[qemu][lvgl]=20=E4=BC=98=E5=8C=96lvgl=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../drivers/lvgl/lv_port_disp.c | 54 ++----------------- bsp/simulator/drivers/lvgl/lv_conf.h | 6 ++- bsp/simulator/drivers/lvgl/lv_demo.c | 4 +- .../board/ports/lcd/drv_lcd.c | 2 +- 4 files changed, 12 insertions(+), 54 deletions(-) diff --git a/bsp/qemu-vexpress-a9/drivers/lvgl/lv_port_disp.c b/bsp/qemu-vexpress-a9/drivers/lvgl/lv_port_disp.c index 9bb856a122..66888d511d 100644 --- a/bsp/qemu-vexpress-a9/drivers/lvgl/lv_port_disp.c +++ b/bsp/qemu-vexpress-a9/drivers/lvgl/lv_port_disp.c @@ -18,72 +18,28 @@ static struct rt_device_graphic_info info; static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ -static void color_to16_maybe(lv_color16_t *dst, lv_color_t *src) -{ -#if (LV_COLOR_DEPTH == 16) - dst->full = src->full; -#else - dst->ch.blue = src->ch.blue; - dst->ch.green = src->ch.green; - dst->ch.red = src->ch.red; -#endif -} - /*Flush the content of the internal buffer the specific area on the display *You can use DMA or any hardware acceleration to do this operation in the background but *'lv_disp_flush_ready()' has to be called when finished.*/ static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) { - int x1, x2, y1, y2; - - x1 = area->x1; - x2 = area->x2; - y1 = area->y1; - y2 = area->y2; - - /*Return if the area is out the screen*/ - if (x2 < 0) - return; - if (y2 < 0) - return; - if (x1 > info.width - 1) - return; - if (y1 > info.height - 1) - return; - - /*Truncate the area to the screen*/ - int32_t act_x1 = x1 < 0 ? 0 : x1; - int32_t act_y1 = y1 < 0 ? 0 : y1; - int32_t act_x2 = x2 > info.width - 1 ? info.width - 1 : x2; - int32_t act_y2 = y2 > info.height - 1 ? info.height - 1 : y2; - uint32_t x; uint32_t y; - long int location = 0; + uint32_t location = 0; /* 16 bit per pixel */ lv_color16_t *fbp16 = (lv_color16_t *)info.framebuffer; - for (y = act_y1; y <= act_y2; y++) + for (y = area->y1; y y2 + 1; y++) { - for (x = act_x1; x <= act_x2; x++) + for (x = area->x1; x x2 + 1; x++) { - location = (x) + (y)*info.width; - color_to16_maybe(&fbp16[location], color_p); + location = x + y * info.width; + fbp16[location].full = color_p->full; color_p++; } - - color_p += x2 - act_x2; } - struct rt_device_rect_info rect_info; - - rect_info.x = x1; - rect_info.y = y1; - rect_info.width = x2 - x1 + 1; - rect_info.height = y2 - y1 + 1; - rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info); - lv_disp_flush_ready(disp_drv); } diff --git a/bsp/simulator/drivers/lvgl/lv_conf.h b/bsp/simulator/drivers/lvgl/lv_conf.h index ee05e7a8a2..0d9b3c63bc 100644 --- a/bsp/simulator/drivers/lvgl/lv_conf.h +++ b/bsp/simulator/drivers/lvgl/lv_conf.h @@ -14,8 +14,10 @@ #define LV_USE_PERF_MONITOR 1 #define LV_COLOR_DEPTH 32 -# define USE_WIN32DRV 1 -# define WIN32DRV_MONITOR_ZOOM 1 +#define USE_WIN32DRV 1 +#define WIN32DRV_MONITOR_ZOOM 1 + +#define LV_USE_FS_WIN32 1 /* music player demo */ #include diff --git a/bsp/simulator/drivers/lvgl/lv_demo.c b/bsp/simulator/drivers/lvgl/lv_demo.c index 101cd1e494..ba984fd6b8 100644 --- a/bsp/simulator/drivers/lvgl/lv_demo.c +++ b/bsp/simulator/drivers/lvgl/lv_demo.c @@ -27,7 +27,7 @@ static void lvgl_thread(void *parameter) /* initialize win32 driver; don't put this in lv_port_disp() */ if (!lv_win32_init(GetModuleHandleW(NULL), SW_SHOW, BSP_LCD_WIDTH, BSP_LCD_HEIGHT, NULL)) { - LOG_E("lv_win32_init failure!"); + LOG_E("lv_win32_init is failure!"); return; } lv_win32_add_all_input_devices_to_group(NULL); @@ -43,7 +43,7 @@ static void lvgl_thread(void *parameter) rt_thread_mdelay(1); } - LOG_W("LVGL simulator window closed!"); + LOG_W("LVGL simulator window is closed!"); } static int lvgl_demo_init(void) diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/drv_lcd.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/drv_lcd.c index 8df8a79a36..fcaf801206 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/drv_lcd.c +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/drv_lcd.c @@ -451,7 +451,7 @@ void lcd_fill_array(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, { rt_uint32_t size = 0; - size = (x_end - x_start + 1) * (y_end - y_start + 1) * 2; + size = (x_end - x_start + 1) * (y_end - y_start + 1) * 2/*16bit*/; lcd_address_set(x_start, y_start, x_end, y_end); rt_pin_write(LCD_DC_PIN, PIN_HIGH); rt_spi_send(spi_dev_lcd, pcolor, size);