流畅的lvgl
优化显示,前面因为是像素填充的,现在修改为块填充。
1、修改NT35510的调置块的函数:
/**
* @brief NT35510_SetRegion 设置显示块的坐标
* @param [in] pstcLCD: LCD controller
* @param u16startXpos: Specifies the sartX position.
* @param u16endXpos: Specifies the endX position.
* @param u16startYpos: Specifies the startY position.
* @param u16endYpos: Specifies the endY position.
* @retval None
*/
//设置横坐标指令:0x2A00~0x2A03;
//设置纵坐标指令:0x2B00~0x2B03;
#define NT35110SC 0x2A00
#define NT35110EC 0x2A02
#define NT35110SP 0x2B00
#define NT35110EP 0x2B02
void NT35510_SetRegion(stc_lcd_controller_t *pstcLCD,
uint16_t u16startXpos,
uint16_t u16endXpos,
uint16_t u16startYpos,
uint16_t u16endYpos)
{
/* Set cursor */
NT35510_WriteRegData(pstcLCD, NT35110SC, (u16startXpos >> 8));
NT35510_WriteRegData(pstcLCD, NT35110SC +1U, (u16startXpos & 0xFFU));
NT35510_WriteRegData(pstcLCD, NT35110EC, (u16endXpos >> 8));
NT35510_WriteRegData(pstcLCD, NT35110EC+1U, (u16endXpos & 0xFFU));
NT35510_WriteRegData(pstcLCD,NT35110SP, (u16startYpos >> 8));
NT35510_WriteRegData(pstcLCD,NT35110SP+1U, (u16startYpos & 0xFFU));
NT35510_WriteRegData(pstcLCD,NT35110SP+2U, (u16endYpos >> 8));
NT35510_WriteRegData(pstcLCD,NT35110SP+3U, (u16endYpos & 0xFFU));
}
2、修改lv_port_disp中的显示函数:
/*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)
{
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
int32_t x;
int32_t y;
BSP_NT35510_SetRegion(area->x1,area->x2,area->y1,area->y2);
BSP_NT35510_PrepareWriteRAM();
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
/*Put a pixel to the display. For example:*/
/*put_px(x, y, *color_p)*/
BSP_NT35510_WriteData(color_p->full);
// BSP_NT35510_WritePixel(x,y,color_p->full);
color_p++;
}
}
/* 重要!!!LCD 驱动函数,在指定区域内填充指定颜色块 */
//lcd_color_fill(area->x1,area->y1,area->x2,area->y2,(uint16_t*)color_p);
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
经过这样优化后,就可以流畅的显示了。
|