不带字库的12864液晶显示

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include
#include
sbit DI=P3^3;
sbit RW=P3^1;
sbit E=P3^0;
sbit RES=P3^6;
sbit CSA=P3^4;
sbit CSB=P3^5;

unsigned char code ling0[]={
0x00,0x80,0xE0,0xF0,0xF8,0x18,0x0C,0x0C,0x0C,0x0C,0x18,0xF8,0xF0,0xE0,0x80,0x00,
0x00,0x03,0x0F,0x1F,0x3F,0x30,0x60,0x60,0x60,0x60,0x30,0x3F,0x1F,0x0F,0x03,0x00,
};
unsigned char code ba8[]={
0x00,0x00,0x70,0xF0,0xD8,0xC8,0x88,0x88,0x88,0x88,0x88,0xD8,0x70,0x70,0x00,0x00,
0x00,0x0C,0x1E,0x1E,0x33,0x21,0x21,0x21,0x21,0x23,0x23,0x37,0x1E,0x0C,0x00,0x00,};
unsigned char code ji[]={
0x20,0x30,0xAC,0x63,0x30,0x02,0x02,0xFE,0x82,0x02,0x42,0x72,0x4F,0xC2,0x00,0x00,
0x62,0x33,0x12,0x1A,0x4A,0x20,0x9C,0x43,0x21,0x16,0x08,0x14,0x63,0xC0,0x40,0x00,};
unsigned char code dian[]={
0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xFC,0x08,0x00,0x00,0x00,
0x00,0x07,0x02,0x02,0x02,0x02,0x3F,0x42,0x42,0x42,0x42,0x47,0x40,0x70,0x00,0x00,};
unsigned char code qi[]={
0x40,0x20,0x58,0x47,0x54,0x54,0x54,0x54,0x54,0x54,0xD4,0x14,0x06,0x04,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x40,0x80,0x70,0x00,};
unsigned char code er2[]={
0x00,0x00,0x60,0x70,0x78,0x4C,0x0C,0x0C,0x0C,0x0C,0x8C,0xF8,0xF0,0x60,0x00,0x00,
0x00,0x00,0x30,0x30,0x38,0x3C,0x34,0x36,0x32,0x33,0x31,0x31,0x38,0x3C,0x00,0x00,};
unsigned char code ban[]={
0x84,0x84,0xFC,0x84,0x06,0xF4,0x00,0xFF,0x00,0x84,0x84,0xFC,0x84,0x86,0x04,0x00,
0x20,0x60,0x3F,0x10,0x8A,0x41,0x38,0x07,0x40,0x40,0x40,0x7F,0x40,0x60,0x40,0x00,};
unsigned char code er12[]={
0x00,0x00,0x60,0x70,0x78,0x08,0x08,0x08,0x08,0x08,0x88,0xF8,0xF0,0x60,0x00,0x00,
0x00,0x00,0x30,0x30,0x38,0x3C,0x34,0x36,0x32,0x33,0x31,0x31,0x30,0x38,0x00,0x00};
unsigned char code er22[]={
0x00,0x00,0x60,0x70,0x78,0x08,0x08,0x08,0x08,0x08,0x88,0xF8,0xF0,0x60,0x00,0x00,
0x00,0x00,0x30,0x30,0x38,0x3C,0x34,0x36,0x32,0x33,0x31,0x31,0x30,0x38,0x00,0x00};
unsigned char code hao[]={
0x80,0x80,0x80,0xBE,0xA2,0xA2,0xA2,0xA2,0xA2,0xA2,0xA2,0xBF,0x82,0xC0,0x80,0x00,
0x00,0x00,0x00,0x04,0x06,0x05,0x04,0x04,0x44,0x84,0x44,0x3E,0x04,0x00,0x00,0x00,};
unsigned char code xing[]={
0x20,0x20,0x24,0xA4,0xA4,0xBF,0xA4,0xE4,0xA4,0xBF,0xA4,0xE6,0xA4,0x30,0x20,0x00,
0x00,0x80,0x80,0x5F,0x4A,0x2A,0x0A,0x0F,0x0A,0x2A,0x2A,0x4F,0x40,0x80,0x00,0x00};
unsigned char code ming1[]={
0x10,0x0C,0x04,0x55,0x55,0x55,0x05,0xFF,0x05,0x55,0x55,0x55,0x84,0x14,0x0C,0x00,
0x00,0x00,0x41,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0xFF,0x01,0x00,0x00};
unsigned char code ming2[]={
0x10,0x22,0x64,0x0C,0xC0,0x44,0x54,0x54,0x54,0x7F,0x54,0x54,0xD6,0x44,0x40,0x00,
0x04,0x04,0xFE,0x01,0x00,0x00,0xFF,0x15,0x15,0x15,0x55,0x95,0x7F,0x01,0x00,0x00};
unsigned char code FF1[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

void chk_busy()
{ DI=0;
RW=1;
E=1;
P1=0xff;
while((P1&0x80)!=0x80);
E=0;
}
/*------------------延时子程序-------

----------------------*/
void delay(unsigned int t)
{ unsigned int i,j;
for(i=0;ifor(j=0;j<10;j++)
;
}
/*------------------写命令到LCD------------------------------*/
void write_com(unsigned char cmdcode)
{
chk_busy();
DI=0;
RW=0;
E=1;
P1=cmdcode;
delay(5);////////////////////在数据写入的时候加入适当的延时
E=0;
delay(5);
}

/*-------------------写数据到LCD----------------------------*/
void write_data(unsigned char Dispdata)
{
chk_busy();
DI=1;
RW=0;
E=1;
P1=Dispdata;
delay(5);///////////////////在数据写入的时候加入适当的延时
E=0;
delay(5);
}
/*------------------初始化LCD屏--------------------------*/
void lcdreset()
{ delay(2000);
write_com(0x30);
delay(10); //选择基本指令集
write_com(0x30); //选择8bit数据流
delay(5);
write_com(0x0c); //开显示(无游标、不反白)
delay(10);
write_com(0x01); //清除显示,并且设定地址指针为00H
delay(500);
write_com(0x06); //指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位
delay(0);
}
/*------------------显示字符串--------------------------*/
void hzkdis(unsigned char code *s)
{ while(*s>0)
{ write_data(*s);
s++;
delay(50);
}
}
/*------------------清屏命令--------------------------*/
void clrscreen()
{
write_com(0x01);
delay(10);
}

void CGRAM1(unsigned char code *s)
{ int i;
write_com(0xb8);
write_com(0x40);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xb9);
write_com(0x40);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM2(unsigned char code *s)
{ int i;
write_com(0xb8);
write_com(0x50);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xb9);
write_com(0x50);

for(i=16;i<32;i++)
{write_data(s[i]);
}
}
void CGRAM3(unsigned char code *s)
{ int i;
write_com(0xb8);
write_com(0x60);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xb9);
write_com(0x60);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM4(unsigned char code *s)
{ int i;
write_com(0xb8);
write_com(0x70);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xb9);
write_com(0x70);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM5(unsigned char code *s)
{ int i;
write_com(0xb8);
write_com(0x40);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xb9);
write_com(0x40);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM6(unsigned char code *s)
{ int i;
write_com(0xb8);
write_com(0x50);
for(i=0;i<16;i++)
{write_data(s[i]);
}

write_com(0xb9);
write_com(0x50);

for(i=16;i<32;i++)
{write_data(s[i]);
}
}

void CGRAM7(unsigned char code *s)
{ int i;
write_com(0xb8);
write_com(0x60);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xb9);
write_com(0x60);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM8(unsigned char code *s)
{ int i;
write_com(0xba);
write_com(0x60);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbb);
write_com(0x60);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM9(unsigned char code *s)
{ int i;
write_com(0xbc);
write_com(0x50);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbd);
write_com(0x50);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM10(unsigned char code *s)
{ int i;
write_com(0xba);
write_com(0x40);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbb);
write_com(0x40);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}

void CGRAM11(unsigned char code *s)
{ int i;
write_com(0xba);
write_com(0x60);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbb);
write_com(0x60);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM12(unsigned char code *s)
{ int i;
write_com(0xbc);
write_com(0x50);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbd);
write_com(0x50);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM13(unsigned char code *s)
{ int i;
write_com(0xb8);
write_com(0x70);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xb9);
write_com(0x70);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM14(unsigned char code *s)
{ int i;
write_com(0xbA);
write_com(0x40);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbB);
write_com(0x40);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM15(unsigned char code *s)
{ int i;
write_com(0xbA);
write_com(0x50);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbB);
write_com(0x50);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM16(unsigned char code *s)
{ int i;
write_com(0xbA);
write_com(0x70);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbB);
write_com(0x70);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM17(unsigned char code *s)
{ int i;
write_com(0xbA);
write_com(0x50);
for(i=0;i<16;i++)
{write_dat

a(s[i]);
}
write_com(0xbB);
write_com(0x50);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM18(unsigned char code *s)
{ int i;
write_com(0xbA);
write_com(0x70);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbB);
write_com(0x70);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM19(unsigned char code *s)
{ int i;
write_com(0xbC);
write_com(0x40);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbD);
write_com(0x40);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM20(unsigned char code *s)
{ int i;
write_com(0xbC);
write_com(0x60);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbD);
write_com(0x60);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM21(unsigned char code *s)
{ int i;
write_com(0xbC);
write_com(0x70);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbD);
write_com(0x70);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM22(unsigned char code *s)
{ int i;
write_com(0xbC);
write_com(0x40);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbD);
write_com(0x40);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM23(unsigned char code *s)
{ int i;
write_com(0xbC);
write_com(0x60);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbD);
write_com(0x60);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM24(unsigned char code *s)
{ int i;
write_com(0xbC);
write_com(0x70);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbD);
write_com(0x70);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM25(unsigned char code *s)
{ int i;
write_com(0xbE);
write_com(0x40);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbF);
write_com(0x40);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM26(unsigned char code *s)
{ int i;
write_com(0xbE);
write_com(0x50);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbF);
write_com(0x50);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM27(unsigned char code *s)
{ int i;
write_com(0xbE);
write_com(0x60);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbF);
write_com(0x60);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM28(unsigned char code *s)
{ int i;
write_com(0xbE);
write_com(0x70);
for(i=0;i<16;i++)
{writ

e_data(s[i]);
}
write_com(0xbF);
write_com(0x70);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM29(unsigned char code *s)
{ int i;
write_com(0xbE);
write_com(0x40);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbF);
write_com(0x40);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM30(unsigned char code *s)
{ int i;
write_com(0xbE);
write_com(0x50);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbF);
write_com(0x50);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
void CGRAM31(unsigned char code *s)
{ int i;
write_com(0xbC);
write_com(0x70);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbD);
write_com(0x70);

for(i=16;i<32;i++)
{write_data(s[i]);
}
}

void CGRAM32(unsigned char code *s)
{ int i;
write_com(0xbE);
write_com(0x70);
for(i=0;i<16;i++)
{write_data(s[i]);
}
write_com(0xbF);
write_com(0x70);

for(i=16;i<32;i++)
{write_data(s[i]);
}

}
main()
{
//RES=0;
//delay(100);
// RES=1;
while(1)
{

//初始化LCD屏
delay(500);
write_com(0x3f);
delay(500) ;
write_com(0xb8);
delay(500);
write_com(0x40);
delay(500);
write_com(0xc0);
delay(500);
CSA=0;
CSB=1;
CGRAM1(ling0);
CGRAM2(ba8);
CGRAM3(ji);
CGRAM4(dian);
CSA=1;
CSB=0;
CGRAM5(qi);
CGRAM6(er2);
CGRAM7(ban);
CGRAM13(FF1);
CSA=0;
CSB=1;
CGRAM14(FF1);
CGRAM15(FF1);
CGRAM11(er12);
CGRAM16(FF1);
CSA=1;
CSB=0;
CGRAM17(FF1);
CGRAM10(er22);
CGRAM18(FF1);
CGRAM8(hao);
CSA=0;
CSB=1;
CGRAM19(FF1);
CGRAM12(xing);
CGRAM20(FF1);
CSA=1;
CSB=0;
CGRAM22(FF1);
CGRAM9(ming2);
CGRAM23(FF1);
CGRAM24(FF1);

CSA=0;
CSB=1;
CGRAM25(FF1);
CGRAM31(ming1);
CGRAM26(FF1);
CGRAM27(FF1);

CSA=1;
CSB=0;
CGRAM25(FF1);
CGRAM26(FF1);
CGRAM27(FF1);
CGRAM28(FF1);
CSA=0;
CSB=1;
CGRAM29(FF1);
CGRAM30(FF1);
CGRAM32(FF1);

//调用自定义的CGRAM的代码
write_data(0x00);
write_data(0x00);
delay(400);







}
}

相关文档
最新文档