显示计时功能都实现了。
正在研究按键调时功能,键扫描能够通过,但调时间无法实现
如何实现按键暂停,启动计时,调整时间?(一个键选择调整位置,一个键加1)
求高手分享经验!不胜感激。
7 个解决方案
#1
复杂的键盘扫描 显示你都做出来了
简单的启动定时器就不会拉
简单的启动定时器就不会拉
#2
这是一键多能 ,不好做!
#3
我有一个1602的。你可以参考一下
void keyscan()
{
rd=0;
if(flag1==1)
{
if(s2==0)
{
delay(5);
if(s2==0)
{
while(!s2);
flag1=0;
}
}
if(s3==0)
{
delay(5);
if(s3==0)
{
while(!s3);
flag1=0;
}
}
}
if(s1==0)
{
delay(5);
if(s1==0)
{ s1num++;
flag=1;
flag1=0;
while(!s1);
if(s1num==1)
{
TR0=0;
write_com(0x80+0x40+10);
write_com(0x0f);
}
}
if(s1num==2)
{
write_com(0x80+0x40+7);
}
if(s1num==3)
{
write_com(0x80+0x40+4);
}
if(s1num==4)
{
s1num=0;
write_com(0x0c);
flag=0;
write_ds(0,miao);
write_ds(2,fen);
write_ds(4,shi);
}
}
if(s1num!=0)
{
if(s2==0)
{
delay(1);
if(s2==0)
{
while(!s2);
if(s1num==1)
{
miao++;
if(miao==60)
miao=0;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen++;
if(fen==60)
fen=0;
write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi++;
if(shi==24)
shi=0;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}
}
}
if(s3==0)
{
delay(1);
if(s3==0)
{
while(!s3);
if(s1num==1)
{
/* if(miao==0)
{
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}*/
miao--;
if(miao==-1)
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen--;
if(fen==-1)
fen=59;
write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi--;
if(shi==-1)
shi=23;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}
}
}
}
}
void keyscan()
{
rd=0;
if(flag1==1)
{
if(s2==0)
{
delay(5);
if(s2==0)
{
while(!s2);
flag1=0;
}
}
if(s3==0)
{
delay(5);
if(s3==0)
{
while(!s3);
flag1=0;
}
}
}
if(s1==0)
{
delay(5);
if(s1==0)
{ s1num++;
flag=1;
flag1=0;
while(!s1);
if(s1num==1)
{
TR0=0;
write_com(0x80+0x40+10);
write_com(0x0f);
}
}
if(s1num==2)
{
write_com(0x80+0x40+7);
}
if(s1num==3)
{
write_com(0x80+0x40+4);
}
if(s1num==4)
{
s1num=0;
write_com(0x0c);
flag=0;
write_ds(0,miao);
write_ds(2,fen);
write_ds(4,shi);
}
}
if(s1num!=0)
{
if(s2==0)
{
delay(1);
if(s2==0)
{
while(!s2);
if(s1num==1)
{
miao++;
if(miao==60)
miao=0;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen++;
if(fen==60)
fen=0;
write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi++;
if(shi==24)
shi=0;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}
}
}
if(s3==0)
{
delay(1);
if(s3==0)
{
while(!s3);
if(s1num==1)
{
/* if(miao==0)
{
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}*/
miao--;
if(miao==-1)
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen--;
if(fen==-1)
fen=59;
write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi--;
if(shi==-1)
shi=23;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}
}
}
}
}
#4
可以先定义个结构体
extern struct TIME
{
uchar sec;
uchar min;
uchar h;
uchar day;
uchar week;
uchar mon;
uchar year;
uchar ap: 1; //分配一位
};
将时间日期读到结构体中的变量中。
下面是我写的一个按键调整时间日期的函数
void key2_event()
{
uchar bcd;
if(count == 0)
return;
if(count == 1)
{
time.year++;
if(time.year == 100)
time.year = 0;
bcd = ((time.year / 10) << 4) | (time.year % 10);
write_DS1302(0x8C, bcd);
}
if(count == 2)
{
time.mon++;
if(time.mon == 13)
time.mon = 1;
bcd = ((time.mon / 10) << 4) | (time.mon % 10);
write_DS1302(0x88, bcd);
}
if(count == 3)
{
uint y;
uchar i;
uchar max_day;
y = time.year;
//time.day++;
if(((y + 2000) % 4 == 0 && (y + 2000) % 100 != 0) || (y + 2000) % 400 == 0)//闰年
{
if(!((y+2000) == 2000))
dy[1] = 29;
}
else
{
dy[1] = 28;
}
for(i = 0; i < 12; i++)
{
if(time.mon == mo[i])
{
max_day = dy[mo[i] - 1];
}
}
time.day++;
if(time.day >= max_day + 1)
time.day = 1;
bcd = ((time.day / 10) << 4) | (time.day % 10);
write_DS1302(0x86, bcd);
}
if(count == 4)
{
time.week++;
if(time.week == 8)
time.week = 1;
bcd = ((time.week / 10) << 4) | (time.week % 10);
write_DS1302(0x8A, bcd);
}
if(count == 5)
{
time.h++;
bcd = read_DS1302(0x85);
if(bcd & 0x80) //12
{
if(time.h == 13)
time.h = 1;
}
else //24
{
if(time.h == 24)
time.h = 0;
}
bcd = ((time.h / 10) << 4) | (time.h % 10);
write_DS1302(0x84, bcd);
}
if(count == 6)
{
time.min++;
if(time.min == 60)
time.min = 0;
bcd = ((time.min / 10) << 4) | (time.min % 10);
write_DS1302(0x82, bcd);
}
if(count == 7)
{
time.sec++;
if(time.sec == 60)
time.sec = 0;
bcd = ((time.sec / 10) << 4) | (time.sec % 10);
write_DS1302(0x80, bcd);
}
}
extern struct TIME
{
uchar sec;
uchar min;
uchar h;
uchar day;
uchar week;
uchar mon;
uchar year;
uchar ap: 1; //分配一位
};
将时间日期读到结构体中的变量中。
下面是我写的一个按键调整时间日期的函数
void key2_event()
{
uchar bcd;
if(count == 0)
return;
if(count == 1)
{
time.year++;
if(time.year == 100)
time.year = 0;
bcd = ((time.year / 10) << 4) | (time.year % 10);
write_DS1302(0x8C, bcd);
}
if(count == 2)
{
time.mon++;
if(time.mon == 13)
time.mon = 1;
bcd = ((time.mon / 10) << 4) | (time.mon % 10);
write_DS1302(0x88, bcd);
}
if(count == 3)
{
uint y;
uchar i;
uchar max_day;
y = time.year;
//time.day++;
if(((y + 2000) % 4 == 0 && (y + 2000) % 100 != 0) || (y + 2000) % 400 == 0)//闰年
{
if(!((y+2000) == 2000))
dy[1] = 29;
}
else
{
dy[1] = 28;
}
for(i = 0; i < 12; i++)
{
if(time.mon == mo[i])
{
max_day = dy[mo[i] - 1];
}
}
time.day++;
if(time.day >= max_day + 1)
time.day = 1;
bcd = ((time.day / 10) << 4) | (time.day % 10);
write_DS1302(0x86, bcd);
}
if(count == 4)
{
time.week++;
if(time.week == 8)
time.week = 1;
bcd = ((time.week / 10) << 4) | (time.week % 10);
write_DS1302(0x8A, bcd);
}
if(count == 5)
{
time.h++;
bcd = read_DS1302(0x85);
if(bcd & 0x80) //12
{
if(time.h == 13)
time.h = 1;
}
else //24
{
if(time.h == 24)
time.h = 0;
}
bcd = ((time.h / 10) << 4) | (time.h % 10);
write_DS1302(0x84, bcd);
}
if(count == 6)
{
time.min++;
if(time.min == 60)
time.min = 0;
bcd = ((time.min / 10) << 4) | (time.min % 10);
write_DS1302(0x82, bcd);
}
if(count == 7)
{
time.sec++;
if(time.sec == 60)
time.sec = 0;
bcd = ((time.sec / 10) << 4) | (time.sec % 10);
write_DS1302(0x80, bcd);
}
}
#5
你这个调时程序,共用了7个按键(层次分明,易读易懂),可以实现时间递增,但不能实现时间递减,
本人想用一个键选择调整位置,一个键时间增加,一个键时间减少.
本人想用一个键选择调整位置,一个键时间增加,一个键时间减少.
#6
这个是1602滴 仅供参考
void Set_CLOCK(int address,int s)
{
switch(count-1)
{
case 0:lcd_pos(0x4b);
lcd_wcmd(0x0f);
delay(100);
break;
case 1:lcd_pos(0x48);
lcd_wcmd(0x0f);
delay(100);
break;
case 2:lcd_pos(0x45);
lcd_wcmd(0x0f);
delay(100);
break;
case 3:lcd_pos(0x0b);
lcd_wcmd(0x0f);
delay(100);
break;
case 4:lcd_pos(0x08);
lcd_wcmd(0x0f);
delay(100);
break;
case 5:lcd_pos(0x0d);
lcd_wcmd(0x0e);
delay(100);
break;
case 6:lcd_pos(0x05);
lcd_wcmd(0x0f);
delay(100);
break;
}
l_tmpdate[address]= ((l_tmpdate[address] >> 4) * 10) + (l_tmpdate[address] & 0x0f);
l_tmpdate[address]=l_tmpdate[address]+s;
if(address==0||address==1)
{
if(l_tmpdate[address]>59)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=59;
}
if(address==2)
{
if(l_tmpdate[address]>24)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=23;
}
if(address==3)
{
if(l_tmpdate[address]>30)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=29;
}
if(address==4)
{
if(l_tmpdate[address]>12)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=11;
}
l_tmpdate[address] = ((l_tmpdate[address] / 10) << 4) + (l_tmpdate[address] % 10) ;
lcd_wcmd(0x0c);
Write_Ds1302(0x8E,0X00);
Write_Ds1302(write_rtc_address[address],l_tmpdate[address]);
Write_Ds1302(0x8E,0x80);
}
void Set_CLOCK(int address,int s)
{
switch(count-1)
{
case 0:lcd_pos(0x4b);
lcd_wcmd(0x0f);
delay(100);
break;
case 1:lcd_pos(0x48);
lcd_wcmd(0x0f);
delay(100);
break;
case 2:lcd_pos(0x45);
lcd_wcmd(0x0f);
delay(100);
break;
case 3:lcd_pos(0x0b);
lcd_wcmd(0x0f);
delay(100);
break;
case 4:lcd_pos(0x08);
lcd_wcmd(0x0f);
delay(100);
break;
case 5:lcd_pos(0x0d);
lcd_wcmd(0x0e);
delay(100);
break;
case 6:lcd_pos(0x05);
lcd_wcmd(0x0f);
delay(100);
break;
}
l_tmpdate[address]= ((l_tmpdate[address] >> 4) * 10) + (l_tmpdate[address] & 0x0f);
l_tmpdate[address]=l_tmpdate[address]+s;
if(address==0||address==1)
{
if(l_tmpdate[address]>59)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=59;
}
if(address==2)
{
if(l_tmpdate[address]>24)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=23;
}
if(address==3)
{
if(l_tmpdate[address]>30)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=29;
}
if(address==4)
{
if(l_tmpdate[address]>12)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=11;
}
l_tmpdate[address] = ((l_tmpdate[address] / 10) << 4) + (l_tmpdate[address] % 10) ;
lcd_wcmd(0x0c);
Write_Ds1302(0x8E,0X00);
Write_Ds1302(write_rtc_address[address],l_tmpdate[address]);
Write_Ds1302(0x8E,0x80);
}
#7
#1
复杂的键盘扫描 显示你都做出来了
简单的启动定时器就不会拉
简单的启动定时器就不会拉
#2
这是一键多能 ,不好做!
#3
我有一个1602的。你可以参考一下
void keyscan()
{
rd=0;
if(flag1==1)
{
if(s2==0)
{
delay(5);
if(s2==0)
{
while(!s2);
flag1=0;
}
}
if(s3==0)
{
delay(5);
if(s3==0)
{
while(!s3);
flag1=0;
}
}
}
if(s1==0)
{
delay(5);
if(s1==0)
{ s1num++;
flag=1;
flag1=0;
while(!s1);
if(s1num==1)
{
TR0=0;
write_com(0x80+0x40+10);
write_com(0x0f);
}
}
if(s1num==2)
{
write_com(0x80+0x40+7);
}
if(s1num==3)
{
write_com(0x80+0x40+4);
}
if(s1num==4)
{
s1num=0;
write_com(0x0c);
flag=0;
write_ds(0,miao);
write_ds(2,fen);
write_ds(4,shi);
}
}
if(s1num!=0)
{
if(s2==0)
{
delay(1);
if(s2==0)
{
while(!s2);
if(s1num==1)
{
miao++;
if(miao==60)
miao=0;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen++;
if(fen==60)
fen=0;
write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi++;
if(shi==24)
shi=0;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}
}
}
if(s3==0)
{
delay(1);
if(s3==0)
{
while(!s3);
if(s1num==1)
{
/* if(miao==0)
{
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}*/
miao--;
if(miao==-1)
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen--;
if(fen==-1)
fen=59;
write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi--;
if(shi==-1)
shi=23;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}
}
}
}
}
void keyscan()
{
rd=0;
if(flag1==1)
{
if(s2==0)
{
delay(5);
if(s2==0)
{
while(!s2);
flag1=0;
}
}
if(s3==0)
{
delay(5);
if(s3==0)
{
while(!s3);
flag1=0;
}
}
}
if(s1==0)
{
delay(5);
if(s1==0)
{ s1num++;
flag=1;
flag1=0;
while(!s1);
if(s1num==1)
{
TR0=0;
write_com(0x80+0x40+10);
write_com(0x0f);
}
}
if(s1num==2)
{
write_com(0x80+0x40+7);
}
if(s1num==3)
{
write_com(0x80+0x40+4);
}
if(s1num==4)
{
s1num=0;
write_com(0x0c);
flag=0;
write_ds(0,miao);
write_ds(2,fen);
write_ds(4,shi);
}
}
if(s1num!=0)
{
if(s2==0)
{
delay(1);
if(s2==0)
{
while(!s2);
if(s1num==1)
{
miao++;
if(miao==60)
miao=0;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen++;
if(fen==60)
fen=0;
write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi++;
if(shi==24)
shi=0;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}
}
}
if(s3==0)
{
delay(1);
if(s3==0)
{
while(!s3);
if(s1num==1)
{
/* if(miao==0)
{
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}*/
miao--;
if(miao==-1)
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
}
if(s1num==2)
{
fen--;
if(fen==-1)
fen=59;
write_sfm(7,fen);
write_com(0x80+0x40+7);
}
if(s1num==3)
{
shi--;
if(shi==-1)
shi=23;
write_sfm(4,shi);
write_com(0x80+0x40+4);
}
}
}
}
}
#4
可以先定义个结构体
extern struct TIME
{
uchar sec;
uchar min;
uchar h;
uchar day;
uchar week;
uchar mon;
uchar year;
uchar ap: 1; //分配一位
};
将时间日期读到结构体中的变量中。
下面是我写的一个按键调整时间日期的函数
void key2_event()
{
uchar bcd;
if(count == 0)
return;
if(count == 1)
{
time.year++;
if(time.year == 100)
time.year = 0;
bcd = ((time.year / 10) << 4) | (time.year % 10);
write_DS1302(0x8C, bcd);
}
if(count == 2)
{
time.mon++;
if(time.mon == 13)
time.mon = 1;
bcd = ((time.mon / 10) << 4) | (time.mon % 10);
write_DS1302(0x88, bcd);
}
if(count == 3)
{
uint y;
uchar i;
uchar max_day;
y = time.year;
//time.day++;
if(((y + 2000) % 4 == 0 && (y + 2000) % 100 != 0) || (y + 2000) % 400 == 0)//闰年
{
if(!((y+2000) == 2000))
dy[1] = 29;
}
else
{
dy[1] = 28;
}
for(i = 0; i < 12; i++)
{
if(time.mon == mo[i])
{
max_day = dy[mo[i] - 1];
}
}
time.day++;
if(time.day >= max_day + 1)
time.day = 1;
bcd = ((time.day / 10) << 4) | (time.day % 10);
write_DS1302(0x86, bcd);
}
if(count == 4)
{
time.week++;
if(time.week == 8)
time.week = 1;
bcd = ((time.week / 10) << 4) | (time.week % 10);
write_DS1302(0x8A, bcd);
}
if(count == 5)
{
time.h++;
bcd = read_DS1302(0x85);
if(bcd & 0x80) //12
{
if(time.h == 13)
time.h = 1;
}
else //24
{
if(time.h == 24)
time.h = 0;
}
bcd = ((time.h / 10) << 4) | (time.h % 10);
write_DS1302(0x84, bcd);
}
if(count == 6)
{
time.min++;
if(time.min == 60)
time.min = 0;
bcd = ((time.min / 10) << 4) | (time.min % 10);
write_DS1302(0x82, bcd);
}
if(count == 7)
{
time.sec++;
if(time.sec == 60)
time.sec = 0;
bcd = ((time.sec / 10) << 4) | (time.sec % 10);
write_DS1302(0x80, bcd);
}
}
extern struct TIME
{
uchar sec;
uchar min;
uchar h;
uchar day;
uchar week;
uchar mon;
uchar year;
uchar ap: 1; //分配一位
};
将时间日期读到结构体中的变量中。
下面是我写的一个按键调整时间日期的函数
void key2_event()
{
uchar bcd;
if(count == 0)
return;
if(count == 1)
{
time.year++;
if(time.year == 100)
time.year = 0;
bcd = ((time.year / 10) << 4) | (time.year % 10);
write_DS1302(0x8C, bcd);
}
if(count == 2)
{
time.mon++;
if(time.mon == 13)
time.mon = 1;
bcd = ((time.mon / 10) << 4) | (time.mon % 10);
write_DS1302(0x88, bcd);
}
if(count == 3)
{
uint y;
uchar i;
uchar max_day;
y = time.year;
//time.day++;
if(((y + 2000) % 4 == 0 && (y + 2000) % 100 != 0) || (y + 2000) % 400 == 0)//闰年
{
if(!((y+2000) == 2000))
dy[1] = 29;
}
else
{
dy[1] = 28;
}
for(i = 0; i < 12; i++)
{
if(time.mon == mo[i])
{
max_day = dy[mo[i] - 1];
}
}
time.day++;
if(time.day >= max_day + 1)
time.day = 1;
bcd = ((time.day / 10) << 4) | (time.day % 10);
write_DS1302(0x86, bcd);
}
if(count == 4)
{
time.week++;
if(time.week == 8)
time.week = 1;
bcd = ((time.week / 10) << 4) | (time.week % 10);
write_DS1302(0x8A, bcd);
}
if(count == 5)
{
time.h++;
bcd = read_DS1302(0x85);
if(bcd & 0x80) //12
{
if(time.h == 13)
time.h = 1;
}
else //24
{
if(time.h == 24)
time.h = 0;
}
bcd = ((time.h / 10) << 4) | (time.h % 10);
write_DS1302(0x84, bcd);
}
if(count == 6)
{
time.min++;
if(time.min == 60)
time.min = 0;
bcd = ((time.min / 10) << 4) | (time.min % 10);
write_DS1302(0x82, bcd);
}
if(count == 7)
{
time.sec++;
if(time.sec == 60)
time.sec = 0;
bcd = ((time.sec / 10) << 4) | (time.sec % 10);
write_DS1302(0x80, bcd);
}
}
#5
你这个调时程序,共用了7个按键(层次分明,易读易懂),可以实现时间递增,但不能实现时间递减,
本人想用一个键选择调整位置,一个键时间增加,一个键时间减少.
本人想用一个键选择调整位置,一个键时间增加,一个键时间减少.
#6
这个是1602滴 仅供参考
void Set_CLOCK(int address,int s)
{
switch(count-1)
{
case 0:lcd_pos(0x4b);
lcd_wcmd(0x0f);
delay(100);
break;
case 1:lcd_pos(0x48);
lcd_wcmd(0x0f);
delay(100);
break;
case 2:lcd_pos(0x45);
lcd_wcmd(0x0f);
delay(100);
break;
case 3:lcd_pos(0x0b);
lcd_wcmd(0x0f);
delay(100);
break;
case 4:lcd_pos(0x08);
lcd_wcmd(0x0f);
delay(100);
break;
case 5:lcd_pos(0x0d);
lcd_wcmd(0x0e);
delay(100);
break;
case 6:lcd_pos(0x05);
lcd_wcmd(0x0f);
delay(100);
break;
}
l_tmpdate[address]= ((l_tmpdate[address] >> 4) * 10) + (l_tmpdate[address] & 0x0f);
l_tmpdate[address]=l_tmpdate[address]+s;
if(address==0||address==1)
{
if(l_tmpdate[address]>59)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=59;
}
if(address==2)
{
if(l_tmpdate[address]>24)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=23;
}
if(address==3)
{
if(l_tmpdate[address]>30)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=29;
}
if(address==4)
{
if(l_tmpdate[address]>12)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=11;
}
l_tmpdate[address] = ((l_tmpdate[address] / 10) << 4) + (l_tmpdate[address] % 10) ;
lcd_wcmd(0x0c);
Write_Ds1302(0x8E,0X00);
Write_Ds1302(write_rtc_address[address],l_tmpdate[address]);
Write_Ds1302(0x8E,0x80);
}
void Set_CLOCK(int address,int s)
{
switch(count-1)
{
case 0:lcd_pos(0x4b);
lcd_wcmd(0x0f);
delay(100);
break;
case 1:lcd_pos(0x48);
lcd_wcmd(0x0f);
delay(100);
break;
case 2:lcd_pos(0x45);
lcd_wcmd(0x0f);
delay(100);
break;
case 3:lcd_pos(0x0b);
lcd_wcmd(0x0f);
delay(100);
break;
case 4:lcd_pos(0x08);
lcd_wcmd(0x0f);
delay(100);
break;
case 5:lcd_pos(0x0d);
lcd_wcmd(0x0e);
delay(100);
break;
case 6:lcd_pos(0x05);
lcd_wcmd(0x0f);
delay(100);
break;
}
l_tmpdate[address]= ((l_tmpdate[address] >> 4) * 10) + (l_tmpdate[address] & 0x0f);
l_tmpdate[address]=l_tmpdate[address]+s;
if(address==0||address==1)
{
if(l_tmpdate[address]>59)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=59;
}
if(address==2)
{
if(l_tmpdate[address]>24)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=23;
}
if(address==3)
{
if(l_tmpdate[address]>30)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=29;
}
if(address==4)
{
if(l_tmpdate[address]>12)
l_tmpdate[address]=0;
if(l_tmpdate[address]<0)
l_tmpdate[address]=11;
}
l_tmpdate[address] = ((l_tmpdate[address] / 10) << 4) + (l_tmpdate[address] % 10) ;
lcd_wcmd(0x0c);
Write_Ds1302(0x8E,0X00);
Write_Ds1302(write_rtc_address[address],l_tmpdate[address]);
Write_Ds1302(0x8E,0x80);
}