//////////////////////////////////////////////////////////////////////////////////////////////////////////// void Downkey()//降序按键 {
Down=1;
if(Down==0||wireless_3==1)
{
mdelay(8); switch(count) {case 1:
temp=Read1302(DS1302_SECOND); //读取秒数
temp=temp-1;
//秒数减1
down_flag=1; //数据调整后更新标志
if(temp==0x7f) //小于0秒,返回59秒 temp=0x59; break;
case 2:
temp=Read1302(DS1302_MINUTE); //读取分数
temp=temp-1; //分数减1
down_flag=1;
if(temp==-1)
temp=0x59; //小于0秒,返回59秒 break;
case 3:
读取小时数
读取星期数
temp=Read1302(DS1302_HOUR); //
temp=temp-1; //小时数减1
down_flag=1; if(temp==-1) temp=0x23;
break;
case 4:
temp=Read1302(DS1302_WEEK); //
temp=temp-1; //星期数减1
down_flag=1; if(temp==0) temp=0x7;;
break;
case 5:
temp=Read1302(DS1302_DAY); //读
取日数
temp=temp-1; //日数减1
down_flag=1;
//读取月数
读取年数
if(temp==0) temp=31;
break;
case 6:
temp=Read1302(DS1302_MONTH);
temp=temp-1; //月数减1
down_flag=1; if(temp==0) temp=12;
break;
case 7:
temp=Read1302(DS1302_YEAR);
temp=temp-1; //年数减1
down_flag=1; if(temp==-1) temp=0x85;
break;
// }
default:break;
}
while(Down==0); while(wireless_3==1); }
void Setkey()//模式选择按键 {
Set=1;
if(Set==0||wireless_4==1)
{
mdelay(8); count=count+1;
done=1;
//Setkey按一次,count就加1
//进入调整模式
while(Set==0); while(wireless_4==1); }
}
void keydone()//按键功能执行 { uchar Second;
if(flag==0) //关闭时钟,停止计时
{ Write1302(0x8e,0x00); //写入允许 temp=Read1302(0x80); Write1302(0x80,temp|0x80);
Write1302(0x8e,0x80); //禁止写入
flag=1; } Setkey();
switch(count) {case 1:do {
//扫描跳出按钮
//count=1,调整秒
//扫描模式切换按键
outkey(); 据
{
Upkey(); //扫描加按钮 Downkey(); //扫描减按钮
if(up_flag==1||down_flag==1) //数据更新,重新写入新的数
Write1302(0x8e,0x00); //写入允许
Write1302(0x80,temp|0x80); //写入新的秒数 Write1302(0x8e,0x80); //禁止写入
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库基于利用时钟芯片DS1302实现万年历,1602LCD显示电子表 - 图文(7)在线全文阅读。
相关推荐: