1)使用设备
stm32f407zgt6,fsmc模拟8080
2)问题描述
如图,显示扭曲错乱
![](https://i-blog.csdnimg.cn/blog_migrate/feff5039dcea85077c08c4e9803f0d0f.jpeg)
采用一个个打点的刷新方式可以正常显示,但是刷屏速度太慢
3)最终解决方法
初始状态(卖家资料给的局部刷新函数,是实测可以正常刷新图片,但是lvgl刷新不正常)
![](https://i-blog.csdnimg.cn/blog_migrate/1841659c7812ee02ad7b9df298526ad5.png)
改为
void LCD_Draw_Picture(u16 sx,u16 sy,u16 ex,u16 ey,u16 *color)
{
u16 height,width;
u16 i,j;
width=ex-sx+1; //得到图片的宽度
height=ey-sy+1; //得到图片的高度
Lcd_SetRegion(sx,sy,ex,ey);
LCD_WriteGRAM(); //开始写入GRAM
for(i=0;i<height;i++)
{
// LCD_SetCursor(sx,sy+i); //设置光标位置
// LCD_WriteGRAM(); //开始写入GRAM
for(j=0;j<width;j++)
{// LCD_DATA=color[i*height+j];//写入颜色值
LCD_DATA=*color;//写入颜色值
color++;
}
}
}
添加函数 void Lcd_SetRegion(uint16_t x_start,uint16_t y_start,uint16_t x_end,uint16_t y_end)
void Lcd_SetRegion(uint16_t x_start,uint16_t y_start,uint16_t x_end,uint16_t y_end)
{
LCD_CMD=setxcmd;
LCD_DATA=(x_start>>8);
LCD_DATA=(x_start&0XFF);
LCD_DATA=(x_end>>8);
LCD_DATA=(x_end&0XFF);
LCD_CMD=setycmd;
LCD_DATA=(y_start>>8);
LCD_DATA=(y_start&0XFF);
LCD_DATA=(y_end>>8);
LCD_DATA=(y_end&0XFF);
}
lvgl显示接口
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
// if(disp_flush_enabled) {
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
LCD_Draw_Picture(area->x1,area->y1,area->x2,area->y2,(u16*)color_p);
// int32_t x;
// int32_t y;
// for(y = area->y1; y <= area->y2; y++) {
// for(x = area->x1; x <= area->x2; x++) {
// /*Put a pixel to the display. For example:*/
// LCD_Color_DrawPoint(x,y,color_p->full);
// color_p++;
// }
// }
// }
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
![](https://i-blog.csdnimg.cn/blog_migrate/8280c0b3b849607d156f034e6c76de45.png)
效果
![](https://i-blog.csdnimg.cn/blog_migrate/81ed99a41b1c766420ecfcc54e63811a.jpeg)