利用初始化设置中的void LCD_displayScreen来实现按一键盘全屏显示某种颜色:
while(1)
{
unsigned char color;
color = Uart_Getch();
switch(color)
{
case 'b':
case 'B':
LCD_displayScreen(0,0,0xff);
Uart_Printf("The color is Blue! \n");
break;
case 'r':
case 'R':
LCD_displayScreen(0xff,0,0);
Uart_Printf("The color is Red! \n");
break;
case 'g':
case 'G':
LCD_displayScreen(0,0xff,0);
Uart_Printf("The color is Green! \n");
break;
case 'y':
case 'Y':
LCD_displayScreen(0xff,0xff,0);
Uart_Printf("The color is Yellow! \n");
break;
case 'w':
case 'W':
LCD_displayScreen(0xff,0xff,0xff);
Uart_Printf("The color is White! \n");
break;
default:
LCD_displayScreen(0,0,0); //BLack
Uart_Printf("Press Wrong Key! B:Blue R:Red Y:Yellow G:Green W:white \n");
}
}
以上代码稍微修改就成了按按键显示任何图片。
/**************************************************************
在LCD屏幕上指定坐标点画一个指定大小的图片
**************************************************************/
void Paint_Bmp(int x0,int y0,int h,int l,unsigned char bmp[])
{
注:x0为起始X坐标,y0为起始y坐标,h为终止X坐标,l为终止Y坐标
bmp[]数组为需要显示的bmp格式,大小为320*240的数据,总的480个8位数据
int x,y;
U32 c;
int p = 0;
for( y = y0 ; y < l ; y++ ) //y<=320
{
for( x = x0 ; x < h ; x++ )
{
c = bmp[p+1] | (bmp[p]<<8) ;
if ( ( (x0+x) < SCR_XSIZE_TFT) && ( (y0+y) < SCR_YSIZE_TFT) )
LCD_BUFFER[y0+y][x0+x] = c ;
p = p + 2 ; // 480/2=240
}
}
}
只需在开头代码中各case语句下的LCD_displayScreen(0,0,0xff);改成:
LCD_displayScreen(0,0,0); //清屏
Paint_Bmp(0,0,320,240,picture1_320_240); //从[0,0]到[320,240]处填充 picture1_320_240
上一篇:S3C2440 测试程序(六) LCD显示实验2_触摸小图片切换大图片
下一篇:TFT LCD的显色原理
推荐阅读最新更新时间:2024-03-16 15:23