#define DATA XBYTE[0x5800]
#define COMMAND XBYTE[0x5801]
#define LINECHARS 3.0
#define CHARBLANK 0
sbit flag0=ACC^0; //Command R/W flag
sbit flagl=ACC^1; //Data R/W flag
sbit flag2=ACC^2; //Auto read
sbit flag3=ACC^3; //Auto write
void wait() //wait()、wait3()、分别为一次读写状态与连续写状态判断
{
do {ACC=COMMAND;
}
while(flag0!=1);
do {ACC=COMMAND;
}
while(flagl!=1);
}
void wait3()
{
do {ACC=COMMAND;
}
while(flag3!=1);
}
void writedata(unsigned char da)
{
wait();
DATA=da;
}
void writedataa(unsigned char da)
{
wait3();
DATA=da;
)
void writecom(unsigned char com)
{
wait();
COMMAND=com;
}
void writedc(unsigned char datal,unsigned char data2,unsigned char com)
{
writedata(datal);
writedata(data2);
writecom(com);
}
void writeldc(unsigned char da,unsigned char com)
{
writedata(da);
writecom(com);
}
void display32(unsigned char start base,unsigned char x,unsigned char y,char*s)
{
unsigned int start;
unsigned char i;
unsigned char high,low;
for(i=0;i<16;i++)
{
start=x+(y+i)*LINECHARS*8;
low=(start/8)&0x00ff;
high=(start/8)>>8;
writedc(low,high+start base,0x24);
writeldc(s[i],0xc0);
writeldc(s[i+16],0xc0);
}
}
void display16(unsigned char start base,unsigned char x,unsigned char y,char*s)
{
unsigned int start;
unsigned char i;
unsigned char high,low;
for(i=0;i<16;i++)
{
start=x+(y+i)*LINECHARS*8;
low=(start/8)&0x00ff;
high=(start/8)>>8;
writedc(low,high+start base,0x24);
writeldc(s[i],0xc0);
}
}
void hiqhliqht lcd(unsigned char start_base;unsigned char start_x,unsigned
char start_y,unsigned char x_length,unsigned char y_length)
{
unsigned int start;
unsigned char i;
unsigned char high,low;
while(y_length!=0)
}
start=(start-x/8)+start_y*(LINECHARS);
low=start&0x00ff;
high=start>>8;
writedc(low,high+start_base,0x24);
i=x length/8;
while(i!=0)
{
writecom(0xc5);
writeldc(~DATA,0xc0);
i--;
}
start_ y++;
y _length--;
}
}
void clear_lcd(unsigned char start_base,unsigned char start_x,unsigned
char start_y,unsigned char x _length,unsigned char y_length)
{
unsigned int start;
unsigned char i;
unsigned char high,low;
while(y_length!=0)
{
start=(start_x/8)+start_y*(LINECHARS);
low=start&0X00ff;
high=start>>8;
writedc(low,high+start_base,0x24);
writecom(0xb0);
i=x_length/8;
while(i!=0)
{
writedatas(0X00);
i--;
}
writecom(0xb2);
start_y++;
y_length--;
}
}
void init lcd()
{
writecom(0x98);
writecom(0x80);
writedc(0x00,0x00,0x42);
writedc(LINECHARS,0x00,0x43);
}