128*64液晶简单单片机代码
0x00,0x00,0x00,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x04,0x10,
0x04,0x10,0x04,0x10,0x04,0x10,0x06,0x10,0x04,0x10,0x00,0x18,0x00,0x10,0x00,0x00,/*"二",0*/
0x00,0x04,0x0C,0x04,0x04,0x04,0x55,0x0A,0x55,0x0A,0x55,0x09,0x85,0x2A,0x7F,0xCC,
0x85,0x28,0x55,0x19,0x55,0x09,0x55,0x02,0x05,0x06,0x0C,0x02,0x04,0x02,0x00,0x00,/*"零",1*/
0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,
0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xC0,0x00,0x80,0x00,0x00,0x00,/*"一",2*/
0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,
0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xC0,0x00,0x80,0x00,0x00,0x00,/*"一",3*/
0x40,0x04,0x20,0x04,0x10,0x04,0x0C,0x04,0xE3,0x07,0x22,0x04,0x22,0x04,0x22,0x04,
0xFE,0xFF,0x22,0x04,0x22,0x04,0x22,0x04,0x22,0x04,0x02,0x04,0x00,0x04,0x00,0x00};/*"年",4*/
//---------------------------12864.h-----------函数库------------
void delay(unsigned long v) //延时子函数
{
while(v--);
}
void lcd_busy() //判断是否繁忙函数
{
rs=0;
rw=1;
dataport=0xff;
while(1)
{
en=1;
if(dataport<0x80)break; //并口最高位为1时表示芯片正在工作
en=0;
}
en=0;
}
void wcode(uchar c,uchar csl,uchar csr) //写指令函数
{
CS1=csl; //显示左屏变量
CS2=csr; //显示右屏变量
lcd_busy();
rs=0;
rw=0;
dataport=c;
en=1;
en=0;
}
void wdata(uchar c,uchar csl,uchar csr) //写数据子函数
{
CS1=csl;
CS2=csr;
lcd_busy();
rs=1;
rw=0;
dataport=c;
en=1;
en=0;
}
void lw(uchar x,uchar y,uchar dd)// 写1个字节进RAM函数
{
if(x>=64) //列大于64说明是右半屏操作
{
set_xy(x-64,y);
wdata(dd,0,1);
}
else
{//否则左半屏
set_xy(x,y);
wdata(dd,1,0);
}
}
void set_startline(uchar i) //设置起始行
{
i=0xc0+i;
wcode(i,1,1);
}
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 k) //液晶关,开函数
{
k=k+0x3e;
wcode(k,1,1);
}
void reset() //复位函数
{
RST=0;
delay(40);
RST=1;
delay(40);
}
void lcd_init(void)//液晶初始化
{uchar x,y;
reset();
set_startline(0);
dison_off(0);
for(y=0;y<8;y++)
{
for(x=0;x<128;x++)lw(x,y,0);
}
dison_off(1);
}
void display_hz(uchar xx, uchar yy, uchar n, uchar fb) //中文字显示函数 扫描方法采用逐列式
{
uchar i,dx;
for(i=0;i<16;i++) //一个汉字列扫描值
{dx=hz[2*i+n*32];//汉字上半部分扫描
if(fb)dx=255-dx;//反显
lw(xx*8+i,yy,dx);//数据写入芯片
dx=hz[(2*i+1)+n*32];//汉字下半部分扫描
if(fb)dx=255-dx; //反显
lw(xx*8+i,yy+1,dx);//数据写入芯片
}
}
评论