diff --git a/bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_conf.h b/bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_conf.h index ad815137f15d..453050149956 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_conf.h +++ b/bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_conf.h @@ -14,7 +14,6 @@ #include #define LV_COLOR_DEPTH 16 -#define LV_USE_PERF_MONITOR 1 #define MY_DISP_HOR_RES 240 #define MY_DISP_VER_RES 240 //#define LV_USE_LOG 1 @@ -31,13 +30,13 @@ #endif - +#define LV_USE_SYSMON 1 +#define LV_USE_PERF_MONITOR 1 +#define LV_USE_DEMO_WIDGETS 1 +#define LV_FONT_MONTSERRAT_24 1 #define LV_USE_DEMO_BENCHMARK 1 -//#define LV_USE_DEMO_WIDGETS 1 - - //#define LV_USE_DEMO_MUSIC 1 #endif diff --git a/bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_port_disp.c b/bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_port_disp.c index b615edb4c68c..a514e6e47350 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_port_disp.c +++ b/bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_port_disp.c @@ -26,6 +26,16 @@ #define MY_DISP_VER_RES 240 #endif +#define BYTE_PER_PIXEL (LV_COLOR_FORMAT_GET_SIZE(LV_COLOR_FORMAT_RGB565)) /*will be 2 for RGB565 */ + +#if (PKG_LVGL_VER_NUM >= 0x0803FF) + #define LV_DISP_TYPE lv_display_t + #define lv_COLOR_TYPE uint8_t +#else + #define LV_DISP_TYPE lv_disp_drv_t + #define lv_COLOR_TYPE lv_color_t +#endif + /********************** * TYPEDEFS **********************/ @@ -35,7 +45,7 @@ **********************/ static void disp_init(void); -static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); +static void disp_flush(LV_DISP_TYPE * disp_drv, const lv_area_t * area, lv_COLOR_TYPE * color_p); //static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width, // const lv_area_t * fill_area, lv_color_t color); @@ -83,9 +93,6 @@ void lv_port_disp_init(void) * and you only need to change the frame buffer's address. */ - /* Example for 1) */ - static lv_disp_draw_buf_t draw_buf_dsc_1; - /*GCC*/ #if defined ( __GNUC__ ) static lv_color_t buf_1[MY_DISP_HOR_RES * MY_DISP_HOR_RES / 2] __attribute__((section(".LVGLccm"))); /*A buffer for 10 rows*/ @@ -94,11 +101,26 @@ void lv_port_disp_init(void) __attribute__((at(0x10000000))) lv_color_t buf_1[LCD_H * LCD_W / 2]; #endif - lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * MY_DISP_HOR_RES / 2); /*Initialize the display buffer*/ /*----------------------------------- * Register the display in LVGL *----------------------------------*/ +#if (PKG_LVGL_VER_NUM >= 0x0803FF) + + lv_display_t *display = lv_display_create(MY_DISP_HOR_RES, MY_DISP_VER_RES); + lv_display_set_buffers(display, buf_1, NULL, sizeof(buf_1), LV_DISPLAY_RENDER_MODE_PARTIAL); /*Initialize the display buffer.*/ + lv_display_set_flush_cb(display, disp_flush); + +#else + + /* Example for 1) */ + static lv_disp_draw_buf_t draw_buf_dsc_1; + + lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * MY_DISP_HOR_RES / 2); /*Initialize the display buffer*/ + + /*----------------------------------- + * Register the display in LVGL + *----------------------------------*/ static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ lv_disp_drv_init(&disp_drv); /*Basic initialization*/ @@ -124,6 +146,9 @@ void lv_port_disp_init(void) /*Finally register the driver*/ lv_disp_drv_register(&disp_drv); + +#endif + } /********************** @@ -155,7 +180,7 @@ void disp_disable_update(void) /*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 disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) +void disp_flush(LV_DISP_TYPE * disp_drv, const lv_area_t * area, lv_COLOR_TYPE * color_p) { extern void lcd_fill_array(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_uint16_t y_end, void *pcolor); lcd_fill_array(area->x1, area->y1, area->x2, area->y2, color_p);