26
26
#define MY_DISP_VER_RES 240
27
27
#endif
28
28
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
+
29
39
/**********************
30
40
* TYPEDEFS
31
41
**********************/
35
45
**********************/
36
46
static void disp_init (void );
37
47
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 );
39
49
//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
40
50
// const lv_area_t * fill_area, lv_color_t color);
41
51
@@ -83,9 +93,6 @@ void lv_port_disp_init(void)
83
93
* and you only need to change the frame buffer's address.
84
94
*/
85
95
86
- /* Example for 1) */
87
- static lv_disp_draw_buf_t draw_buf_dsc_1 ;
88
-
89
96
/*GCC*/
90
97
#if defined ( __GNUC__ )
91
98
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)
94
101
__attribute__((at (0x10000000 ))) lv_color_t buf_1 [LCD_H * LCD_W / 2 ];
95
102
#endif
96
103
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*/
98
104
/*-----------------------------------
99
105
* Register the display in LVGL
100
106
*----------------------------------*/
101
107
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
+ *----------------------------------*/
102
124
static lv_disp_drv_t disp_drv ; /*Descriptor of a display driver*/
103
125
lv_disp_drv_init (& disp_drv ); /*Basic initialization*/
104
126
@@ -124,6 +146,9 @@ void lv_port_disp_init(void)
124
146
125
147
/*Finally register the driver*/
126
148
lv_disp_drv_register (& disp_drv );
149
+
150
+ #endif
151
+
127
152
}
128
153
129
154
/**********************
@@ -155,7 +180,7 @@ void disp_disable_update(void)
155
180
/*Flush the content of the internal buffer the specific area on the display
156
181
*You can use DMA or any hardware acceleration to do this operation in the background but
157
182
*'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 )
159
184
{
160
185
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 );
161
186
lcd_fill_array (area -> x1 , area -> y1 , area -> x2 , area -> y2 , color_p );
0 commit comments