sbit LCDRS=P3^4;
sbit LCDRW=P3^3;
sbit LCDEN=P3^2;
sbit LCDRST=P3^0;
sbit LCDPSB=P3^1;
uchar data z;
uchar data y;
uchar data column;
uchar data page;
uchar *p2;
uchar wbyte;
void delayms(uint z) //ÑÓ³Ùº¯Êý£¬MS¼¶ÑÓ³Ù¡£
{
uint data i,j;
for(i=0;i<z;i++)
{
for(j=0;j<600;j++)
{;}
}
}
void write_com(uchar com)
{
uchar temp=0;
LCDRS=0; // ֮ǰÊÇ0£»
LCDRW=1;
do
{
LCDEN=1;
delayms(1);
temp=P2;
LCDEN=0;
}
while(temp&0x80);
LCDRW=0;
P2=com;
LCDEN=1;
delayms(1);
LCDEN=0;
}
void write_date(uchar date)
{
uchar temp=0;
LCDRS=0;
LCDRW=1;
do
{
LCDEN=1;
delayms(1);
temp=P2;
LCDEN=0;
}
while(temp&0x80);
LCDRS=1; //¸Ä³ÉдÊý¾ÝÁË¡£Ö®Ç°ÊÇ1.д´í¡£
LCDRW=0;
P2=date;
LCDEN=1;
delayms(1);
LCDEN=0;
}
void clearlcd1()
{
uchar i;
uchar j;
for(i=0;i<64;i++)
{
write_com(i|0x80);
write_com(0x80);
for(j=0;j<32;j++)
{
write_date(0x00);
}
}
}
void picture()
{
uchar v;
uchar w;
uchar x;
uchar h;
write_com(0x34);
write_com(0x36);
for(h=0;h<32;h++)
{
v=column|0x80;
w=page|0x80;
write_com(w);
write_com(v);
page++;
for(x=0;x<4;x++)
{
wbyte=*p2;
write_date(wbyte);
p2++;
}
}
}
void init()
{
LCDRST=1;
write_com(0x30); //»ù±¾Ö¸Á
delayms(1);
write_com(0x02); //µØÖ·¹éλ
delayms(1);
write_com(0x0c); / /ÕûÌåÏÔʾ´ò¿ª Óαê¹Ø±Õ
delayms(1);
write_com(0x02); //Çå³ýÏÔʾ
delayms(1);
write_com(0x02);//¹â±ê´ÓÓÒÏò×ó¼ÓһλÒƶ¯
}
void lock()
{
clearlcd1();
column=3;
page=1;
const uchar code clocker_32_4[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x00,
0x00,0xFF,0xFF,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x03,0x00,0x03,0xFF,0xFF,0xC0,
0x07,0xFF,0xFF,0xE0,0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,
0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,
0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,
0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,
0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x07,0xFF,0xFF,0xE0,0x03,0xFF,0xFF,0xC0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
//这里出现 C141 syntax error
p2=clocker_32_4[];
picture();
}
void main()
{
uchar temp1[]={"--¡æ "};
uchar temp2[]={"³ý¹¸"};
uchar temp3[]={"--ml "};
uchar temp4[]={"ÖÆË®ÖÐ"};
int i=0;
LCDPSB=1;
init();
write_com(0x80);//É趨λÖÃΪµÚÒ»ÐеĵÚһλ
for(i=0;i<4;i++)
write_date(temp1
);
write_com(0x86);//É趨λÖÃΪµÚÒ»Ðеĵڶþλ
for(i=0;i<2;i++)
write_date(temp2);
write_com(0x98);//É趨λÖÃΪµÚÒ»ÐеĵÚÈýλ
for(i=0;i<5;i++)
write_date(temp3);
write_com(0x9e);//É趨λÖÃΪµÚÒ»ÐеĵÚËÄλ
for(i=0;i<3;i++)
write_date(temp4);
lock();
while(1);//³ÌÐòÍ£Ö¹
}
此帖出自小平头技术问答
一周热门 更多>