|
|
@ -30,7 +30,9 @@ |
|
|
/**********************
|
|
|
/**********************
|
|
|
* TYPEDEFS |
|
|
* TYPEDEFS |
|
|
**********************/ |
|
|
**********************/ |
|
|
|
|
|
#define DBG_TAG "LVGLd" |
|
|
|
|
|
#define DBG_LVL DBG_INFO |
|
|
|
|
|
#include <rtdbg.h> |
|
|
/**********************
|
|
|
/**********************
|
|
|
* STATIC PROTOTYPES |
|
|
* STATIC PROTOTYPES |
|
|
**********************/ |
|
|
**********************/ |
|
|
@ -47,7 +49,15 @@ static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_colo |
|
|
/**********************
|
|
|
/**********************
|
|
|
* MACROS |
|
|
* MACROS |
|
|
**********************/ |
|
|
**********************/ |
|
|
|
|
|
static lv_disp_draw_buf_t draw_buf_dsc_1; |
|
|
|
|
|
static lv_disp_draw_buf_t draw_buf_dsc_2; |
|
|
|
|
|
static lv_disp_draw_buf_t draw_buf_dsc_3; |
|
|
|
|
|
|
|
|
|
|
|
static lv_color_t *buf_1 = RT_NULL; |
|
|
|
|
|
static lv_color_t *buf_2_1 = RT_NULL; |
|
|
|
|
|
static lv_color_t *buf_2_2 = RT_NULL; |
|
|
|
|
|
static lv_color_t *buf_3_1 = RT_NULL; |
|
|
|
|
|
static lv_color_t *buf_3_2 = RT_NULL; |
|
|
/**********************
|
|
|
/**********************
|
|
|
* GLOBAL FUNCTIONS |
|
|
* GLOBAL FUNCTIONS |
|
|
**********************/ |
|
|
**********************/ |
|
|
@ -85,35 +95,65 @@ void lv_port_disp_init(void) |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
/* Example for 1) */ |
|
|
/* Example for 1) */ |
|
|
static lv_disp_draw_buf_t draw_buf_dsc_1 __attribute__((aligned(4))); |
|
|
//static lv_disp_draw_buf_t draw_buf_dsc_1 __attribute__((aligned(8)));
|
|
|
static lv_color_t *buf_1 __attribute__((aligned(4))) = RT_NULL; |
|
|
//static lv_color_t *buf_1 __attribute__((aligned(8))) = RT_NULL;
|
|
|
//static lv_color_t buf_1[MY_DISP_HOR_RES * 10] __attribute__((section(".sdram"))); /*A buffer for 10 rows*/
|
|
|
//static lv_color_t buf_1[MY_DISP_HOR_RES * 10] __attribute__((section(".sdram"))); /*A buffer for 10 rows*/
|
|
|
buf_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10); |
|
|
//buf_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10);
|
|
|
|
|
|
|
|
|
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/ |
|
|
//lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
|
|
|
|
|
|
|
|
|
/* Example for 2) */ |
|
|
/* Example for 2) */ |
|
|
static lv_disp_draw_buf_t draw_buf_dsc_2 __attribute__((aligned(4))); |
|
|
//static lv_disp_draw_buf_t draw_buf_dsc_2 __attribute__((aligned(8)));
|
|
|
static lv_color_t *buf_2_1 __attribute__((aligned(4)))= RT_NULL; |
|
|
//static lv_color_t *buf_2_1 __attribute__((aligned(8)))= RT_NULL;
|
|
|
static lv_color_t *buf_2_2 __attribute__((aligned(4)))= RT_NULL; |
|
|
//static lv_color_t *buf_2_2 __attribute__((aligned(8)))= RT_NULL;
|
|
|
//static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10] __attribute__((section(".sdram"))); /*A buffer for 10 rows*/
|
|
|
//static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10] __attribute__((section(".sdram"))); /*A buffer for 10 rows*/
|
|
|
//static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10] __attribute__((section(".sdram"))); /*An other buffer for 10 rows*/
|
|
|
//static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10] __attribute__((section(".sdram"))); /*An other buffer for 10 rows*/
|
|
|
buf_2_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10); |
|
|
//buf_2_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10);
|
|
|
buf_2_2 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10); |
|
|
//buf_2_2 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_HOR_RES * 10);
|
|
|
|
|
|
|
|
|
lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/ |
|
|
//lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
|
|
|
|
|
|
|
|
|
/* Example for 3) also set disp_drv.full_refresh = 1 below*/ |
|
|
/* Example for 3) also set disp_drv.full_refresh = 1 below*/ |
|
|
static lv_disp_draw_buf_t draw_buf_dsc_3 __attribute__((aligned(4))); |
|
|
//static lv_disp_draw_buf_t draw_buf_dsc_3 __attribute__((aligned(8)));
|
|
|
static lv_color_t *buf_3_1 __attribute__((aligned(4)))= RT_NULL; |
|
|
//static lv_color_t *buf_3_1 __attribute__((aligned(8)))= RT_NULL;
|
|
|
static lv_color_t *buf_3_2 __attribute__((aligned(4)))= RT_NULL; |
|
|
//static lv_color_t *buf_3_2 __attribute__((aligned(8)))= RT_NULL;
|
|
|
//static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES] __attribute__((section(".sdram"))); /*A screen sized buffer*/
|
|
|
//static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES] __attribute__((section(".sdram"))); /*A screen sized buffer*/
|
|
|
//static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES] __attribute__((section(".sdram"))); /*Another screen sized buffer*/
|
|
|
//static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES] __attribute__((section(".sdram"))); /*Another screen sized buffer*/
|
|
|
buf_3_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_VER_RES * 10); |
|
|
//buf_3_1 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_VER_RES * 10);
|
|
|
buf_3_2 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_VER_RES * 10); |
|
|
//buf_3_2 = (lv_color_t *)rt_memheap_alloc(&sdram_heap, sizeof(lv_color_t) * MY_DISP_VER_RES * 10);
|
|
|
|
|
|
|
|
|
|
|
|
//lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_HOR_RES * MY_DISP_VER_RES ); /*Initialize the display buffer*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_HOR_RES * MY_DISP_VER_RES ); /*Initialize the display buffer*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 使用对齐分配函数
|
|
|
|
|
|
buf_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap, |
|
|
|
|
|
sizeof(lv_color_t) * MY_DISP_HOR_RES * 10, |
|
|
|
|
|
4); // ← 关键:对齐到 4 字节
|
|
|
|
|
|
|
|
|
|
|
|
buf_2_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap, |
|
|
|
|
|
sizeof(lv_color_t) * MY_DISP_HOR_RES * 10, |
|
|
|
|
|
4); |
|
|
|
|
|
buf_2_2 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap, |
|
|
|
|
|
sizeof(lv_color_t) * MY_DISP_HOR_RES * 10, |
|
|
|
|
|
4); |
|
|
|
|
|
|
|
|
|
|
|
buf_3_1 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap, |
|
|
|
|
|
sizeof(lv_color_t) * MY_DISP_HOR_RES * MY_DISP_VER_RES, |
|
|
|
|
|
4); |
|
|
|
|
|
buf_3_2 = (lv_color_t *)rt_memheap_alloc_align(&sdram_heap, |
|
|
|
|
|
sizeof(lv_color_t) * MY_DISP_HOR_RES * MY_DISP_VER_RES, |
|
|
|
|
|
4); |
|
|
|
|
|
|
|
|
|
|
|
if (!buf_1 || !buf_2_1 || !buf_2_2 || !buf_3_1 || !buf_3_2) { |
|
|
|
|
|
LOG_E("Failed to alloc aligned draw buffers"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 初始化 draw buffer
|
|
|
|
|
|
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); |
|
|
|
|
|
lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10); |
|
|
|
|
|
lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_HOR_RES * MY_DISP_VER_RES); |
|
|
/*-----------------------------------
|
|
|
/*-----------------------------------
|
|
|
* Register the display in LVGL |
|
|
* Register the display in LVGL |
|
|
*----------------------------------*/ |
|
|
*----------------------------------*/ |
|
|
@ -131,7 +171,7 @@ void lv_port_disp_init(void) |
|
|
disp_drv.flush_cb = disp_flush; |
|
|
disp_drv.flush_cb = disp_flush; |
|
|
|
|
|
|
|
|
/*Set a display buffer*/ |
|
|
/*Set a display buffer*/ |
|
|
disp_drv.draw_buf = &draw_buf_dsc_1; |
|
|
disp_drv.draw_buf = &draw_buf_dsc_2; |
|
|
|
|
|
|
|
|
/*Required for Example 3)*/ |
|
|
/*Required for Example 3)*/ |
|
|
//disp_drv.full_refresh = 1;
|
|
|
//disp_drv.full_refresh = 1;
|
|
|
|