持续进阶之三数码管简易时钟显示(续完)显示消影
0赞
上代码了,比之前做了微笑的消影处理,显示比之前的稍微好点了,万恶的影子浪费了我这么多时间
经过几番的折腾,有点小收获了_^-^_
综合原因就是定时器的刷新速度太快,还有就是573的没有足够的时间去送完一组数据,导致上次数据还没完经更着下一次数据又送出,所以产生了从影也就是所谓的鬼影,以后有好的方法在做细微的处理吧,暂时先到这里了,o_o
/*
MCU:STC89C52RC
Fosc:11059200Hz
日期:2014-04-28
网名:坎悟积验
功能:简单的数码管时钟
显示:00-00-00 :hour-fend-miao
*/
#include <reg52.h>
typedef unsigned char Uint8;
typedef unsigned int Uint16;
Uint8 code shuLED[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x80,0x40};
#define Pro0 P0
sbit DULA = P1^7;
sbit WELA = P1^6;
Uint8 tab[8] = {0};
Uint8 miao = 0,fend = 0,hour = 0;
Uint8 i = 0;
Uint16 m = 0;
void main()
{
TMOD = 0x01;
TH0 = 0xf5;//0xf1;0xf8;
TL0 = 0x33;//0x9a;0xcd;
EA = 1;
ET0 = 1;
TR0 = 1;
while(1)
{
if(m == 333)
{
m = 0;
miao++;
if(miao == 60)
{
miao = 0;
fend++;
if(fend == 60)
{
fend = 0;
hour++;
if(hour == 24)
{
hour = 0;
}
tab[0] = hour/10;
tab[1] = hour%10;
}
tab[2] = fend/10;
tab[3] = fend%10;
}
tab[4] = miao/10;
tab[5] = miao%10;
}
}
}
void time0() interrupt 1
{
static Uint8 i = 0;
TH0 = 0xf5;
TL0 = 0x33;
m++;
switch(i)
{
case 0:
DULA = 1;
Pro0 = shuLED[tab[0]];
DULA = 0;
Pro0 = 0xff;
WELA = 1;
Pro0 = 0xfe;
WELA = 0;
Pro0 = 0xff;
i++;
break;
case 1:
DULA = 1;
Pro0 = shuLED[tab[1]];
DULA = 0;
Pro0 = 0xff;
WELA = 1;
Pro0 = 0xfd;
WELA = 0;
Pro0 = 0xff;
i++;
break;
case 2:
DULA = 1;
Pro0 = shuLED[11];
DULA = 0;
Pro0 = 0xff;
WELA = 1;
Pro0 = 0xfb;
WELA = 0;
Pro0 = 0xff;
i++;
break;
case 3:
DULA = 1;
Pro0 = shuLED[tab[2]];
DULA = 0;
Pro0 = 0xff;
WELA = 1;
Pro0 = 0xf7;
WELA = 0;
Pro0 = 0xff;
i++;
break;
case 4:
DULA = 1;
Pro0 = shuLED[tab[3]];
DULA = 0;
Pro0 = 0xff;
WELA = 1;
Pro0 = 0xef;
WELA = 0;
Pro0 = 0xff;
i++;
break;
case 5:
DULA = 1;
Pro0 = shuLED[11];
DULA = 0;
Pro0 = 0xff;
WELA = 1;
Pro0 = 0xdf;
WELA = 0;
Pro0 = 0xff;
i++;
break;
case 6:
DULA = 1;
Pro0 = shuLED[tab[4]];
DULA = 0;
Pro0 = 0xff;
WELA = 1;
Pro0 = 0xbf;
WELA = 0;
Pro0 = 0xff;
i++;
break;
case 7:
DULA = 1;
Pro0 = shuLED[tab[5]];
DULA = 0;
Pro0 = 0xff;
WELA = 1;
Pro0 = 0x7f;
WELA = 0;
Pro0 = 0xff;
i = 0;
break;
default: break;
}
}
之前的消影没处理好很明显的看到有可恶的影子。。。。。。
经过微笑的处理看起来稍微好点了,等日后有良好的方法再继续改进,数码管暂时到这里结束;继续学习状态机
