?? lcd.c
字號:
//file name : LCD.c
//author:abin
//date:2007.1.18
//about:T6963c 240*128
#include "lcd.h"
void checkready01( void ) //
{
while(1)
if ((COMLCD & 0x03) == 0x03)
break;
}
void checkready3( void )
{
while(1)
if ((COMLCD & 0x08) == 0x08)
break;
}
void write2(unsigned char para1,unsigned char para2,unsigned char constdat)
{
checkready01();
DATLCD = para1;
checkready01();
DATLCD = para2;
checkready01();
COMLCD = constdat;
}
void write1(unsigned char para1,unsigned char constdat)
{
checkready01();
DATLCD = para1;
checkready01();
COMLCD = constdat;
}
void write(uchar constdat)
{
checkready01();
COMLCD = constdat;
}
void ucwrite(uchar constdat)
{
DATLCD = constdat;
}
void LCD_Initial( void )
{
unsigned int mcount = 0;
write2( 0,0x0,0x24); //set the point address
write( 0xB0 ); //auto write
do
{
checkready3();
ucwrite(0x0);
mcount ++;
}while(mcount <= 0x1fff);
write( 0xB2 ); //end auto operation
write( 0x80 ); //mode or
write2( 0,0x0,0x40); //text address
write2( 30,0,0x41); //text width
write2( 0,0x10,0x42); //graph address
write2( 30,0,0x43); //graph width
write2( 0,0x0,0x24); //set the point address
write(0x9f);
write2( 0x1f,0,0x22);
write2( 0,0x0,0x24); //set the point address
write( 0x80 ); //mode or
}
//function name:LCD_Set_Curse()
//date:07.1.18
//author:
//about:x,y coordinate of the curse.size: height of the curse
//------>y
//|
//|
//V x
void LCD_Set_Curse(unsigned char x,unsigned char y, unsigned char size)
{
write(DISPLAY|CURSE_ON|CURSE_FLASH);
write2(y%30,x%16,0x21);
write(0xa0+size%7);
}
void LCD_Clear(void)
{
unsigned int mcount = 0;
write2( 0,0x0,0x24); //set the point address
write( 0xB0 ); //auto write
do
{
checkready3();
ucwrite(0x0);
mcount ++;
}while(mcount <= 0x1fff);
write( 0xB2 ); //end auto operation
write(DISPLAY);
}
void LCD_Clear_Text(void)
{
unsigned int mcount = 0;
write2( 0,0,0x40);
write2( 0,0,0x24);
write( 0xB0 );
do
{
checkready3();
ucwrite( 0 );
mcount ++;
}while(mcount <= 0xfff);
write( 0xB2 );
}
void Put_Text(unsigned char x,unsigned char y,unsigned char dat)
{
unsigned int ii = x*30+y;
write2( 0,0,0x40);//文本區首地址設置
write2(ii%256,ii/256,0x24);
write1(dat-0x20,0xc0);
}
void Put_Text_Str(unsigned char x,unsigned char y, unsigned char const *addr)
{
unsigned int ii = x*30+y;
write2( 0,0,0x40);//文本區首地址設置
write2(ii%256,ii/256,0x24);
write( 0xB0 );
while(*addr != '\0')
{
checkready3();
ucwrite( *addr-0x20 );
addr++;
}
write( 0xB2 );
}
void Put_Text_Int(unsigned char x,unsigned char y,unsigned int dat,unsigned char length)
{
unsigned char i,temp[5];
for(i=5;i>0;i--)
{
temp[i-1]=dat%10+0x30;
dat = dat/10;
}
for(i=5-length;i<5;i++)
{
Put_Text(x,y,temp[i]);
y++;
}
}
//about:x:0~15,y:0~29,mode
void Put_Char(unsigned char x, unsigned char y,unsigned char width, unsigned char const *addr,unsigned char mode)
{
unsigned char linex,i=16;//
unsigned int ii;
//linex = x*8;
linex = x;
while(i--)
{
ii = 0x1000+linex*30+y;
write2(ii%256,ii/256,0x24);
if(mode == 0xff)
write1(~(*addr++),0xc0);
else
write1(*addr++,0xc0);
if(width==16)
{
if(mode == 0xff)
write1(~(*addr++),0xc0);
else
write1(*addr++,0xc0);
}
linex++;
}
}
void Put_Str(unsigned char x,unsigned char y,const char *str,unsigned char mode)
{
unsigned char i=0,j;
unsigned char const *addr;
while(str[i]!= '\0')
{
if(str[i]>0x80)
{
//temp= ((unsigned int)str[i])<<8 + ((unsigned int)(str[i++]));
for(j=0;j<HANZI_COUNT;j++)//查找漢字索引
{
if(Hanzi_Index[2*j] == str[i] && Hanzi_Index[2*j+1] == str[i+1])
{
addr = hanzi + 32*j;
break;
}
}
if(j<HANZI_COUNT)
Put_Char(x,y,16,addr,mode);//顯示漢字
else
{
Put_Char(x,y,8,ASIC,0xff);
Put_Char(x,y+1,8,ASIC,0xff);
}
i+=2;
y+=2;
if(y>29)
{
x++;
y = 0;
}
}
else
{
Put_Char(x,y,8,(ASIC + (str[i]%0x80 - ' ')*16 ),mode);
i++;
y++;
if(y>29)
{
x++;
y = 0;
}
}
}
}
void Put_Int(unsigned char x,unsigned char y,unsigned int dat,unsigned char length,unsigned char mode)
{
unsigned char i,temp[5];
for(i=5;i>0;i--)
{
temp[i-1]=dat%10;
dat = dat/10;
}
for(i=5-length;i<5;i++)
{
Put_Char(x,y,8,ASIC+('0'-' '+temp[i])*16,mode);
y++;
}
}
/*
T---------->x
|
|
|
V y
modify:2007.3.28
*/
void LCD_Display_Graph(unsigned char x,unsigned char y,unsigned int height,unsigned char width,unsigned char *addr)
{
unsigned int ii;
unsigned char xx,yy,hh,ww;
for(hh = 0;hh<height;hh++)
{
yy = y+hh;
xx = (x+7)/8;
ii= 0x1000+yy*30+xx;
ww = ((width+7)/8)%30;
write2(ii%256,ii/256,0x24);
write( 0xB0 );
while(ww--)
{
checkready3();
ucwrite( *addr++ );
}
write(0xB2);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -