欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
CK3148電子鐘源程序 修正BUG
[打印本頁]
作者:
51hei麗人
時(shí)間:
2016-6-21 01:01
標(biāo)題:
CK3148電子鐘源程序 修正BUG
哈哈,最近又做了一個(gè)程序,這已經(jīng)是我制造的第三個(gè)電子鐘了,不知道我為什么這么喜歡電子鐘?
圖片和升級(jí)版的程序詳見:
http://m.raoushi.com/bbs/dpj-52307-1.html
/***********************************************************************
作者:TZR
版本:CK3148 (ver1.2)
功能: 1顯示時(shí)間
2顯示日期
3計(jì)算年份
4鬧鐘功能
5超小體積設(shè)計(jì)(電池最大……)
6整點(diǎn)報(bào)時(shí)
日志:V1:實(shí)現(xiàn)走時(shí)功能,程序整體不穩(wěn)定,鬧鐘和整點(diǎn)報(bào)時(shí)功能不正常。
V1.2:修正鬧鐘和整點(diǎn)報(bào)時(shí)BUG,修正出現(xiàn)“0月0日的”BUG,修正年份顯示錯(cuò)誤的問題。
***************************************************************************/
#include <stc12c2052ad.h>
unsigned char hour;
unsigned char min;
unsigned char sec;
unsigned char st;
unsigned char t;
unsigned char alh;
unsigned char alm;
unsigned char yearH;
unsigned char yearL;
unsigned char month;
unsigned char beepc;
unsigned char day;
unsigned char mo;
unsigned bm[12]={1,0,1,0,1,0,1,1,0,1,0,1};
bit am;
sbit mode=P1^7;
sbit chan=P1^6;
sbit beep=P3^7;
sbit v4=P1^5;
sbit c=P1^4;
sbit b=P1^3;
sbit v3=P1^2;
sbit v2=P1^1;
sbit d=P1^0;
sbit e=P3^0;
sbit f=P3^1;
sbit h=P3^2;
sbit g=P3^3;
sbit a=P3^4;
sbit v1=P3^5;
#define close v1=0;v2=0;v3=0;v4=0;
#define led0 a=1;b=1;c=1;d=1;e=1;f=1;g=1;h=1;
#define num0 a=1;b=0;c=0;d=0;e=0;f=0;g=0;
#define num1 a=1;b=1;c=1;e=1;f=1;d=0;g=0;
#define num2 f=0;e=0;d=0;c=0;a=0;
#define num3 g=0;f=0;d=0;c=0;a=0;
#define num4 g=0;d=0;b=0;a=0;
#define num5 g=0;f=0;c=0;b=0;a=0;
#define num6 c=0;b=0;e=0;f=0;g=0;a=0;
#define num7 c=0;d=0;g=0;
#define num8 a=0;b=0;c=0;d=0;e=0;f=0;g=0;
#define num9 a=0;b=0;c=0;d=0;f=0;g=0;
CLKS0=1;
void delay (unsigned int a){
unsigned int i;
while( --a != 0){
for(i = 0; i < 300; i++);
}
}
void paint(unsigned char i){
if(i==0){num0;}
if(i==1){num1;}
if(i==2){num2;}
if(i==3){num3;}
if(i==4){num4;}
if(i==5){num5;}
if(i==6){num6;}
if(i==7){num7;}
if(i==8){num8;}
if(i==9){num9;}
}
void main (void){
P3M0=0x00;
P3M1=0x80;
mode=0;
beep=0;
beepc=0;
chan=0;
mo=0;
EA=1;
ET0=1;
st=0;
close;
led0;
hour=11;
min=59;
alh=12;
alm=00;
sec=59;
TH0=0x00;
TL0=0x00;
TR0=1;
t=1;
am=1;
yearH=20;
yearL=11;
month=4;
day=23;
while(1){
if(mo==0){
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
if(chan==1){
delay(20);
if(chan==1){
beep=0;
beepc=0;
while(chan==1);
}
}
if(sec%10==8 || sec%10==9){
led0;
paint(day%10);//0001
close;
v1=1;
delay(t);
led0;
paint(day/10);//0010
close;
v2=1;
delay(t);
led0;
paint(month%10);//0100
h=0;
close;
v3=1;
delay(t);
led0;
paint(month/10);//1000
close;
v4=1;
delay(t);
}else{
led0;
paint(min%10);//0001
close;
v1=1;
delay(t);
led0;
paint(min/10);//0010
close;
v2=1;
delay(t);
led0;
paint(hour%10);//0100
h=sec%2;
close;
v3=1;
delay(t);
led0;
paint(hour/10);//1000
close;
v4=1;
delay(t);
}
}else if(mo==1){
if(st<50){
led0;
paint(hour/10);//1000
close;
v4=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
hour+=10;
if(hour>23){
hour=0;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==2){
if(st<50){
led0;
paint(hour%10);//1000
close;
v3=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
hour+=1;
if(hour%10==0){
hour-=10;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==3){
if(st<50){
led0;
paint(min/10);//1000
close;
v2=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
min+=10;
if(min>59){
min=0;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==4){
if(st<50){
led0;
paint(min%10);//1000
close;
v1=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
min+=1;
if(min%10==0){
min-=10;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==5){
if(st<50){
led0;
paint(month/10);//1000
close;
v2=1;
delay(t);
led0;
paint(month%10);//1000
close;
v1=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
month+=1;
if(month==13){
month=1;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==6){
if(st<50){
led0;
paint(day/10);//1000
close;
v2=1;
delay(t);
led0;
paint(day%10);//1000
close;
v1=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
day+=1;
if(day==32){
day=1;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==7){
if(st<50){
led0;
paint(yearL%10);//0001
close;
v1=1;
delay(t);
led0;
paint(yearL/10);//0010
close;
v2=1;
delay(t);
led0;
paint(yearH%10);//0100
h=0;
close;
v3=1;
delay(t);
led0;
paint(yearH/10);//1000
close;
v4=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
yearL+=1;
if(yearL>=30){
yearL=11;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==8){
if(st<50){
led0;
paint(alh/10);//1000
close;
v4=1;
delay(t);
led0;
paint(alh%10);//1000
close;
v3=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
alh+=1;
if(alh>23){
alh=0;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==9){
if(st<50){
led0;
paint(alm/10);//1000
close;
v2=1;
delay(t);
led0;
paint(alm%10);//1000
close;
v1=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
alm+=1;
am=1;
if(alm>=60){
alm=0;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo=0;
}
while(mode==1);
}
}
}
}
void t0 (void) interrupt 1 {
st++;
if(st>99){
st=0;
sec++;
if(beep==1){
beepc--;
if(beepc<=0){
beep=0;
}
}
}
if(sec>59){
sec=0;
min++;
if(min==alm && hour==alh && am==1){
beep=1;
beepc=50;
}
}
if(min>59){
min=0;
hour++;
beep=1;//整點(diǎn)報(bào)時(shí)
beepc=1;
}
if(hour>23){
hour=0;
day++;
if(month==2){
if(yearL%4==0){
if(day==30){
day=0;
month++;
}
}else{
if(day==29){
day=0;
month++;
}
}
}else if(bm[month]==0){
if(day==31){
day=0;
month++;
if(month==13){
month=1;
yearL++;
}
}
}else if(bm[month]==1){
if(day==32){
day=0;
month++;
if(month==13){
month=1;
yearL++;
}
}
}
}
TH0=0x6c;/*7a9c*/
TL0=0xc2;
}
復(fù)制代碼
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1