DS1302怎么设置多组闹
谁做过用DS1302做闹钟,可以设置多个闹铃。
我这样做行不行,请指导一下:
if(s5==0&&s1num==0)
{
s5num++;
flag2=1;
while(!s5);baojing();
if(s5num==1)
{ write_com(0x80+13);
write_com(0x0f);//光标
}
if(s5num==2)
{
write_1302(0x8e,0x00);//禁止写保护,第一组闹铃分钟
write_1302(0xc2,lfen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0x80+10);
}
if(s5num==3)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xc0,lshi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+2);
}
if(s5num==4)
{
write_1302(0x8e,0x00);//禁止写保护,第二组闹铃
write_1302(0xc4,eshi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+5);
}
if(s5num==5)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xc6,efen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+7);
}
if(s5num==6)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xc8,sshi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+10);
}
if(s5num==7)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xca,sfen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+12);
}
if(s5num==8)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xcc,sishi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+15);
}
if(s5num==9)
{
s5num=0;
flag2=0;
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xce,sifen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0x0c);//不显示光标
}
}
}
/***********************以下是加减*************************/
if(s5num!=0&&s1num==0)
{
if(s2==0)
{
delay(5);
if(s2==0)
{
while(!s2);baojing();
if(s5num==1)
{
uchar *fff1=&lfen;
fenjia(fff1,12,0x80+13);
}
if(s5num==2)
{
uchar *sss1=&lshi;
shijia(sss1,9,0x80+10);
}
if(s5num==4)
{
uchar *sss2=&eshi;
shijia(sss2,1,0xc0+2);
}
if(s5num==4)
{
uchar *fff2=&efen;
fenjia(fff2,4,0xc0+5);
}
if(s5num==5)
{
uchar *sss1=&sshi;
shijia(sss1,9,0xc0+10);
}
if(s5num==6)
{
uchar *fff1=&sfen;
fenjia(fff1,12,0xc0+13);
}
if(s5num==7)
{
uchar *sss1=&sishi;
shijia(sss1,9,0xc0+10);
}
if(s5num==8)
{
uchar *fff1=&sifen;
fenjia(fff1,12,0xc0+13);
}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
不是吧,
一周热门 更多>