#include <REGX52.H>
#include <INTRINS.H>
#include "DT.h"
#include "delay.h"
#include "keypad.h"
#include "buzzer.h"
#include "independent button.h"
#include "decimalism.h"
#include <REGX52.H>
#include <INTRINS.H>
int jk=0;
sbit BEEP=P2^5;
void Timer0Init(void) //1??@11.0592MHz
{
TMOD &= 0xF0; //???????
TMOD |= 0x01; //???????
TL0 = 0x00; //??????
TH0 = 0xDC; //??????
TF0 = 0; //??TF0??
TR0 = 1; //???0????
EA=1;
ET0=1;
}
/*void Timer1Init(void) //10000??@11.0592MHz
{
TMOD &= 0x0F; //???????
TMOD |= 0x10; //???????
TL1 = 0x00; //??????
TH1 = 0xDC; //??????
TF1 = 0; //??TF1??
TR1 = 1; //???1????
EA=1;
ET1=0;
}*/
int time[4][2]={0,0,0,0,0,0,0,0},time_flag[3][4][2]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int **timep=time;
int ***time_flagp=time_flag;
int kf=-1;//±ê¼Çչʾʱ¼ä½ÚµãÕ»Öеĵڼ¸¸ö
int k=-1;//±ê¼ÇÒѾÉ趨Á˶àÉÙλ
int kkk[3]={-1,-1,-1};//¸¨Öúɾ³ýʱ¼ä½Úµã
int kkk_move=-1;//°ïÖúÂÖ»»ÏÔʾʱ¼ä½Úµã
int sound=0;
int allkey()
{
int reFkey=0,rekeypad_detect=0;
reFkey=Fkey();
rekeypad_detect=keypad_detect();
if(reFkey!=0)return reFkey;
if(rekeypad_detect!=0)return rekeypad_detect;
return 0;
}
void shuru(key)
{
int ii=k;
for(;ii>-1;ii--)
{time[ii+1][0]=time[ii][0];time[ii+1][1]=time[ii][1];}
k++;
time[0][0]=key;time[0][1]=0;
}
void del()
{
int i=0;
for(;i<k;i++){time[i][0]=time[i+1][0];time[i][1]=time[i+1][1];}
time[k][0]=0;time[k][0]=0;
k--;
}
int et1=0;
void keyfun(int key)reentrant
{
int n=3;
switch (key)
{
case 1:for(jk=0;jk<10;jk++)musicHz_self(500);jk=0;shuru(7);break;
case 2:for(jk=0;jk<10;jk++)musicHz_self(485);jk=0;shuru(8);break;
case 3:for(jk=0;jk<10;jk++)musicHz_self(470);jk=0;shuru(9);break;
case 4:for(jk=0;jk<10;jk++)musicHz_self(455);jk=0;P2_0=0;sound=1;break;
case 5:for(jk=0;jk<10;jk++)musicHz_self(440);jk=0;shuru(4);break;
case 6:for(jk=0;jk<10;jk++)musicHz_self(425);jk=0;shuru(5);break;
case 7:for(jk=0;jk<10;jk++)musicHz_self(410);jk=0;shuru(6);break;
case 8:for(jk=0;jk<10;jk++)musicHz_self(395);jk=0;sound=2;break;
case 9:for(jk=0;jk<10;jk++)musicHz_self(380);jk=0;shuru(1);break;
case 10:for(jk=0;jk<10;jk++)musicHz_self(365);jk=0;shuru(2);break;
case 11:for(jk=0;jk<10;jk++)musicHz_self(350);jk=0;shuru(3);break;
case 12:for(jk=0;jk<10;jk++)musicHz_self(335);jk=0;sound=3;break;
case 13:for(jk=0;jk<10;jk++)musicHz_self(320);jk=0;shuru(0);break;
case 14:for(jk=0;jk<10;jk++)musicHz_self(305);jk=0;time[0][1]=1;break;
case 15:for(jk=0;jk<10;jk++)musicHz_self(290);jk=0;del();break;
case 16:for(jk=0;jk<10;jk++)musicHz_self(275);jk=0;if(et1==0)et1=1;else et1=0;break;
case 17:for(jk=0;jk<10;jk++)musicHz_self(265);jk=0;
/*while(1)
{
if(kkk_move==0)kkk_move=2;else kkk_move--;
if(kkk[kkk_move]!=-1){kkk_move=kkk[kkk_move];break;}
}
break;*/
/*case 18:for(jk=0;jk<100;jk++)musicHz_self(250);jk=0;
while(1)
{
if(kkk_move==2)kkk_move=0;else kkk_move++;
if(kkk[kkk_move]!=-1){kkk_move=kkk[kkk_move];break;}
}
break;
case 19:for(jk=0;jk<10;jk++)musicHz_self(225);jk=0;kkk[kkk_move]=-1;keyfun(17);
/*while(1)
{
if(kkk_move==0){kkk_move=2;if(kkk[kkk_move]!=-1)break;}
if(kkk[kkk_move-1]!=-1){kkk_move=kkk[kkk_move-1];break;}
if(kkk[0]==-1&&kkk[1]==-1&&kkk[2]==-1)break;
}*/
break;*/
case 20:for(jk=0;jk<10;jk++)musicHz_self(210);jk=0;
kf++;
kkk[kf]=kf;
kkk_move=kkk[kf];
for(;n>=0;n--)
{
time_flag[kf][n][0]=time[n][0];
time_flag[kf][n][1]=time[n][1];
}
n=3;break;
}
}
int m=0;
int num=0xff;
int led=0x1;
void warning()reentrant
{
if(m==1)
{
while(1)
{
if(sound==0){
P2=num-led;
Delayms(100);
P2=num;
Delayms(100);}
if(sound==1){m=0;break;}
if(sound==2){time[2][0]=5;sound=0;et1=1;m=0;break;}
if(sound==3){time[3][0]=1;time[2][1]=1;sound=0;et1=1;m=0;break;}
}
}
}
void main()
{
Timer0Init();
while(1)
{
//showtandf(timep,time_flagp);
//void showtandf(int** time,int*** time_flag)
//{
int i=0;warning();
for(i=0;i<4;i++)
{
DTshow(i+5,time[i][0],time[i][1]);
}
if(kkk_move!=-1)
{
for(i=0;i<4;i++)
{
DTshow(i+1,time_flag[kkk_move][i][0],time_flag[kkk_move][i][1]);
}
}
//}
}
}
int mmm=0;
void key_detect() interrupt 1
{
//void timeflood() interrupt 2
//{
TL0 = 0x00; //??????
TH0 = 0xDC; //??????
if(et1==1)
{
int i=0;
//Timer1Init();ET1=1;
time[0][0]--;
//¼ìÑéÊ®½øÖÆ
for(i=0;i<sizeof(time)/2-1;i++)
{
if(time[i][0]==-1){time[i][0]=9;time[i+1][0]--;}
}
if(time[sizeof(time)/2-1][0]==-1)
{
for(i=0;i<sizeof(time)/2;i++)
{
time[i][0]=0;
}
}
if(time[0][0]==0&&time[1][0]==0&&time[2][0]==0&&time[3][0]==0){m=1;et1=0;}
}
//}ledflag();
if(sound==0&&m==1)
{
BEEP=!BEEP;
}
mmm++;
if(mmm==100)
{keyfun(allkey());mmm=0;}
}
杂(勿看)
最新推荐文章于 2024-08-25 06:11:42 发布