#include "reg52.h"
#define uchar unsigned char
#define uint unsigned int
sbit zr=P1^0;
sbit zy=P1^1;
sbit zg=P1^2;
sbit hr=P1^3;
sbit hy=P1^4;
sbit hg=P1^5;
sbit stop=P1^0;
sbit set=P1^1;
sbit add=P1^2;
sbit sub=P1^3;
uchar code tab[]=
{
0xc9,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90
};
ys(uint i)
{
while(i--);
}
uchar u,q,bz=0,moshi=0,shezhi=0,dxnb=1,jixu=1,dx=30,nb=25,qq=25,qqq=25;
light()
{
if (dxnb==0)
{
if(nb>5)zg=0,hr=0;
if(nb==5)dx=5,zg=1,zy=0;
if(nb==0)dxnb=!dxnb,dx=qq+5,nb=qq;
}
if (dxnb==1)
{
if(dx>5)zy=1,hr=1,hg=0,zr=0;
if(dx==5)nb=5,hg=1,hy=0;
if(dx==0)dxnb=!dxnb,dx=qqq,nb=qqq+5,hy=1,zr=1;
}
}
suma()
{
P2=0xdf;P0=tab[nb/10];
ys(200);
P2=0xef;P0=tab[nb%10];
ys(200);
P2=0xf7;P0=0xbf;
ys(200);
P2=0xfb;P0=0xbf;
ys(200);
P2=0xfd;P0=tab[dx/10];
ys(200);
P2=0xfe;P0=tab[dx%10];
ys(200);
}
suma1()
{
P2=0xdf;P0=tab[qq/10];
ys(200);
P2=0xef;P0=tab[qq%10];
ys(200);
P2=0xf7;P0=0xbf;
ys(200);
P2=0xfb;P0=0xbf;
ys(200);
P2=0xfd;P0=tab[qqq/10];
ys(200);
P2=0xfe;P0=tab[qqq%10];
ys(200);
}
ds()
{
P2=0xdf;P0=0x89;
ys(200);
P2=0xef;P0=0x86;
ys(200);
P2=0xf7;P0=0xc7;
ys(200);
P2=0xfb;P0=0xc7;
ys(200);
P2=0xfd;P0=0xc0;
ys(200);
}
display(uchar duan,uchar wei)
{
P0=duan;
P2=wei;
ys(100);
}
keyget()
{
if (stop==0)
{
jixu=!jixu;
if(jixu==0)TR0=0,u=0,q=0;
if(jixu==1)TR0=1,moshi=0;
if(jixu==1&q==1)TR0=1,moshi=0,dxnb=1,P1=0xff,dx=qq+5,nb=qq;
while(stop==0)suma();
}
if (add==0&TR0==0&moshi==1)
{
while(add==0)suma1();
if(shezhi==1)qq=qq+1;
if(shezhi==2)qqq=qqq+1;
if(qq>30)qq=10;
if(qqq>30)qqq=10;
}
if (sub==0&TR0==0&moshi==1)
{
while(sub==0)suma1();
if(shezhi==1)if(qq>10)qq=qq-1;else qq=30;
if(shezhi==2)if(qqq>10)qqq=qqq-1;else qqq=30;
}
}
main()
{
EA=ET0=ET1=1;
TMOD=0x11;
TR0=0;
while (1)
{
if (bz==0)
{
ds();
}
if (stop==0)
{
while(stop==0)suma();
bz=1,TR0=1;
}
if (bz==1)
{
while (1)
{
light();
keyget();
if(moshi==0)suma();
else suma1();
}
}
}
}
t1() interrupt 1
{
TH0=15535/256;
TL0=15535%256;
u++;
if(u==10)u=0,dx--,nb--;
}
|