avr 12864液晶
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
p_e=0; } //写数据到 LCM 子函数 void wdata(uchar c,uchar csl,uchar csr) { p_csl=csl;
p_csr=csr; lcd_busy(); p_di=1; p_rw=0; lcm=c;//将变量 C 赋予 LCM p_e=1; p_e=0; } //设定起始行 void set_startline(uchar i) { i=0xc0+i; wcode(i,1,1); } //定位 X 方向,Y 方向 void set_xy(uchar x,uchar y) { x=x+0x40; y=y+0xb8; wcode(x,1,1); wcode(y,1,1); } //屏幕开启、关闭 void dison_off(uchar o) { o=o+0x3e; //o 为 1 为开,为 0 是关 wcode(o,1,1); } //复位子函数 void reset() {//delay(1000); p_rst=0; delay(20); p_rst=1; delay(20); } //LCM 初始化 void lcd_init(void) { uchar x,y; reset();
{ disp_Hz(loop,y,loop+24,fb); } } if(i>=4) { if(i!=4)fb=0;
else fb=1;//
if(i==4)y=6; if(i==5)y=4; if(i==6)y=2; for(loop=0;loop<8;loop++)//5 {
disp_Hz(loop,y,loop+32,fb);//y=1 时 }} if(i>=5) { if(i!=5)fb=0;
void wdata(uchar c,uchar csl,uchar csr); void set_statrline(uchar i); void set_xy(uchar x,uchar y); void dison_off(uchar o); void reset(); void lcd_init(void); void lw(uchar x,uchar y,uchar dd);//写数据函数 void disp_Hz(uchar xx,uchar yy,uchar n,uchar fb);//显示汉字 void disp_Ez(uchar xx,uchar yy,uchar n,uchar fb);
0x04,0x00,0x64,0x00,0x24,0x81,0x24,0x41,0x24,0x21,0x2F,0x19,0xE4,0x07,0x24,0x01, 0x24,0x01,0x24,0x41,0x2F,0x81,0x24,0x7F,0x24,0x00,0x64,0x00,0x24,0x00,0x00,0x00,/*" 劳 ",3*/
if(lcm<0x80) break; p_e=0; } p_e=0;*/ } //写指令到 LCM void wcode(uchar c,uchar csl,uchar csr) { p_csl=csl; p_csr=csr; lcd_busy(); p_di=0; p_rw=0; lcm=c;//将变量 C 赋予 LCM p_e=1;
else fb=1;
if(i==5)y=6; if(i==6)y=4; if(i==7)y=2; 源自文库or(loop=0;loop<8;loop++)//6
{ disp_Hz(loop,y,loop+40,fb); } } if(i>=6) { if(i!=6)fb=0; else fb=1; if(i==6)y=6; if(i==7)y=4; for(loop=0;loop<8;loop++)//行 7
0x40,0x40,0x41,0x20,0xC6,0x1F,0x00,0x20,0x40,0x40,0x48,0x48,0x49,0x44,0x4E,0x43, 0xF8,0x40,0x4C,0x41,0x4B,0x42,0x48,0x4C,0x48,0x40,0x40,0x40,0x00,0x40,0x00,0x00,/*" 送 ",4*/
0x00,0x00,0xFE,0xFF,0x22,0x02,0x5A,0x04,0x86,0x43,0x10,0x48,0x94,0x24,0x74,0x22, 0x94,0x15,0x1F,0x09,0x34,0x15,0x54,0x23,0x94,0x60,0x94,0xC0,0x10,0x40,0x00,0x00,/*" 陵 ",1*/
0x00,0x00,0x40,0x40,0x30,0x48,0x12,0x48,0xDC,0x4B,0x54,0x4A,0x50,0x4A,0x5F,0x7E,
0x50,0x4A,0x50,0x4A,0xD8,0x4B,0x16,0x48,0x54,0x48,0x38,0x48,0x10,0x40,0x00,0x00,/*" 堂 ",6*/
{disp_Hz(loop,y,loop+48,fb); } } if(i==7) { if(i!=7)fb=0;
else fb=1;
for(loop=0;loop<8;loop++)//8 {
disp_Hz(loop,6,loop+56,fb);//y=1 时 }} delay(600);
}
} } uchar code HZ[]= {0x40,0x40,0x40,0x40,0x20,0x42,0x20,0x42,0x50,0x4A,0x48,0x72,0x44,0x42,0xC3,0x7F, 0x44,0x42,0x48,0x62,0x50,0x5A,0x50,0x42,0x20,0x42,0x60,0x40,0x20,0x40,0x00,0x00,/*" 金 ",0*/
0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" , ",7*/
/*128*64 液晶模块驱动程序 ,HD61202 驱动 创建时间:07.1.6 功能描述:循环显示李白的诗歌共 8 行,指定反白显示*/
#include <at89x51.h> //#include <intrins.h> #define uchar unsigned char #define uint unsigned int #define lcm P1 sbit p_csl=P2^4; sbit p_csr=P2^3; sbit p_di=P2^2; sbit p_rw=P2^1; sbit p_e=P2^0; sbit p_rst=P2^7; uchar code HZ[]; uchar code Ez[]; /*****函数声明********/ void delay(uint k); void wcode(uchar c,uchar csl,uchar csr);
dison_off(0);
for(y=0;y<8;y++) { for(x=0;x<128;x++)
lw(x,y,0); } dison_off(1); set_startline(0); } //写数据到 LCM void lw(uchar x,uchar y,uchar dd) { if(x>=64) { set_xy(x-64,y); wdata(dd,0,1); } else { set_xy(x,y);
dx=255-dx; lw(xx*8+i,yy,dx);//
dx=Ez[(2*i+1)+n*16]; if(fb)
dx=255-dx; lw(xx*8+i,yy+1,dx); } }
/*****主函数****/ void main() { uchar loop,i,y;//
uchar fb; lcd_init(); delay(300); for(loop=0;loop<2;loop++)//菜单 { disp_Hz(loop+1,0,loop+64,1); disp_Ez(13,0,10,0); disp_Ez(14,0,8,0); } while(1) {for(i=0;i<8;i++) { disp_Ez(12,0,i+1,0); if(i<3) { if(i!=0)fb=0; else fb=1; for(loop=0;loop<8;loop++)//行 1 { disp_Hz(loop,2,loop,fb); } } if(i<4) { if(i!=1)fb=0; else fb=1; if(i==3)y=2; else y=4; for(loop=0;loop<8;loop++)//2 { disp_Hz(loop,y,loop+8,fb); }} if(i<5) { if(i!=2)fb=0; else fb=1; if((i==0)||(i==1)||(i==2)) y=6; if(i==3)y=4; if(i==4)y=2; for(loop=0;loop<8;loop++)//3
{ disp_Hz(loop,y,loop+16,fb);//第一屏结束,每屏显示 3 行 } } if(i>=3) { if(i!=3)fb=0; else fb=1;//
if(i==3)y=6; if(i==4)y=4; if(i==5)y=2; for(loop=0;loop<8;loop++)//行 4
0x02,0x80,0x02,0x80,0x82,0x83,0xBA,0x42,0xAA,0x4A,0xAF,0x5B,0xAA,0x2A,0xBA,0x2A, 0xAA,0x2A,0xAF,0x5B,0xAA,0x4A,0xBA,0x42,0x82,0x83,0x02,0x80,0x00,0x80,0x00,0x00,/*" 蔓",8*/
0x00,0x08,0x18,0x08,0x04,0x05,0x84,0x04,0x44,0xFC,0x7C,0x46,0xA5,0x46,0x26,0x45, 0x24,0x45,0xA4,0x46,0x64,0x46,0x24,0xFE,0x14,0x04,0x0C,0x0C,0x04,0x04,0x00,0x00,/*" 客 ",5*/
0x04,0x00,0x64,0x00,0x24,0x81,0x24,0x41,0x24,0x21,0x2F,0x19,0xE4,0x07,0x24,0x01, 0x24,0x01,0x24,0x41,0x2F,0x81,0x24,0x7F,0x24,0x00,0x64,0x00,0x24,0x00,0x00,0x00,/*" 劳 ",2*/
if(fb) dx=255-dx;//反白显示
lw(xx*16+i,yy,dx); dx=HZ[(2*i+1)+n*32]; if(fb)
dx=255-dx; lw(xx*16+i,yy+1,dx); } } void disp_Ez(uchar xx,uchar yy,uchar n,uchar fb)//显示数字或英语 { uchar i,dx; for(i=0;i<8;i++) { dx=Ez[2*i+n*16]; if(fb)
wdata(dd,1,0); } } //显示汉字子函数 void disp_Hz(uchar xx,uchar yy,uchar n,uchar fb)//xx 为该行第 xx 个字,共 8 字,yy 为第几行, 共 8 行。 { uchar i,dx;
for(i=0;i<16;i++) { dx=HZ[2*i+n*32]; //2*i 为选择偶数行,因其为列扫描
//延时 void delay(uint k) { uint i;
for(;k>0;k--) { for(i=0;i<124;i++)
{;} } }
//
//LCM 忙判断 void lcd_busy(void) { p_di=0;
p_rw=1; /*lcm=0xff; while(1) { p_e=1;