我这个程序为什么按下按键2不能显示日期啊
时间:10-02
整理:3721RD
点击:
这是主函数部分,其他的部分没错,可以帮我分析下不
void main()
{
systemtime currenttime;
uchar t0,t1,t2,t3,t4,t5;
uchar m0,m1,m2,m3,m4,m5;
init(); //初始化DS1302
settime(ds1302_shi,0); //写入时间和日期初始值
settime(ds1302_fen,0);
settime(ds1302_miao,0);
settime(ds1302_nian,13);
settime(ds1302_yue,5);
settime(ds1302_ri,29);
while(1)
{
datetostr(¤ttime );//读日期
gettime(¤ttime);//获取时间
timetostr(¤ttime);//读时间
jianpanshaomiao(); //读按键值
m0=currenttime.datestring[0];
m1=currenttime.datestring[1];
m2=currenttime.datestring[2];
m3=currenttime.datestring[3];
m4=currenttime.datestring[4];
m5=currenttime.datestring[5];
t0=currenttime.timestring[0];
t1=currenttime.timestring[1];
t2=currenttime.timestring[2];
t3=currenttime.timestring[3];
t4=currenttime.timestring[4];
t5=currenttime.timestring[5];
if(ok==2) //按下按键2 显示日期
{
disp(table[m0],table[m1],table[m2],table[m3],table[m4],table[m5]);
}
if(ok!=2) //正常情况下显示时间
{
disp(table[t0],table[t1],table[t2],table[t3],table[t4],table[t5]);
}
}
}
void main()
{
systemtime currenttime;
uchar t0,t1,t2,t3,t4,t5;
uchar m0,m1,m2,m3,m4,m5;
init(); //初始化DS1302
settime(ds1302_shi,0); //写入时间和日期初始值
settime(ds1302_fen,0);
settime(ds1302_miao,0);
settime(ds1302_nian,13);
settime(ds1302_yue,5);
settime(ds1302_ri,29);
while(1)
{
datetostr(¤ttime );//读日期
gettime(¤ttime);//获取时间
timetostr(¤ttime);//读时间
jianpanshaomiao(); //读按键值
m0=currenttime.datestring[0];
m1=currenttime.datestring[1];
m2=currenttime.datestring[2];
m3=currenttime.datestring[3];
m4=currenttime.datestring[4];
m5=currenttime.datestring[5];
t0=currenttime.timestring[0];
t1=currenttime.timestring[1];
t2=currenttime.timestring[2];
t3=currenttime.timestring[3];
t4=currenttime.timestring[4];
t5=currenttime.timestring[5];
if(ok==2) //按下按键2 显示日期
{
disp(table[m0],table[m1],table[m2],table[m3],table[m4],table[m5]);
}
if(ok!=2) //正常情况下显示时间
{
disp(table[t0],table[t1],table[t2],table[t3],table[t4],table[t5]);
}
}
}