⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1302

📁 ds1302与数码管时间可调
💻
📖 第 1 页 / 共 2 页
字号:
 216   1              {
 217   2                      d = !d;
 218   2                      key4_state = 0;
 219   2                        
 220   2              }
 221   1      }
 222          /**********显示函数**************/
 223          void display()
 224          {
 225   1              uchar i;
 226   1              for(i=0;i<8;i++)
 227   1              {
 228   2              P0 = 0x00;
 229   2              P2 = weima[7];
 230   2              P0 = a|~duanma[counter[0]%10];
 231   2              delayms(1);
 232   2              P0 = 0x00;
 233   2              P2 = weima[6];
 234   2          P0 = a|~duanma[counter[0]/10];
 235   2          delayms(1);
 236   2      
 237   2      
 238   2              P0 = 0x00;
 239   2              P2 = weima[5];
 240   2              P0=~duanma[10];
 241   2              delayms(1);
C51 COMPILER V9.00   ZHAO                                                                  08/13/2013 14:33:02 PAGE 5   

 242   2      
 243   2      
 244   2              P0 = 0x00;
 245   2              P2 = weima[4];
 246   2          P0 = b|~duanma[counter[1]%10];  
 247   2              delayms(1);
 248   2               P0 = 0x00;
 249   2              P2 = weima[3];
 250   2              P0 = b|~duanma[counter[1]/10];
 251   2              delayms(1);
 252   2              //i = 0x80*dot;
 253   2              //i = 0x7f|i;
 254   2      
 255   2              
 256   2              P0 = 0x00;
 257   2              P2 = weima[2];
 258   2          P0=~duanma[10];
 259   2          delayms(1);
 260   2      
 261   2      
 262   2              P0 = 0x00;
 263   2          P2 = weima[1];
 264   2              P0 = c&~duanma[counter[2]%10];
 265   2              delayms(1); 
 266   2              P0 = 0x00;
 267   2              P2 = weima[0];
 268   2              P0 = c&~duanma[counter[2]/10];
 269   2          delayms(1); 
 270   2              }
 271   1      
 272   1      }
 273          void display1()
 274          {
 275   1              uchar i;
 276   1              for(i=0;i<8;i++)
 277   1              {
 278   2              P0 = 0x00;
 279   2              P2 = weima[7];
 280   2              P0 = a|~duanma[counter[0]%10];
 281   2              delayms(1);
 282   2              P0 = 0x00;
 283   2              P2 = weima[6];
 284   2          P0 = a|~duanma[counter[0]/10];
 285   2          delayms(1);
 286   2      
 287   2      
 288   2              P0 = 0x00;
 289   2              P2 = weima[5];
 290   2              P0=~duanma[10];
 291   2              delayms(1);
 292   2      
 293   2      
 294   2              P0 = 0x00;
 295   2              P2 = weima[4];
 296   2          P0 = b&~duanma[counter[1]%10];  
 297   2              delayms(1);
 298   2               P0 = 0x00;
 299   2              P2 = weima[3];
 300   2              P0 = b&~duanma[counter[1]/10];
 301   2              delayms(1);
 302   2              //i = 0x80*dot;
 303   2              //i = 0x7f|i;
C51 COMPILER V9.00   ZHAO                                                                  08/13/2013 14:33:02 PAGE 6   

 304   2      
 305   2              
 306   2              P0 = 0x00;
 307   2              P2 = weima[2];
 308   2          P0=~duanma[10];
 309   2          delayms(1);
 310   2      
 311   2      
 312   2              P0 = 0x00;
 313   2          P2 = weima[1];
 314   2              P0 = c|~duanma[counter[2]%10];
 315   2              delayms(1); 
 316   2              P0 = 0x00;
 317   2              P2 = weima[0];
 318   2              P0 = c|~duanma[counter[2]/10];
 319   2          delayms(1); 
 320   2              }
 321   1      
 322   1      }
 323          
 324          void display2()
 325          {
 326   1              uchar i;
 327   1              for(i=0;i<8;i++)
 328   1              {
 329   2              P0 = 0x00;
 330   2              P2 = weima[7];
 331   2              P0 = a&~duanma[counter[0]%10];
 332   2              delayms(1);
 333   2              P0 = 0x00;
 334   2              P2 = weima[6];
 335   2          P0 = a&~duanma[counter[0]/10];
 336   2          delayms(1);
 337   2      
 338   2      
 339   2              P0 = 0x00;
 340   2              P2 = weima[5];
 341   2              P0=~duanma[10];
 342   2              delayms(1);
 343   2      
 344   2      
 345   2              P0 = 0x00;
 346   2              P2 = weima[4];
 347   2          P0 = b|~duanma[counter[1]%10];  
 348   2              delayms(1);
 349   2               P0 = 0x00;
 350   2              P2 = weima[3];
 351   2              P0 = b|~duanma[counter[1]/10];
 352   2              delayms(1);
 353   2              //i = 0x80*dot;
 354   2              //i = 0x7f|i;
 355   2      
 356   2              
 357   2              P0 = 0x00;
 358   2              P2 = weima[2];
 359   2          P0=~duanma[10];
 360   2          delayms(1);
 361   2      
 362   2      
 363   2              P0 = 0x00;
 364   2          P2 = weima[1];
 365   2              P0 = c|~duanma[counter[2]%10];
C51 COMPILER V9.00   ZHAO                                                                  08/13/2013 14:33:02 PAGE 7   

 366   2              delayms(1); 
 367   2              P0 = 0x00;
 368   2              P2 = weima[0];
 369   2              P0 = c|~duanma[counter[2]/10];
 370   2          delayms(1); 
 371   2              }
 372   1      
 373   1      }
 374          /**************主函数****************/
 375          void main()
 376          {
 377   1          uchar i;
 378   1              Init_mcu(); 
 379   1      while(1)    //无限循环
 380   1              {
 381   2              key_setup();
 382   2              if(key1_flag == 1)
 383   2                      {
 384   3                              display();
 385   3                      }
 386   2              if(key1_flag==2)
 387   2              {
 388   3                display1();
 389   3              }
 390   2              if(key1_flag == 3 )
 391   2              {
 392   3               display2();
 393   3              }
 394   2              if(key1_flag ==4)
 395   2                      {
 396   3                              TR0=1;
 397   3                              key1_flag=0;
 398   3                              sec=(counter[0]/10)*16+counter[0]%10; // BCD 码转换成 HEX
 399   3                              min=(counter[1]/10)*16+counter[1]%10; // BCD 码转换成 HEX
 400   3                              hou=(counter[2]/10)*16+counter[2]%10; // BCD 码转换成 HEX
 401   3                              set_time();
 402   3                              TR0=1;
 403   3                      }
 404   2      
 405   2          if(key1_flag == 0)
 406   2         {            
 407   3             get_time();
 408   3                      flash = 0x7f*dot;
 409   3                      flash = flash|0x80;
 410   3                      P0 = 0x00;
 411   3                      P2 = weima[i];
 412   3                      if(i == 2 || i == 5)
 413   3                      P0 = ~duanma[time1[i]]&flash;
 414   3                      else
 415   3                      P0 = ~duanma[time1[i]];
 416   3                }
 417   2              i++;
 418   2              if(i == 8)i = 0; 
 419   2              xiaoying();
 420   2              }
 421   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1783    ----
   CONSTANT SIZE    =     38    ----
   XDATA SIZE       =   ----    ----
C51 COMPILER V9.00   ZHAO                                                                  08/13/2013 14:33:02 PAGE 8   

   PDATA SIZE       =   ----    ----
   DATA SIZE        =     30       1
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -