|
@@ -26,6 +26,14 @@
|
|
|
#define MY_DISP_VER_RES 240
|
|
|
#endif
|
|
|
|
|
|
+#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,9 +43,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 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);
|
|
|
+static void disp_flush(LV_DISP_TYPE * disp_drv, const lv_area_t * area, lv_COLOR_TYPE * color_p);
|
|
|
|
|
|
/**********************
|
|
|
* STATIC VARIABLES
|
|
@@ -83,9 +89,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,16 +97,29 @@ 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*/
|
|
|
|
|
|
- /*Set up the functions to access to your display*/
|
|
|
-
|
|
|
/*Set the resolution of the display*/
|
|
|
disp_drv.hor_res = MY_DISP_HOR_RES;
|
|
|
disp_drv.ver_res = MY_DISP_VER_RES;
|
|
@@ -114,16 +130,11 @@ void lv_port_disp_init(void)
|
|
|
/*Set a display buffer*/
|
|
|
disp_drv.draw_buf = &draw_buf_dsc_1;
|
|
|
|
|
|
- /*Required for Example 3)*/
|
|
|
- //disp_drv.full_refresh = 1;
|
|
|
-
|
|
|
- /* Fill a memory array with a color if you have GPU.
|
|
|
- * Note that, in lv_conf.h you can enable GPUs that has built-in support in LVGL.
|
|
|
- * But if you have a different GPU you can use with this callback.*/
|
|
|
- //disp_drv.gpu_fill_cb = gpu_fill;
|
|
|
-
|
|
|
/*Finally register the driver*/
|
|
|
lv_disp_drv_register(&disp_drv);
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**********************
|
|
@@ -155,35 +166,16 @@ 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)
|
|
|
+static 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);
|
|
|
-
|
|
|
lv_disp_flush_ready(disp_drv);
|
|
|
}
|
|
|
|
|
|
-/*OPTIONAL: GPU INTERFACE*/
|
|
|
-
|
|
|
-/*If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color*/
|
|
|
-//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)
|
|
|
-//{
|
|
|
-// /*It's an example code which should be done by your GPU*/
|
|
|
-// int32_t x, y;
|
|
|
-// dest_buf += dest_width * fill_area->y1; /*Go to the first line*/
|
|
|
-//
|
|
|
-// for(y = fill_area->y1; y <= fill_area->y2; y++) {
|
|
|
-// for(x = fill_area->x1; x <= fill_area->x2; x++) {
|
|
|
-// dest_buf[x] = color;
|
|
|
-// }
|
|
|
-// dest_buf+=dest_width; /*Go to the next line*/
|
|
|
-// }
|
|
|
-//}
|
|
|
-
|
|
|
|
|
|
#else /*Enable this file at the top*/
|
|
|
|
|
|
/*This dummy typedef exists purely to silence -Wpedantic.*/
|
|
|
typedef int keep_pedantic_happy;
|
|
|
-#endif
|
|
|
+#endif
|