微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 128*64代码进化版显示时,分,秒

128*64代码进化版显示时,分,秒

时间:11-30 来源:互联网 点击:

07,0xC0,0x04,0x20,0x24,0x10,0x24,0xF8,0x3F,0x00,0x24,0x00,0x00,/*"4",4*/

0x00,0x00,0xF8,0x19,0x08,0x21,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00,/*"5",5*/

0x00,0x00,0xE0,0x0F,0x10,0x11,0x88,0x20,0x88,0x20,0x18,0x11,0x00,0x0E,0x00,0x00,/*"6",6*/

0x00,0x00,0x38,0x00,0x08,0x00,0x08,0x3F,0xC8,0x00,0x38,0x00,0x08,0x00,0x00,0x00,/*"7",7*/

0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00,/*"8",8*/

0x00,0x00,0xE0,0x00,0x10,0x31,0x08,0x22,0x08,0x22,0x10,0x11,0xE0,0x0F,0x00,0x00,/*"9",9*/

0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00};/*"0",10*/

//------------------------------库函数---------------------------

void delay(unsigned long v) //延时子函数
{
while(v--);
}

void lcd_busy() //繁忙标志
{
rs=0;
rw=1;
dataport=0xff;
while(1)
{
en=1;
if(dataport<0x80)break;
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) //写一个字节进芯片
{
if(x>=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,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);
}
}

void display_asc(uchar xx,uchar yy,uchar n,uchar fb) //显示数字逐列式
{
uchar i,dx;
for(i=0;i<8;i++)
{
dx=asc[2*i+n*16];
if(fb)dx=255-dx;
lw(xx*8+i,yy,dx);
dx=asc[2*i+1+n*16];
if(fb)dx=255-dx;
lw(xx*8+i,yy+1,dx);
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top