Skip to content

Commit 2bcc2f8

Browse files
committed
[BSP][LVGL]An adaptation that creates a buffer in high or low versions
1 parent 58055e7 commit 2bcc2f8

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_conf.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <rtconfig.h>
1515

1616
#define LV_COLOR_DEPTH 16
17-
#define LV_USE_PERF_MONITOR 1
1817
#define MY_DISP_HOR_RES 240
1918
#define MY_DISP_VER_RES 240
2019
//#define LV_USE_LOG 1
@@ -31,13 +30,13 @@
3130

3231
#endif
3332

34-
33+
#define LV_USE_SYSMON 1
34+
#define LV_USE_PERF_MONITOR 1
35+
#define LV_USE_DEMO_WIDGETS 1
36+
#define LV_FONT_MONTSERRAT_24 1
3537
#define LV_USE_DEMO_BENCHMARK 1
3638

3739

38-
//#define LV_USE_DEMO_WIDGETS 1
39-
40-
4140
//#define LV_USE_DEMO_MUSIC 1
4241

4342
#endif

bsp/stm32/stm32f407-rt-spark/board/ports/lvgl/lv_port_disp.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
#define MY_DISP_VER_RES 240
2727
#endif
2828

29+
#define BYTE_PER_PIXEL (LV_COLOR_FORMAT_GET_SIZE(LV_COLOR_FORMAT_RGB565)) /*will be 2 for RGB565 */
30+
31+
#if (PKG_LVGL_VER_NUM >= 0x0803FF)
32+
#define LV_DISP_TYPE lv_display_t
33+
#define lv_COLOR_TYPE uint8_t
34+
#else
35+
#define LV_DISP_TYPE lv_disp_drv_t
36+
#define lv_COLOR_TYPE lv_color_t
37+
#endif
38+
2939
/**********************
3040
* TYPEDEFS
3141
**********************/
@@ -35,7 +45,7 @@
3545
**********************/
3646
static void disp_init(void);
3747

38-
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
48+
static void disp_flush(LV_DISP_TYPE * disp_drv, const lv_area_t * area, lv_COLOR_TYPE * color_p);
3949
//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
4050
// const lv_area_t * fill_area, lv_color_t color);
4151

@@ -83,9 +93,6 @@ void lv_port_disp_init(void)
8393
* and you only need to change the frame buffer's address.
8494
*/
8595

86-
/* Example for 1) */
87-
static lv_disp_draw_buf_t draw_buf_dsc_1;
88-
8996
/*GCC*/
9097
#if defined ( __GNUC__ )
9198
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)
94101
__attribute__((at(0x10000000))) lv_color_t buf_1[LCD_H * LCD_W / 2];
95102
#endif
96103

97-
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*/
98104
/*-----------------------------------
99105
* Register the display in LVGL
100106
*----------------------------------*/
101107

108+
#if (PKG_LVGL_VER_NUM >= 0x0803FF)
109+
110+
lv_display_t *display = lv_display_create(MY_DISP_HOR_RES, MY_DISP_VER_RES);
111+
lv_display_set_buffers(display, buf_1, NULL, sizeof(buf_1), LV_DISPLAY_RENDER_MODE_PARTIAL); /*Initialize the display buffer.*/
112+
lv_display_set_flush_cb(display, disp_flush);
113+
114+
#else
115+
116+
/* Example for 1) */
117+
static lv_disp_draw_buf_t draw_buf_dsc_1;
118+
119+
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*/
120+
121+
/*-----------------------------------
122+
* Register the display in LVGL
123+
*----------------------------------*/
102124
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
103125
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
104126

@@ -124,6 +146,9 @@ void lv_port_disp_init(void)
124146

125147
/*Finally register the driver*/
126148
lv_disp_drv_register(&disp_drv);
149+
150+
#endif
151+
127152
}
128153

129154
/**********************
@@ -155,7 +180,7 @@ void disp_disable_update(void)
155180
/*Flush the content of the internal buffer the specific area on the display
156181
*You can use DMA or any hardware acceleration to do this operation in the background but
157182
*'lv_disp_flush_ready()' has to be called when finished.*/
158-
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
183+
void disp_flush(LV_DISP_TYPE * disp_drv, const lv_area_t * area, lv_COLOR_TYPE * color_p)
159184
{
160185
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);
161186
lcd_fill_array(area->x1, area->y1, area->x2, area->y2, color_p);

0 commit comments

Comments
 (0)