我是将时钟写在液晶的前16位,闹钟写在液晶的后16位,
时钟已经设置好,而且可以正常调试,但是当按下闹钟键时,也就是移屏之后,发现不能调整时间,为什么呢?很急!!!!
(移屏正常,按下key4的时候指针也能准确指到),但就是按下key2和key3屏幕没有反应!
相应代码如下:
//************闹钟键盘扫描**********
void keyscan1()
{
if(key4==0)
{
delay(5);
if(key4==0)
{
while(!key4);
flag1++;
if(flag1==1)
{
for(num=0;num<16;num++)
write_com(0x18);
delay(20);
}
if(flag1==2)
{
write_com(0x0f);
write_com(0x80+0x5a);
}
if(flag1==3)
{
write_com(0x0f);
write_com(0x80+0x57);
}
if(flag1==4)
{
write_com(0x0f);
write_com(0x80+0x54);
}
if(flag1==5)
{
flag1=0;
for(num=0;num<16;num++)
write_com(0x1c);
delay(20);
}
if(flag1!=0)
{
if(key2==0)
{
delay(5);
if(key2==0)
{
while(!key2);
if(flag1==2)
{
miao1++;
if(miao1==60)
miao1=0;
write_sfm(26,miao1);
write_com(0x80+0x5a);
}
if(flag1==3)
{
fen1++;
if(fen1==60)
fen1=0;
write_sfm(23,fen1);
write_com(0x80+0x57);
}
if(flag1==4)
{
shi1++;
if(shi1==23)
shi1=0;
write_sfm(20,shi1);
write_com(0x80+0x54);
}
}
}
if(key3==0)//数字减少
{
delay(5);
if(key3==0)
{
while(!key3);
if(flag1==2)
{
if(miao1==0)
miao1=60;
miao1--;
write_sfm(26,miao1);
write_com(0x80+0x5a);
}
if(flag1==3)
{
if(fen1==0)
fen1=60;
fen1--;
write_sfm(23,fen1);
write_com(0x80+0x57);
}
if(flag1==4)
{
if(shi1==0)
shi1=24;
shi1--;
write_sfm(20,shi1);
write_com(0x80+0x54);
}
}
}
}
}
}
}
此帖出自
小平头技术问答
一周热门 更多>