/*******************************
函数名:void keyscan
功能:按键调时
********************************/
uchar keyscan()
{
uchar count1=5;
if(k1==0)
{
delay_ms(2);
if(k1==0) //确认功能键按下
{
s1num++;
di(); //蜂鸣器叫一声
}
}
if(s1num==1)
{
DisplayNum( 64, 4, TIME[1]/16);
DisplayNum( 56, 4, TIME[1]&0x0F); //分
Delay10ms(10);
DisplayNum( 64, 4, 12);
DisplayNum( 56, 4, 12);
Delay10ms(10);
DisplayNum( 64, 4, TIME[1]/16);
DisplayNum( 56, 4, TIME[1]&0x0F);
if(k2==0)
{
delay_ms(2);
if(k2==0)
{
di();
TIME[1]++;
Ds1302WriteTime();
if(TIME[1]==60)
{
TIME[1]=0;
}
}
}
if(k3==0)
{
delay_ms(2);
if(k3==0)
{
di();
TIME[1]--;
Ds1302WriteTime();
if(TIME[1]==0)
{
TIME[1]=60;
}
}
}
}
if(s1num==2)
{
DisplayNum( 88, 4, TIME[2]/16);
DisplayNum( 80, 4, TIME[2]&0x0F); //时
Delay10ms(10);
DisplayNum( 88, 4, 12);
DisplayNum( 80, 4, 12);
Delay10ms(10);
DisplayNum( 88, 4, TIME[2]/16);
DisplayNum( 80, 4, TIME[2]&0x0F);
if(k2==0)
{
delay_ms(2);
if(k2==0)
{
di();
TIME[2]++;
Ds1302WriteTime();
if(TIME[2]==24)
{
TIME[2]=0;
}
}
}
if(k3==0)
{
di();
delay_ms(2);
if(k3==0)
{
TIME[2]--;
Ds1302WriteTime();
if(TIME[2]==0)
{
TIME[2]=24;
}
}
}
}
if(s1num==3)
{
DisplayNum( 56, 2, TIME[3]/16);
DisplayNum( 48, 2, TIME[3]&0x0F); //日
Delay10ms(10);
DisplayNum( 56, 2, 12);
DisplayNum( 48, 2, 12);
Delay10ms(10);
DisplayNum( 56, 2, TIME[3]/16);
DisplayNum( 48, 2, TIME[3]&0x0F);
if(k2==0)
{
delay_ms(2);
if(k2==0)
{
di();
TIME[3]++;
Ds1302WriteTime();
if(TIME[3]==31)
{
TIME[2]=1;
}
}
}
if(k3==0)
{
delay_ms(2);
if(k3==0)
{
di();
TIME[3]--;
Ds1302WriteTime();
if(TIME[3]==0)
{
TIME[3]=31;
}
}
}
}
if(s1num==4)
{
DisplayNum( 80, 2, TIME[4]/16);
DisplayNum( 72, 2, TIME[4]&0x0F); //月
Delay10ms(10);
DisplayNum( 80, 2, 12);
DisplayNum( 72, 2, 12);
Delay10ms(10);
DisplayNum( 80, 2, TIME[4]/16);
DisplayNum( 72, 2, TIME[4]&0x0F);
if(k2==0)
{
di();
delay_ms(2);
if(k2==0)
{
TIME[4]++;
Ds1302WriteTime();
if(TIME[4]==12)
{
TIME[4]=1;
}
}
}
if(k3==0)
{
delay_ms(2);
if(k3==0)
{
di();
TIME[4]--;
Ds1302WriteTime();
if(TIME[4]==0)
{
TIME[4]=12;
}
}
}
}
if(s1num==5)
{
DisplayNum( 0, 2, TIME[5]&0x07); //周
Delay10ms(10);
DisplayNum( 0, 2, 12);
Delay10ms(10);
DisplayNum( 0, 2, TIME[5]&0x07);
if(k2==0)
{
delay_ms(2);
if(k2==0)
{
di();
TIME[5]++;
Ds1302WriteTime();
if(TIME[5]==7)
{
TIME[5]=1;
}
}
}
if(k3==0)
{
delay_ms(2);
if(k3==0)
{
di();
TIME[5]--;
Ds1302WriteTime();
if(TIME[5]==0)
{
TIME[5]=7;
}
}
}
}
if(s1num==6)
{
DisplayNum( 104, 2, TIME[6]/16);
DisplayNum( 96, 2, TIME[6]&0x0F); //年
Delay10ms(10);
DisplayNum( 104, 2, 12);
DisplayNum( 96, 2, 12);
Delay10ms(10);
DisplayNum( 104, 2, TIME[6]/16);
DisplayNum( 96, 2, TIME[6]&0x0F);
// Ds1302WriteTime();
if(k2==0)
{
delay_ms(2);
if(k2==0)
{
di();
TIME[6]++;
Ds1302WriteTime();
}
}
if(k3==0)
{
delay_ms(2);
if(k3==0)
{
di();
TIME[6]--;
Ds1302WriteTime();
}
}
}
if(s1num==7)
{
s1num=0;
}
return s1num;
}
12是全是取模的0x00。
程序可以运行,就是不大流畅,大神能看看哪里有点问题吗,大二小生拜谢 |