mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
更新LCD刷新模式
This commit is contained in:
@@ -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*/
|
||||
|
||||
Reference in New Issue
Block a user