高中生
最后登录1970-1-1
在线时间 小时
注册时间2016-5-23
|
修改19-LTDC—液晶显示英文(字库在内部FLASH)代码,实行双缓冲绘图。
画了一个圆,每次走一步。本来想加入的双缓冲原理,应该可以解决;还是出现闪屏现象,虽然有一点改善。仿真运行后,才知道LTDC->SRCR->LTDC_SRCR_VBR无法置1。无论调用固件库函数,还直接寄存器置1;都不行。代码如下:
//画圆函数
void LCD_Test(void)
{
LTDC_PosTypeDef ltdcPos;
static unsigned int x=100, y=100;
unsigned int status;
LCD_SetLayer(LCD_FOREGROUND_LAYER);
LCD_SetTransparency(0xff);
LCD_Clear(LCD_COLOR_BLACK); /* ÇåÆᣬÏÔê¾è«oú */
LCD_SetColors(LCD_COLOR_RED,LCD_COLOR_BLACK);
LCD_DrawFullCircle(x,y,50);
//LCD_SetColors(LCD_COLOR_GREEN,LCD_COLOR_BLACK);
// LCD_DrawFullCircle(450,350,75);
status = LTDC->SRCR;
SwapBuffer();
x++;
y++;
if (x >= LCD_PIXEL_WIDTH)
x=0;
if (y>=LCD_PIXEL_HEIGHT)
y = 0;
Delay(0x2FFFF);
}
//双缓冲函数
#define LCD_BACKGROUND1_BUFFER (LCD_FRAME_BUFFER)
#define LCD_FOREGROUND1_BUFFER (LCD_BACKGROUND1_BUFFER + BUFFER_OFFSET)
#define LCD_BACKGROUND2_BUFFER (LCD_FOREGROUND1_BUFFER + BUFFER_OFFSET)
#define LCD_FOREGROUND2_BUFFER (LCD_BACKGROUND2_BUFFER + BUFFER_OFFSET)
#define LCD_DMD2D_FOREGROUND_BUFFER (LCD_FOREGROUND2_BUFFER + BUFFER_OFFSET)
#define LCD_DMD2D_BACKGROUND_BUFFER (LCD_DMD2D_FOREGROUND_BUFFER + BUFFER_OFFSET)
void SwapBuffer(void)
{
switch(currentFrame) {
case FRAME1:
if (CurrentFrameBuffer == LCD_FOREGROUND1_BUFFER) {
CurrentFrameBuffer = LCD_FOREGROUND2_BUFFER;
}
else if (CurrentFrameBuffer == LCD_BACKGROUND1_BUFFER) {
CurrentFrameBuffer = LCD_BACKGROUND2_BUFFER;
}
LTDC_LayerAddress(LTDC_Layer1, LCD_BACKGROUND1_BUFFER);
LTDC_LayerAddress(LTDC_Layer2, LCD_FOREGROUND1_BUFFER);
currentFrame = FRAME2;
LTDC_ReloadConfig(LTDC_VBReload);
LTDC->SRCR = 0x02;
break;
case FRAME2:
if (CurrentFrameBuffer == LCD_FOREGROUND2_BUFFER) {
CurrentFrameBuffer = LCD_FOREGROUND1_BUFFER;
}
else if (CurrentFrameBuffer == LCD_BACKGROUND2_BUFFER) {
CurrentFrameBuffer = LCD_BACKGROUND1_BUFFER;
}
LTDC_LayerAddress(LTDC_Layer1, LCD_BACKGROUND2_BUFFER);
LTDC_LayerAddress(LTDC_Layer2, LCD_FOREGROUND2_BUFFER);
currentFrame = FRAME1;
LTDC_ReloadConfig(LTDC_VBReload);
LTDC->SRCR = 0x02;
break;
}
}
如果把画圆延时加长:Delay(0xFFFFF);就不会出现闪屏。但是动画太慢,并不理想。
尝试在LTDCInit之前、里面或者之后加上LTDC->SRCR = 0x02;也无法把LTDC->SRCR->LTDC_SRCR_VBR置1.
现在问题:为什么不能置1?还是我对LTDC->SRCR->LTDC_SRCR_VBR这个位置理解错了?这个位不是垂直消隐吗?
还有一个问题:我读取LTDC_CDSR位都是为0,我本来想LTDC->SRCR->LTDC_SRCR_VBR不能置1,也可以通过读取这个信号为同步信号。但是这个方法也不行。
望大神们赐教。
|
|