12864显示图形Word格式文档下载.docx
《12864显示图形Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《12864显示图形Word格式文档下载.docx(10页珍藏版)》请在冰豆网上搜索。
![12864显示图形Word格式文档下载.docx](https://file1.bdocx.com/fileroot1/2023-2/4/7ec69864-b388-47b8-af82-5899dc79e511/7ec69864-b388-47b8-af82-5899dc79e5111.gif)
*/
ucharcodeHzk[]={
//左屏幕第1页
0xFF,0xFF,0xFF,0xFF,0x7F,0xBF,0x3F,0xBF,0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,
0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,
//左屏幕第2页
0xFF,0xFF,0xFF,0xAB,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,
0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,
//左屏幕第3页
0xFF,0xFF,0xFF,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0xE0,0xEA,0xE0,0xEA,
0xE0,0xEA,0xE0,0xEA,0xE0,0xEA,0xC0,0xAA,0x00,0xAA,0xE0,0xEA,0xE0,0xEA,0xE0,0xEA,
0xE0,0xEA,0xE0,0xEA,0xE0,0xEA,0x80,0xAA,0x00,0xAA,0x00,0xAA,0xC0,0xEA,0xE0,0xEA,
0xE0,0xEA,0xE0,0xEA,0xC0,0xEA,0x80,0xAA,0x00,0xAA,0xE0,0xEA,0xE0,0xEA,0xE0,0xEA,
//左屏幕第4页
0xFF,0xFF,0xFF,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0xFF,0xFF,0xFF,0xFF,
0x38,0xBA,0x38,0xBF,0x3F,0xBF,0x1F,0xAF,0x00,0xAA,0xFF,0xFF,0xFF,0xFF,0xFF,0xBA,
0x78,0xFA,0xFD,0xFF,0xDF,0xBF,0x0F,0xAA,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0x01,0xAA,
0x00,0xAA,0x01,0xEF,0xFF,0xFF,0xFF,0xFE,0x00,0xAA,0x00,0xAA,0x00,0xAA,0xFF,0xFF,
//左屏幕第5页
0xFF,0xFF,0xFF,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x0F,0xAF,0x0F,0xAF,
0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x0F,0xAF,0x0F,0xAF,0x0F,0xAA,
0x00,0xAA,0x03,0xAF,0x0F,0xAF,0x0F,0xAE,0x00,0xAA,0x01,0xAB,0x07,0xAF,0x0F,0xAE,
0x0E,0xAE,0x0F,0xAF,0x07,0xAF,0x03,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x0F,0xAF,
//左屏幕第6页
0xFF,0xFF,0xFF,0xEA,0x80,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,
//左屏幕第7页
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
//左屏幕第8页
0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,
//右屏幕第1页
0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,0x1F,0xBF,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
//右屏幕第2页
0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x00,0xAA,0x01,0xFF,0xFF,0xFF,0xFF,0x00,
//右屏幕第3页
0xE0,0xEA,0xE0,0xEA,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FE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
//右屏幕第8页
0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x00,
};
/*状态检查,LCD是否忙*/
voidCheckState()
{
uchardat;
//状态信息(判断是否忙)
RS=0;
//数据\指令选择,D/I(RS)=“L”,表示DB7∽DB0为显示指令数据
RW=1;
//R/W=“H”,E=“H”数据被读到DB7∽DB0
do{
DATA=0x00;
EN=1;
//EN下降源
_nop_();
//一个时钟延时
dat=DATA;
EN=0;
dat=dat>
>
7;
//仅当第7位为0时才可操作(判别busy信号)
}while(!
(dat==0x00));
}
/*写命令到LCD中*/
SendCommandToLCD(ucharcom)
CheckState();
//状态检查,LCD是否忙
//向LCD发送命令。
RS=0写指令,RS=1写数据
RW=0;
//R/W=“L”,E=“H→L”数据被写到IR或DR
DATA=com;
//com:
命令
//EN下降源
/*设置页0xb8是页的首地址*/
voidSetLine(ucharpage)
page=0xb8|page;
//10111xxx0<
=page<
=7设定页地址--X0-7,8行为一页64/8=8,共8页
SendCommandToLCD(page);
/*设定显示开始行,0xc0是行的首地址*/
voidSetStartLine(ucharstartline)
startline=0xc0|startline;
//11000000
SendCommandToLCD(startline);
//设置从哪行开始:
0--63,一般从0行开始显示
/*设定列地址--Y0-63,0x40是列的首地址*/
voidSetColumn(ucharcolumn)
column=column&
0x3f;
//column最大值为64,越出0=<
column<
=63
column=0x40|column;
//01xxxxxx
SendCommandToLCD(column);
/*开关显示,0x3f是开显示,0x3e是关显示*/
voidSetOnOff(ucharonoff)
onoff=0x3e|onoff;
//0011111x,onoff只能为0或者1
SendCommandToLCD(onoff);
/*写显示数据*/
voidWriteByte(uchardat)
RS=1;
//RS=0写指令,RS=1写数据
////R/W=“L”,E=“H→L”数据被写到IR或DR
DATA=dat;
//dat:
显示数据
/*选择屏幕screen:
0-全屏,1-左屏,2-右屏*/
voidSelectScreen(ucharscreen)
{
switch(screen)
{case0:
cs1=0;
//全屏
cs2=0;
break;
case1:
//左屏
cs2=1;
case2:
cs1=1;
//右屏
}
/*清屏screen:
0-全屏,1-左屏,2-右*/
voidClearScreen(ucharscreen)
{
uchari,j;
SelectScreen(screen);
for(i=0;
i<
8;
i++)//控制页数0-7,共8页
SetLine(i);
SetColumn(0);
for(j=0;
j<
64;
j++)
//控制列数0-63,共64列
{
WriteByte(0x00);
//写点内容,列地址自动加1
/*延时程序*/
voiddelay(uintz)
uinti,j;
i<
z;
i++)
for(j=0;
j<
110;
j++);
/*向上滚屏*//*这里用做滚动显示*/
voidlcd_rol()
uinti;
for(i=0;
i<
64;
SendCommandToLCD(0xc0+i);
//片选2
//SendCommandToLCD(0xc0+62-i);
delay(100);
/*初始化LCD*/
voidInitLCD()
CheckState();
SelectScreen(0);
SetOnOff(0);
//关显示
SetOnOff
(1);
//开显示
ClearScreen(0);
//清屏
SetStartLine(0);
//开始行:
/*显示单屏幕一页*/
voidDisplay(ucharss,ucharpage,ucharcolumn,ucharnumber)
inti;
//ss选屏参数,page选页参数,column选列参数number区块共计8页×
2屏幕=16取值0~15
SelectScreen(ss);
column=column&
SetLine(page);
//
SetColumn(column);
//控制列
i++)//控制64列的数据输出
WriteByte(Hzk[i+64*number]);
//64个数据输出
/*主函数*/
voidmain()
uinti;
InitLCD();
//初始12864
ClearScreen(0);
//清屏
SetStartLine(0);
//显示开始行
while
(1)
{
/*Display(选屏参数(cs0,cs1),pagr选页参数,column选列参数,number选第几汉字输出)*/
for(i=0;
i++)
Display(2,i,0,i);
//左屏幕i页,0列i块
Display(1,i,0,i+8);
//右屏幕i页,0列i+8块
}
//delay(5000);
//停住
//lcd_rol();
//滚动
/*这里用做滚动显示*/
/*while
(1)
lcd_rol();
delay(1000);
}*/
显示效果:
仿真电路图: