led.lst

来自「用于控制LED广告灯箱的源代码」· LST 代码 · 共 788 行 · 第 1/3 页

LST
788
字号
 247   3                              DisplaySegment(2);
 248   3                              MOTOR = STOP;
 249   3                      }
 250   2                      
 251   2                      if (SET == 0)
 252   2                      {
 253   3                              break;
 254   3                      }
 255   2                      
 256   2                      flag1++;
 257   2              }
 258   1              while (!SET)
 259   1              {
 260   2                      DisplaySegment(2);
 261   2              }
 262   1      }
 263          
 264          
 265          /*****************************
 266          
 267          设置自动模式的页数和时间
 268          
 269          *****************************/
 270          void Automatism(void)
 271          {
 272   1              unsigned char controlPage;
 273   1      //      unsigned char controlSecHigh, controlSecLow;
 274   1              unsigned char controlSec;
 275   1              unsigned char count1;
 276   1      
 277   1              
 278   1      //      controlSecHigh = ReadByte(0x2001);
 279   1      //      controlSecLow = ReadByte(0x2002);
 280   1      /*      controlPage = 5;
 281   1              controlSecHigh = 0x00;
 282   1              controlSecLow = 0x08;
 283   1      //      controlSec = ((unsigned int)controlSecHigh << 8) | controlSecLow;
 284   1      */   
 285   1              controlPage = ReadByte(0x2000);
 286   1              controlSec = ReadByte(0x2001);
 287   1      
 288   1              while (1)
 289   1              {
 290   2                      if ((ADD==0) && (DEC==1))
 291   2                      {
 292   3                              for (count1=0; count1<50; count1++)
 293   3                              {
 294   4                                      DisplayStop(17, controlPage/10, controlPage%10);
 295   4                              }
 296   3                              if ((ADD==0) && (DEC==1))
 297   3                              {
 298   4                                      if (controlPage != 2)
 299   4                                      {
 300   5                                              controlPage--;
 301   5                                      }               
 302   4                              }
 303   3                      }
C51 COMPILER V7.06   LED                                                                   02/11/2007 20:19:36 PAGE 6   

 304   2                      if ((ADD==1) && (DEC==0))
 305   2                      {
 306   3                              for (count1=0; count1<50; count1++)
 307   3                              {
 308   4                                      DisplayStop(17, controlPage/10, controlPage%10);
 309   4                              }
 310   3                              if ((ADD==1) && (DEC==0))
 311   3                              {
 312   4                                      if (controlPage != 25)
 313   4                                      {
 314   5                                              controlPage++;
 315   5                                      }                                       
 316   4                              }
 317   3                      }
 318   2                      if (SET == 0)
 319   2                      {
 320   3                              break;
 321   3                      }
 322   2                      
 323   2                      DisplayStop(17, controlPage/10, controlPage%10);
 324   2              }
 325   1              //停顿显示 当按键松开时执行下步
 326   1              while (!SET)
 327   1              {
 328   2                      DisplayStop(17, controlPage/10, controlPage%10);        
 329   2              };
 330   1              while (1)
 331   1              {
 332   2                      if ((ADD==0) && (DEC==1))
 333   2                      {
 334   3                              for (count1=0; count1<50; count1++)
 335   3                              {
 336   4                                      DisplayStop(controlSec/100%10, controlSec/10%10, controlSec%10);
 337   4                              }
 338   3                              if ((ADD==0) && (DEC==1))
 339   3                              {
 340   4                                      if (controlSec != 0)
 341   4                                      {
 342   5                                              controlSec--;
 343   5                                      }                                       
 344   4                              }
 345   3                      }
 346   2                      if ((ADD==1) && (DEC==0))
 347   2                      {
 348   3                              for (count1=0; count1<50; count1++)
 349   3                              {
 350   4                                      DisplayStop(controlSec/100%10, controlSec/10%10, controlSec%10);
 351   4                              }
 352   3                              if ((ADD==1) && (DEC==0))
 353   3                              {
 354   4                                      if (controlSec != 99)
 355   4                                      {
 356   5                                              controlSec++;
 357   5                                      }                               
 358   4                              }
 359   3                      }
 360   2                      if (SET == 0)
 361   2                      {       
 362   3                              break;
 363   3                      }
 364   2      
 365   2                      DisplayStop(controlSec/100%10, controlSec/10%10, controlSec%10);
C51 COMPILER V7.06   LED                                                                   02/11/2007 20:19:36 PAGE 7   

 366   2              }
 367   1      
 368   1              while (!SET)
 369   1              {
 370   2                      DisplayStop(controlSec/100%10, controlSec/10%10, controlSec%10);        
 371   2              };
 372   1              
 373   1              DeleteSector(0x2000);
 374   1              WriteByte(0x2000, controlPage);
 375   1      //                      WriteByte(0x2001, (unsigned char)(controlSec >> 8));
 376   1      //                      WriteByte(0x2002, (unsigned char) controlSec);
 377   1              WriteByte(0x2001, controlSec);
 378   1              for (count1=0; count1<250; count1++)
 379   1              {
 380   2                      DisplayStop(18, 18, 18); 
 381   2              }
 382   1      }
 383          
 384          
 385          
 386          //中断函数
 387          /*
 388          void TIME0display(void) interrupt 1 using 2
 389          {
 390          
 391          }
 392          */
 393          
 394          
 395          //功能:串口中断发送接受服务子程序
 396          //函数:SendReceiveInt()
 397          //调用变量:无   
 398          //返回值:无
 399          //修改日期:2007-1-14
 400          //作者:狼魅
 401          void SendReceiveInt() interrupt 4 using 1
 402          {
 403   1              if (ControlSendReceive == 0)
 404   1              {
 405   2                      if (RI != 0)
 406   2                      {
 407   3                              RI = 0;
 408   3                              ReceiveData = SBUF;
 409   3                              if (TI != 0)
 410   3                              {
 411   4                                      TI = 0;
 412   4                                      SBUF = SendData;
 413   4                              }
 414   3                      }
 415   2              }
 416   1              else
 417   1              {
 418   2                      if (TI != 0)
 419   2                      {
 420   3                              TI = 0;
 421   3                              SBUF = SendData;
 422   3                      }
 423   2              }
 424   1      }
 425          
 426          
 427          /*******************************************
C51 COMPILER V7.06   LED                                                                   02/11/2007 20:19:36 PAGE 8   

 428          *            主函数
 429          *       广告灯箱
 430          *狼魅   
 431          *开始时间:2006-11-27
 432          *修改时间:2006-12-4
 433          /******************************************/
 434          
 435          void main(void)
 436          {
 437   1      /**********************
 438   1      串口中断模式设置        
 439   1      波特率:4800
 440   1      **********************/
 441   1              TMOD = 0x20;
 442   1              TH1 = 0xfa;
 443   1              TL1 = 0xfa;
 444   1              SCON = 0xd8;
 445   1              PCON = 0x00;
 446   1              IE = 0x90;
 447   1              TR1 = 1;
 448   1      
 449   1      /******************************
 450   1      功能:设置手动,自动设置。
 451   1      日期:2006-12-4
 452   1      作者:狼魅
 453   1      *******************************/
 454   1              
 455   1              if (!(ADD | DEC))
 456   1              {
 457   2                      while (1)
 458   2                      {
 459   3                              while (1)
 460   3                              {                               
 461   4                                      if ((ADD==0) && (DEC==1))
 462   4                                      {
 463   5                                              control = 1;
 464   5                                      }
 465   4              
 466   4                                      if ((ADD==1) && (DEC==0))
 467   4                                      {
 468   5                                              control = 2;
 469   5                                      }
 470   4      
 471   4                                      if (SET == 0)
 472   4                                      {
 473   5                                              break;
 474   5                                      }
 475   4                                      DisplayStop(15, 16, control);           
 476   4                              }                                
 477   3                              //停顿显示 当按键松开时执行下步
 478   3                              while (!SET)
 479   3                              {
 480   4                                      DisplayStop(15, 16, control);
 481   4                              };
 482   3                                       
 483   3                              if (control == 1)
 484   3                              {
 485   4                                      Automatism();                   //设置自动模式
 486   4                              }
 487   3                              else
 488   3                              {
 489   4                                      ManPower();                             //设置手动模式
C51 COMPILER V7.06   LED                                                                   02/11/2007 20:19:36 PAGE 9   

 490   4                              }
 491   3      
 492   3                              DisplayStop(15, 16, control);
 493   3                      }
 494   2              }
 495   1      
 496   1      
 497   1      
 498   1              setPage = ReadByte(0x2000)-1;
 499   1              setSec = ReadByte(0x2001);
 500   1      
 501   1      /******************************

⌨️ 快捷键说明

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