下面是在12864上显示的时钟(1302)的一小段程序,为什么我调整时间的时候只有1到10 是正常的,超过之后就不是依次加一了,比如10一下跳到17,怎么回事?
if(key2==0)
{
timedelay(20);
if(key2==0)
{
while(!key2);
if(k==1)
{
year++;
if(year>99) year=0;
write_(year,1,2);//送进12864显示
year1=year/10;
year2=year%10;
year1=year1&0xff;
year2=year2&0xff;
year1<<=4;
year=year1|year2;// 10to16
write_1302(0x8e,0x00); //WP=0 写操作命令
write_1302(0x8c,year);//写进1302
}
if(k==2)
{
mon++;
if(mon>12) mon=1;
write_(mon,1,4);
mon1=mon/10;
mon2=mon%10;
mon1=mon1&0xff;
mon2=mon2&0xff;
mon1<<=4;
mon=mon1|mon2;// 10to16
write_1302(0x8e,0x00); //WP=0 写操作命令
write_1302(0x88,mon);
}
if(k==3)
{
date++;
if(date>31) date=1;
write_(date,1,6);
date1=date/10;
date2=date%10;
date1=date1&0xff;
date2=date2&0xff;
date1<<=4;
date=date1|date2;// 10to16
write_1302(0x8e,0x00); //WP=0 写操作命令
write_1302(0x86,date);
}
if(k==4)
{
hou++;
if(hou>24) hou=0;
write_(hou,3,1);
hou1=hou/10;
hou2=hou%10;
hou1=hou1&0xff;
hou2=hou2&0xff;
hou1<<=4;
hou=hou1|hou2;// 10to16
write_1302(0x8e,0x00); //WP=0 写操作命令
write_1302(0x84,hou);
}
if(k==5)
{
min++;
if(min>59) min=0;
write_(min,3,3);
min1=min/10;
min2=min%10;
min1=min1&0xff;
min2=min2&0xff;
min1<<=4;
min=min1|min2;// 10to16
write_1302(0x8e,0x00); //WP=0 写操作命令
write_1302(0x82,min);
}
if(k==6)
{
week++;
if(week>7) week=1;
lcd_pos(4,2);
j=0;
if(week==1)
{
while(table1[j]!=' ')
{
lcd_wdat(table1[j]);
timedelay(15);
j++;
}//显示week//
}
if(week==2)
{
while(table2[j]!=' ')
{
timedelay(15);
j++;
}//显示week//
}
if(week==3)
{
while(table3[j]!=' ')
{
lcd_wdat(table3[j]);
timedelay(20);
j++;
}//显示week//
}
if(week==4)
{
while(table4[j]!=' ')
{
lcd_wdat(table4[j]);
timedelay(15);
j++;
}//显示week//
}
if(week==5)
{
while(table5[j]!=' ')
{
lcd_wdat(table5[j]);
timedelay(15);
j++;
}//显示week//
}
if(week==6)
{
while(table6[j]!=' ')
{
lcd_wdat(table6[j]);
timedelay(15);
j++;
}//显示week//
}
if(week==7)
{
while(table7[j]!=' ')
{
lcd_wdat(table7[j]);
timedelay(15);
j++;
}//显示week//
}
week1=week/10;
week2=week%10;
week1=week1&0xff;
week2=week2&0xff;
week1<<=4;
week=week1|week2;// 10to16
write_1302(0x8e,0x00); //WP=0 写操作命令
write_1302(0x8a,week);
}
}
}
一周热门 更多>