日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          DS1302控制代碼

          作者: 時(shí)間:2016-12-01 來(lái)源:網(wǎng)絡(luò) 收藏
          /*******************************************
          修改小時(shí)
          *******************************************/
          if(cnt==5)
          {
          temp=read_1302(0x85);
          shi=((temp&0x70)>>4)*10+(temp&0x0F);
          if(K2==0)
          {
          delay(5);
          if(K2==0)//K2鍵實(shí)現(xiàn)加
          {
          while(!K2);
          delay(5);
          while(!K2);//確保K2鍵松開
          shi++;
          if(shi>=24)
          {
          shi=0;
          }
          write_1302(0x8e,0x00);
          write_1302(0x84,(shi/10)<<4|(shi%10));
          DisplayHours(shi);
          write_1302(0x8e,0x80);
          }
          }
          if(K3==0)
          {
          delay(5);
          if(K3==0)//K3鍵實(shí)現(xiàn)減
          {
          while(!K3);
          delay(5);
          while(!K3);//確保K3鍵松開
          shi--;
          if(shi==-1)
          {
          shi=23;
          }
          write_1302(0x8e,0x00);
          write_1302(0x84,(shi/10)<<4|(shi%10));
          DisplayHours(shi);
          write_1302(0x8e,0x80);
          }
          }
          }
          /*******************************************
          修改分鐘
          *******************************************/
          if(cnt==6)
          {
          temp=read_1302(0x83);
          fen=((temp&0x70)>>4)*10+(temp&0x0F);
          if(K2==0)
          {
          delay(5);
          if(K2==0)//K2鍵實(shí)現(xiàn)加
          {
          while(!K2);
          delay(5);
          while(!K2);//確保K2鍵松開
          fen++;
          if(fen>=60)
          {
          fen=0;
          }
          write_1302(0x8e,0x00);
          write_1302(0x82,(fen/10)<<4|(fen%10));
          DisplayMinutes(fen);
          write_1302(0x8e,0x80);
          }
          }
          if(K3==0)
          {
          delay(5);
          if(K3==0)//K3鍵實(shí)現(xiàn)減
          {
          while(!K3);
          delay(5);
          while(!K3);//確保K3鍵松開
          fen--;
          if(fen==-1)
          {
          fen=59;
          }
          write_1302(0x8e,0x00);
          write_1302(0x82,(fen/10)<<4|(fen%10));
          DisplayMinutes(fen);
          write_1302(0x8e,0x80);
          }
          }
          }
          /*******************************************
          修改秒鐘
          *******************************************/
          if(cnt==7)
          {
          temp=read_1302(0x81);
          miao=((temp&0x70)>>4)*10+(temp&0x0F);
          if(K2==0)
          {
          delay(5);
          if(K2==0)//K2鍵實(shí)現(xiàn)加
          {
          while(!K2);
          delay(5);
          while(!K2);//確保K2鍵松開
          miao++;
          if(miao>=60)
          {
          miao=0;
          }
          write_1302(0x8e,0x00);
          write_1302(0x80,(miao/10)<<4|(miao%10));
          DisplaySeconds(miao);
          write_1302(0x8e,0x80);
          }
          }
          if(K3==0)
          {
          delay(5);
          if(K3==0)//K3鍵實(shí)現(xiàn)減
          {
          while(!K3);
          delay(5);
          while(!K3);//確保K3鍵松開
          miao--;
          if(miao==-1)
          {
          miao=59;
          }
          write_1302(0x8e,0x00);
          write_1302(0x80,(miao/10)<<4|(miao%10));
          DisplaySeconds(miao);
          write_1302(0x8e,0x80);
          }
          }
          }
          if(cnt==8)
          {
          cnt=0;
          }
          }
          /*************************************
          主函數(shù)
          *************************************/
          void main()
          {
          lcdInit();
          flag1302=read_1302(0x81);
          if(flag1302&0x80)//秒鐘的最高位為1才需要初始化
          {
          Init_1302();
          }
          while(1)
          {
          change();
          read_date();
          }
          }
          上一頁(yè) 1 2 3 下一頁(yè)

          關(guān)鍵詞: DS1302控制代

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉