#include<reg51.h>
#include<intrins.h>
#include<stdio.h>
#include <string.h>
#define uint unsigned int
#define uchar unsigned char
sbit E=P2^0;
sbit RW=P2^1;
sbit RS=P2^2;
sbit cs1=P2^3;
sbit cs2=P2^4;
sbit key=P3^0;
uchar dat,u,z,r,p,i;
uchar code wei[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x60,0x02,0x8C,0x00,0x88,0x88,0xFF,0x88,0x88,0x00,0xFE,0x22,0x22,0xFE,0x00,
0x04,0xE4,0x24,0x24,0x64,0xA4,0x24,0x3F,0x24,0xA4,0x64,0x24,0x24,0xE4,0x04,0x00,
0x20,0x20,0xFF,0x20,0x20,0xF8,0x88,0x88,0x88,0x08,0xFF,0x08,0x09,0xCA,0x08,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x04,0x04,0x7E,0x01,0x00,0x1F,0x08,0x08,0x08,0x9F,0x60,0x1F,0x42,0x82,0x7F,0x00,
0x00,0xFF,0x00,0x08,0x09,0x09,0x09,0x7F,0x09,0x09,0x09,0x48,0x80,0x7F,0x00,0x00,
0x10,0x30,0x1F,0x88,0x68,0x1F,0x10,0x20,0x9F,0x40,0x27,0x18,0x26,0x41,0xF0,0x00, //?????
0x00,0x08,0x88,0x88,0x88,0x88,0x89,0xFA,0x88,0x88,0x88,0x88,0x88,0x08,0x00,0x00,
0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,
0x00,0xFE,0x22,0x5A,0x86,0x10,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x14,0x0C,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x10,0x20,0x1F,0x00,0x00,0x00,
0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00,
0x00,0xFF,0x04,0x08,0x07,0x80,0x41,0x31,0x0F,0x01,0x01,0x3F,0x41,0x41,0x71,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //????
0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,
0x10,0x10,0xD0,0xFF,0x90,0x00,0x10,0xD0,0x10,0xD0,0x10,0xFF,0x10,0x92,0x14,0x00,
0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0xF8,0x00,0x00,0x00,
0x20,0x10,0x4C,0x47,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0xD4,0x04,0x04,0x00,0x00,
0x04,0x03,0x00,0xFF,0x00,0x83,0x60,0x1F,0x00,0x00,0x00,0x3F,0x40,0x40,0x78,0x00,
0x04,0x03,0x00,0xFF,0x00,0x41,0x31,0x0F,0x01,0xBF,0x41,0x27,0x38,0x47,0xF0,0x00,
0x00,0x00,0x1F,0x08,0x08,0x08,0x08,0x7F,0x88,0x88,0x88,0x88,0x9F,0x80,0xF0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x30,0x40,0xF0,0x00,
0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,
0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0x3E,0x22,0x22,0x22,0x22,0x22,0x3E,0x00,0x00,
0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,
0x00,0xFE,0x22,0x5A,0x86,0x10,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x14,0x0C,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
0x08,0x06,0x01,0xFF,0x01,0x06,0x40,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x41,0x00,
0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00,
0x00,0xFF,0x04,0x08,0x07,0x80,0x41,0x31,0x0F,0x01,0x01,0x3F,0x41,0x41,0x71,0x00, //??е????????
0x48,0x2A,0x1A,0x7E,0x19,0x29,0x48,0xFC,0x24,0x26,0xFD,0x24,0x24,0xFC,0x00,0x00,
0x00,0x10,0x10,0x90,0x10,0x10,0x11,0x16,0x10,0x10,0x10,0xD0,0x10,0x10,0x00,0x00,
0x5E,0x50,0x50,0x5F,0x50,0x50,0xDE,0x00,0xFE,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x82,0x8A,0x56,0x23,0x52,0x8E,0x80,0x61,0x19,0x07,0x7D,0x99,0x95,0x91,0xD8,0x00,
0x40,0x40,0x40,0x40,0x43,0x5C,0x40,0x40,0x50,0x4C,0x43,0x40,0x40,0x40,0x40,0x00,
0x00,0x7E,0x42,0x22,0x22,0x12,0x93,0x60,0x1F,0x00,0x00,0x3F,0x40,0x40,0x78,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //κ????
};
uchar code digit0[]={
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,
0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
0x00,0x30,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x18,0x20,0x21,0x21,0x22,0x1C,0x00,
0x00,0x00,0x80,0x40,0x30,0xF8,0x00,0x00,0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24,
0x00,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x20,0x20,0x20,0x11,0x0E,0x00,
0x00,0xE0,0x10,0x88,0x88,0x90,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x20,0x1F,0x00,
0x00,0x18,0x08,0x08,0x88,0x68,0x18,0x00,0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x00,
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
0x00,0xF0,0x08,0x08,0x08,0x10,0xE0,0x00,0x00,0x01,0x12,0x22,0x22,0x11,0x0F,0x00
};
uchar code maohao[]={
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x31,0x31,0x31,0x31,0x00,
0x00,0x00
};
void delayms(uchar a)
{
uint i,j;
for(i=a;i>0;i--);
for(j=110;j>0;j--);
}
void readzhuangtai()
{
uchar z;
RW=1;
RS=0;
z=P0;
while(z&0x80==0);
}
void write_com(uchar commend)
{
readzhuangtai();
RW=0;
RS=0;
delayms(5);
P0=commend;
delayms(5);
E=1;
delayms(5);
E=0;
}
void write_data(uchar date)
{
readzhuangtai();
RW=0;
RS=1;
delayms(5);
P0=date;
delayms(5);
E=1;
delayms(5);
E=0;
}
void changezuo(uchar j,uchar y) //j??????
{
cs1=0;
cs2=1;
write_com(0x3f);
write_com(0x40);
write_com(0xb8+2*(y-1));
for(i=0;i<16*8;i++)
{
write_data(wei[128*(j-1)*2+i]);
}
}
void changeyou(uchar k,uchar l)
{
cs1=1;
cs2=0;
write_com(0x3f);
write_com(0x40);
write_com(0xb8+2*(l-1));
for(i=0;i<16*8;i++)
{
write_data(wei[128*k*2-128+i]);
}
}
void time(uchar q,uchar s)
{
cs1=0;
cs2=1;
write_com(0x3f);
write_com(0x40+q*8);
write_com(0xbe);
for(i=8*2*s;i<8*(2*s+1);i++)
{
write_data(digit0[ i]);
}
write_com(0x40+q*8);
write_com(0xbf);
for(i=8*(2*s+1);i<16*s+16;i++)
{
write_data(digit0[ i]);
}
}
void maohao1(uchar q)
{
cs1=0;
cs2=1;
write_com(0x40+q*8);
write_com(0xbe);
for(i=0;i<9;i++)
{
write_data(maohao[ i]);
}
write_com(0x40+q*8);
write_com(0xbf);
for(i=9;i<18;i++)
{
write_data(maohao[ i]);
}
}
void T0timer() interrupt 1
{
TH0=(65536-50000)/255;
TL0=(65536-50000)%255;
u=u++;
if(u==20)
{
u=0;
z=z+1;
}
if(z==60)
{
++r;
z=0;
if(r==60)
{
++p;
r=0;
if(p==24)
{
z=0;
r=0;
p=0;
}
}
}
}
void main()
{
uchar i,s,d,w,e,t,y;
TMOD=0x01; //?????????м??
TH0=(65536-50000)/255; //???50ms?????ж???ж?20??????
TL0=(65536-50000)%255;
EA=1;
ET0=1;
TR0=1;
IT0=1;
EX0=1;
PT0=1;
RW=0;
changezuo(1,1); //?????????????
changezuo(2,2);
changezuo(3,3);
changeyou(1,1);
changeyou(2,2);
while(1)
{
s=p/10;
d=p%10;
w=r/10;
e=r%10;
t=z/10;
y=z%10;
time(0,s);
time(1,d);
maohao1(2);
time(3,w);
time(4,e);
maohao1(5);
time(6,t);
time(7,y);
}
}
|