|
本帖最后由 xjt010 于 2010-3-2 23:05 编辑
发几个裸机的lcd显示函数,很实用。先把字库文件(Font_Libs.c)复制到\TQ2440_Test\src . 字库在配套光盘里的uCOS-II\S3C2440\source 里能找到.把下面的函数添加LCD_TFT.c.再调用就可以了.
extern unsigned char __CHS[];
extern unsigned char __VGA[];
/**************************************************************
在LCD屏幕上指定坐标点(x,y)写ASCII码(ch)
**************************************************************/
void Lcd_PutASCII(unsigned int x,unsigned int y,unsigned char ch,unsigned int c,unsigned int bk_c,unsigned int st)
{
unsigned short int i,j;
unsigned char *pZK,mask,buf;
pZK = &__VGA[ch*16];
for( i = 0 ; i < 16 ; i++ )
{
mask = 0x80;
buf = pZK;
for( j = 0 ; j < 8 ; j++ )
{
if( buf & mask )
{
PutPixel(x+j,y+i,c);
}
else
{
if( !st )
{
PutPixel(x+j,y+i,bk_c);
}
}
mask = mask >> 1;
}
}
}
/**************************************************************
在LCD屏幕上指定坐标(x,y)点写汉字(QW)
**************************************************************/
void Lcd_PutHZ(unsigned int x,unsigned int y,unsigned short int QW,unsigned int c,unsigned int bk_c,unsigned int st)
{
unsigned short int i,j;
unsigned char *pZK,mask,buf;
pZK = &__CHS[ (( (QW >> 8) - 161 )*94 + (QW & 0x00FF)- 161 )*32 ];
// pZK = &__CHS[0xB6a1];
for( i = 0 ; i < 16 ; i++ )
{
//左
mask = 0x80;
buf = pZK[i*2];
for( j = 0 ; j < 8 ; j++ )
{
if( buf & mask )
{
PutPixel(x+j,y+i,c);
}
else
{
if( !st )
{
PutPixel(x+j,y+i,bk_c);
}
}
mask = mask >> 1;
}
//右
mask = 0x80;
buf = pZK[i*2 + 1];
for( j = 0 ; j < 8 ; j++ )
{
if( buf & mask )
{
PutPixel(x+j + 8,y+i,c);
}
else
{
if( !st )
{
PutPixel(x+j + 8,y+i,bk_c);
}
}
mask = mask >> 1;
}
}
}
///显示字符串
void PrintfS(unsigned int x,unsigned int y,char* str,unsigned int c,unsigned int bk_c,unsigned int st)
{
while(*str)
{
if(*str>0xa0)
{
Lcd_PutHZ(x,y,*(str+1)+*(str)*256,c,bk_c,st);
str +=2;
x +=16;
}
else
{
Lcd_PutASCII(x,y,*str, c,bk_c, st);
str++;
x +=8;
}
}
}
///显示数值
void Lcd_PutNum(unsigned int x,unsigned int y,unsigned long fig,unsigned int c,unsigned int bk_c,unsigned int st)
//输出数值 最大位数unsigned long fig 决定。由注意溢出
{ unsigned long pow=1;
unsigned long temp;
unsigned char Putfig=0;
temp=fig;
while(temp!=0)
{
temp=temp/10;
Putfig++;
}
for(;Putfig>1;Putfig--) //下面要%,Putfig不到零
pow=pow*10;
while(pow!=0)
{
Putfig=fig/pow;
Lcd_PutHZ( x, y, ('0'+Putfig) , c, bk_c, st);
fig=fig%pow;
pow=pow/10;
x +=10;
}
} |
|