微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 我这个程序为什么按下按键2不能显示日期啊

我这个程序为什么按下按键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(&currenttime );//读日期
                   gettime(&currenttime);//获取时间
                        timetostr(&currenttime);//读时间
                        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]);
                          }
          }
  }

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top