S3C2440 測試程序(六) LCD顯示實(shí)驗(yàn)1
利用初始化設(shè)置中的void LCD_displayScreen來實(shí)現(xiàn)按一鍵盤全屏顯示某種顏色:
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屏幕上指定坐標(biāo)點(diǎn)畫一個(gè)指定大小的圖片
**************************************************************/
void Paint_Bmp(int x0,int y0,int h,int l,unsigned char bmp[])
{
注:x0為起始X坐標(biāo),y0為起始y坐標(biāo),h為終止X坐標(biāo),l為終止Y坐標(biāo)
bmp[]數(shù)組為需要顯示的bmp格式,大小為320*240的數(shù)據(jù),總的480個(gè)8位數(shù)據(jù)
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