uchar dispbuf[4]; //显示数组
uchar hour,min,sec,sec20;
uchar dispbit,count,keynum,keysec,keysec1;
bit id,flag,buzz,key1,key2,flag1,bit1,bit2;
uchar ps[4]={1,2,3,4}; //初始密码
uchar pw[4]; //密码数组,用于存放输入的密码,用于比较
uchar keycount;
bit error,right,hibit;
uchar wr,ok,wr1,ok10; //密码锁标志
void disptime() //显示数组更新
{if(flag)
{dispbuf[0]=hour/10;
dispbuf[1]=hour%10;
dispbuf[2]=min/10;
dispbuf[3]=min%10;
}
}
void delayms(int ms)
{ uchar i;
while(ms--)
{
for(i=0;i<250;i++);
{ _nop_();
_nop_();
_nop_();
_nop_();
}
}
}
void sound()
{ spk=0;
delayms(100);
spk=1;
}
uchar key()
{ uchar cl,ch,temp;
P1=0xf0;
if((P1&0xf0)!=0xf0)
{ delayms(10);
if((P1&0xf0)!=0xf0)
{ cl=0xfe;
while(cl&0x10)
{ P1=cl;
if((P1&0xf0)!=0xf0)
{ ch=(P1&0xf0)|0x0f;
temp=(~ch)|(~cl);
while((P1&0xf0)!=0xf0)
{ if(temp==0x18)
key1=1;
if(temp==0x84)
bit1=1;
P1=0xf0;
}
key1=0;bit1=0;
if(keysec>2)
key2=1;
if(keysec1>2)
bit2=1;
keysec=0;keysec1=0;
return (~ch)|(~cl);
}
else
cl=(cl<<1)|0x01;
}
}
}
return 0;
}
uchar keyscan()
{ switch(key())
{ case 0x11:sound();return 0;
case 0x21:sound();return 1;
case 0x41:sound();return 2;
case 0x81:sound();return 3;
case 0x12:sound();return 4;
case 0x22:sound();return 5;
case 0x42:sound();return 6;
case 0x82:sound();return 7;
case 0x14:sound();return 8;
case 0x24:sound();return 9;