@@ -38,6 +38,7 @@ extern "C" {
38
38
/* Private function prototypes -----------------------------------------------*/
39
39
#if __has_include ("lvgl.h")
40
40
#include " mbed.h"
41
+ #if (LVGL_VERSION_MAJOR == 9)
41
42
void lvgl_displayFlushing (lv_display_t * display, const lv_area_t * area, unsigned char * px_map);
42
43
static void inc_thd () {
43
44
while (1 ) {
@@ -46,6 +47,9 @@ static void inc_thd() {
46
47
}
47
48
}
48
49
static rtos::Thread lvgl_inc_thd;
50
+ #else
51
+ void lvgl_displayFlushing (lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p);
52
+ #endif
49
53
#endif
50
54
51
55
/* Functions -----------------------------------------------------------------*/
@@ -92,6 +96,8 @@ int Arduino_H7_Video::begin() {
92
96
/* Initiliaze LVGL library */
93
97
lv_init ();
94
98
99
+
100
+ #if (LVGL_VERSION_MAJOR == 9)
95
101
/* Create a draw buffer */
96
102
static lv_color_t * buf1 = (lv_color_t *)malloc ((width () * height () / 10 )); /* Declare a buffer for 1/10 screen size */
97
103
if (buf1 == NULL ) {
@@ -114,6 +120,36 @@ int Arduino_H7_Video::begin() {
114
120
lv_display_set_flush_cb (display, lvgl_displayFlushing);
115
121
116
122
lvgl_inc_thd.start (inc_thd);
123
+
124
+ #else // LVGL_VERSION_MAJOR
125
+
126
+ /* Create a draw buffer */
127
+ static lv_disp_draw_buf_t draw_buf;
128
+ static lv_color_t * buf1;
129
+ buf1 = (lv_color_t *)malloc ((width () * height () / 10 ) * sizeof (lv_color_t )); /* Declare a buffer for 1/10 screen size */
130
+ if (buf1 == NULL ) {
131
+ return 2 ; /* Insuff memory err */
132
+ }
133
+ lv_disp_draw_buf_init (&draw_buf, buf1, NULL , width () * height () / 10 ); /* Initialize the display buffer. */
134
+
135
+ /* Initialize display features for LVGL library */
136
+ static lv_disp_drv_t disp_drv; /* Descriptor of a display driver */
137
+ lv_disp_drv_init (&disp_drv); /* Basic initialization */
138
+ disp_drv.flush_cb = lvgl_displayFlushing; /* Set your driver function */
139
+ disp_drv.draw_buf = &draw_buf; /* Assign the buffer to the display */
140
+ if (_rotated) {
141
+ disp_drv.hor_res = height (); /* Set the horizontal resolution of the display */
142
+ disp_drv.ver_res = width (); /* Set the vertical resolution of the display */
143
+ disp_drv.rotated = LV_DISP_ROT_270;
144
+ } else {
145
+ disp_drv.hor_res = width (); /* Set the horizontal resolution of the display */
146
+ disp_drv.ver_res = height (); /* Set the vertical resolution of the display */
147
+ disp_drv.rotated = LV_DISP_ROT_NONE;
148
+ }
149
+ disp_drv.sw_rotate = 1 ;
150
+ lv_disp_drv_register (&disp_drv); /* Finally register the driver */
151
+
152
+ #endif
117
153
#endif
118
154
119
155
/* Configure SDRAM */
@@ -194,6 +230,7 @@ void Arduino_H7_Video::set(int x, int y, uint8_t r, uint8_t g, uint8_t b) {
194
230
#endif
195
231
196
232
#if __has_include("lvgl.h")
233
+ #if (LVGL_VERSION_MAJOR == 9)
197
234
static uint8_t * rotated_buf = nullptr ;
198
235
void lvgl_displayFlushing (lv_display_t * disp, const lv_area_t * area, unsigned char * px_map) {
199
236
uint32_t w = lv_area_get_width (area);
@@ -228,6 +265,16 @@ void lvgl_displayFlushing(lv_display_t * disp, const lv_area_t * area, unsigned
228
265
dsi_lcdDrawImage ((void *) px_map, (void *)(dsi_getActiveFrameBuffer () + offsetPos), w, h, DMA2D_INPUT_RGB565);
229
266
lv_display_flush_ready (disp); /* Indicate you are ready with the flushing*/
230
267
}
268
+ #else
269
+ void lvgl_displayFlushing (lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
270
+ uint32_t width = lv_area_get_width (area);
271
+ uint32_t height = lv_area_get_height (area);
272
+ uint32_t offsetPos = (area->x1 + (dsi_getDisplayXSize () * area->y1 )) * sizeof (uint16_t );
273
+
274
+ dsi_lcdDrawImage ((void *) color_p, (void *)(dsi_getActiveFrameBuffer () + offsetPos), width, height, DMA2D_INPUT_RGB565);
275
+ lv_disp_flush_ready (disp); /* Indicate you are ready with the flushing*/
276
+ }
277
+ #endif
231
278
#endif
232
279
233
280
/* *** END OF FILE ****/
0 commit comments