内容发布更新时间 : 2024/12/23 8:48:42星期一 下面是文章的全部内容请认真阅读。
}
if(menu_1 == 1) { if(menu_2 == 1) 设置时
{ if(key_can == 3) 加 { shi+=0x01;
if((shi & 0x0f) >=
0x0a)
shi = (shi & 0xf0)
+ 0x10; if(shi >= 0x24)
shi = 0; }
if(key_can == 4) 减
{ if(shi == 0x00)
shi = 0x24;
if((shi & 0x0f) ==
0x00)
shi = (shi | 0x0a)
- 0x10; shi -- ;
}
}
if(menu_2 == 2) 设置分
{
if(key_can == 3)
加
{ fen+=0x01;
if((fen & 0x0f) >=
0x0a)
fen = (fen & 0xf0)
+ 0x10; if(fen >= 0x60)
fen = 0; }
if(key_can == 4) 减
{ if(fen == 0x00)
fen = 0x5a;
if((fen & 0x0f) ==
0x00)
fen = (fen | 0x0a)
- 0x10;
fen -- ;
}
}
if(menu_2 == 3) 设置秒
{ if(key_can == 3) 加
{ miao+=0x01;
if((miao & 0x0f) >=
0x0a)
miao = (miao &
0xf0) + 0x10;
if(miao >= 0x60)
miao = 0; if((week & 0x0f) ==
}
if(key_can == 4) 减
0x00)
week = (week |
{ if(miao == 0x00)
miao = 0x5a;
if((miao & 0x0f) ==
0x00)
miao = (miao |
0x0a) - 0x10; miao -- ;
}
}
if(menu_2 == 4)
设置星
期 { if(key_can == 3) 加
{ week+=0x01;
if((week & 0x0f) >=
0x0a)
week = (week &
0xf0) + 0x10; if(week >= 0x08)
week = 1; }
if(key_can == 4) 减
{ if(week == 0x01)
week = 0x08;
0x0a) - 0x10;
week -- ;
}
}
if(menu_2 == 5) 设置年
{
if(key_can == 3) 加
{
nian+=0x01;
if((nian & 0x0f) >=
0x0a)
nian = (nian &
0xf0) + 0x10; if(nian >= 0x9a)
nian = 1; }
if(key_can == 4) 减
{ if(nian == 0x01)
nian = 0x9a;
if((nian & 0x0f) ==
0x00)
nian = (nian |
0x0a) - 0x10;
nian -- ;
}
}
27
if(menu_2 == 6) 设置月 { if(key_can == 3) 加
{
yue+=0x01;
if((yue & 0x0f) >=
0x0a)
yue = (yue & 0xf0)
+ 0x10; if(yue >= 0x13)
yue = 1; }
if(key_can == 4) 减
{ if(yue == 0x01)
yue = 0x13;
if((yue & 0x0f) ==
0x00)
yue = (yue | 0x0a)
- 0x10;
yue -- ;
}
}
if(menu_2 == 7) 设置日
{ if(key_can == 3) 加
{
ri+=0x01;
if((ri & 0x0f) >= 0x0a)
ri = (ri & 0xf0) +
0x10;
if(ri >= 0x32)
ri = 0;
}
if(key_can == 4) 减
{ if(ri == 0x01)
ri = 0x32;
if((ri & 0x0f) ==
0x00)
ri = (ri | 0x0a)
- 0x10;
ri -- ;
}
}
write_sfm2_ds1302(1,2,shi);
显示时
write_sfm2_ds1302(1,5,fen);
显示分
write_sfm2_ds1302(1,8,miao);
显示秒
write_sfm1(1,14,week);
显示星期
write_sfm2_ds1302(2,3,nian);
显示年
write_sfm2_ds1302(2,6,yue);
显示月
write_sfm2_ds1302(2,9,ri);
显示日
switch(menu_2) 光标显示 {
case
1:
bj_shudu = 0;
}
if(key_can == 4) { if(bj_shudu != 0) 减
write_guanbiao(1,2,1); break;
case
2:
write_guanbiao(1,5,1); break;
case
3:
write_guanbiao(1,8,1); break;
case
4:
write_guanbiao(1,14,1); break;
case
5:
write_guanbiao(2,3,1); break;
case
6:
write_guanbiao(2,6,1); break;
case
7:
write_guanbiao(2,9,1); break; }
write_time(); 把时间写
进去 }
if(menu_1 == 2) {
if(menu_2 == 1)
设置速
度 { if(key_can == 3) 加
{ bj_shudu++;
if(bj_shudu >= 99)
bj_shudu -- ;
}
}
if(menu_2 == 2)
把总量
程清零
{ if(key_can == 3)
{
zong_lc= 0;
}
if(key_can == 4)
{ zong_lc= 0;
}
}
write_sfm2(1,7,bj_shudu);
显示报警速度
write_sfm7(2,4,zong_lc);
显示
switch(menu_2) 光标显示
{
29
case 1: write_guanbiao(1,6,1); break;
case
2:
write_guanbiao(2,3,1); break; }
write_eeprom();
}
}
****************报
警
函
数
*************** void clock_() { beep = 0; delay_1ms(200) ;
P0 = P1 = P2 = P3 = 0xff; IO口
初始为电平 init_ds1302_io(); init_ds1302();
init_1602(); 1602初始化 init_int0();
time_init();
定时器0初始化
程序
init_eeprom(); 开机初始化保存
的数据* while(1)
{ shudu = 11; key();
按键程序
if(key_can < 10)
{
key_with();
}
if(flag_200ms == 1) { flag_200ms = 0;
read_time();
读
时间 if(menu_1 == 0)
init_1602_ds1302();
显示时钟
menu_dis(); 计算速度函
数 clock_ = 1;
break; }
}
*************定时器0中断服务程序***************
void time0_int() interrupt 1
{ static uchar value; TH0 = 0x3c;
TL0 = 0xb0; 50ms value++;
if(value % 4 == 0)
flag_200ms = 1;
if(value >= 20) 1秒 才是一秒