当前位置:首页 > 单片机 > 单片机
[导读]利用初始化设置中的void LCD_displayScreen来实现按一键盘全屏显示某种颜色:while(1){ unsigned char color; color = Uart_Getch(); switch(color) { case 'b': case 'B':

利用初始化设置中的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


本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭