更新LCD刷新模式

This commit is contained in:
不吃油炸鸡
2026-02-04 10:25:04 +08:00
parent 605ff6fb5e
commit dc96e6353f
5 changed files with 96 additions and 27 deletions

View File

@@ -46,6 +46,9 @@ static void disp_flush(lv_display_t * disp, const lv_area_t * area, uint8_t * px
* STATIC VARIABLES
**********************/
// 1. 定义一个静态变量来保存当前的 driver 句柄
static lv_display_t *g_current_disp_drv = NULL;
/**********************
* MACROS
**********************/
@@ -66,6 +69,7 @@ void lv_port_disp_init(void)
* -----------------------------------*/
lv_display_t * disp = lv_display_create(MY_DISP_HOR_RES, MY_DISP_VER_RES);
lv_display_set_flush_cb(disp, disp_flush);
g_current_disp_drv = disp;
#define BUFFER_METHOD 1
#if BUFFER_METHOD == 1
/* Example 1
@@ -103,6 +107,13 @@ void lv_port_disp_init(void)
* STATIC FUNCTIONS
**********************/
void lcd_flush_ready_callback(void)
{
if (g_current_disp_drv != NULL) {
lv_display_flush_ready(g_current_disp_drv);
}
}
/*Initialize your display and the required peripherals.*/
static void disp_init(void)
{
@@ -110,6 +121,7 @@ static void disp_init(void)
LCD_Init();
LCD_Fill(0,0, LCD_W, LCD_H, BLACK);
LCD_Close_Light();
LCD_Set_Flush_Complete_Callback(lcd_flush_ready_callback);
}
volatile bool disp_flush_enabled = true;
@@ -142,12 +154,12 @@ static void disp_flush(lv_display_t * disp_drv, const lv_area_t * area, uint8_t
last_rotation = current_rotation; // 更新上次状态
}
if(disp_flush_enabled) {
LCD_Color_Render(area->x1,area->y1,area->x2,area->y2, (uint16_t *)px_map);
LCD_Color_Render_Async(area->x1,area->y1,area->x2,area->y2, (uint16_t *)px_map);
}
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_display_flush_ready(disp_drv);
// lv_display_flush_ready(disp_drv);
}
#else /*Enable this file at the top*/