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

📄 mylib.lst

📁 红外抄表系统的源代码。利用非电信号传送控制信息和数据信息
💻 LST
📖 第 1 页 / 共 5 页
字号:
 598   1              LCD_WD2(2,*(IC2_TB+j));          //not display S14
 599   1          KickDog();
 600   1      }
 601          
 602          /*****************************************/
 603          /*                                       */
 604          /* The function change hex to dec        */
 605          /* designed by xl.zhang                  */
 606          /* Date 2007-4-4                         */
 607          /*                                       */
 608          /*****************************************/
 609          uchar hex_to_dec(uchar hex_dat)
 610          {
 611   1           uchar k1,k2;
 612   1           k1=hex_dat/16;
 613   1           k2=hex_dat%16;
C51 COMPILER V6.00i MYLIB                                                                  08/21/2007 12:22:11 PAGE 11  

 614   1           k1=k2+k1*10;
 615   1           return(k1);
 616   1      }
 617          /**************************************************/
 618          /*                                                */
 619          /* The function send display number to IC1 region,*/
 620          /* where Sx is the trouble type to display        */
 621          /* f_time is the trouble start time or stop time  */
 622          /* hour and minute <=255(FFH)                     */
 623          /* designed by xl.zhang                           */
 624          /* Date 2007-4-4                                 */
 625          /**************************************************/
 626          void DispIC1_start_stop(uchar Sx,uchar time[6])  //
 627          {
 628   1          uchar B_D;
 629   1          int j;
 630   1          B_D = 0x0;
 631   1          j = 0;
 632   1          if(Sx == 0)     //trouble in S1
 633   1              LCD_WD1(B_D,*(IC1_TB+j)|0x10);
 634   1          else
 635   1              LCD_WD1(B_D,*(IC1_TB+j));
 636   1          B_D += 2;
 637   1          j = 0;
 638   1          if(Sx == 1)      //trouble in S2
 639   1              LCD_WD1(B_D,*(IC1_TB+j)|0x10);
 640   1          else
 641   1              LCD_WD1(B_D,*(IC1_TB+j));
 642   1          B_D += 2;
 643   1          j = time[4]/10;
 644   1          if(Sx == 2)      //trouble in S3
 645   1              LCD_WD1(B_D,*(IC1_TB+j)|0x10);
 646   1          else
 647   1              LCD_WD1(B_D,*(IC1_TB+j));
 648   1          B_D += 2;
 649   1          j =  time[4]%10;
 650   1          if(Sx == 3)      //trouble in S4
 651   1              LCD_WD1(B_D,*(IC1_TB+j)|0x10);
 652   1          else
 653   1              LCD_WD1(B_D,*(IC1_TB+j));
 654   1          B_D += 2;
 655   1          j = time[5]/10;
 656   1          if(Sx == 4)      //trouble in S5
 657   1              LCD_WD1(B_D,*(IC1_TB+j)|0x10);
 658   1          else
 659   1              LCD_WD1(B_D,*(IC1_TB+j));
 660   1          B_D += 2;
 661   1          j = time[5]%10;
 662   1          if(Sx == 5)      //trouble in S6
 663   1              LCD_WD1(B_D,*(IC1_TB+j)|0x10);
 664   1          else
 665   1              LCD_WD1(B_D,*(IC1_TB+j));
 666   1          KickDog();
 667   1      }
 668          
 669          void Set1302(uchar time[7])
 670          {
 671   1        uchar i;
 672   1        uchar ucAddr = 0x80;
 673   1        W1302(0x8e,0x00);
 674   1        for(i =0;i<7;i++)
 675   1        {
C51 COMPILER V6.00i MYLIB                                                                  08/21/2007 12:22:11 PAGE 12  

 676   2          W1302(ucAddr,time[6-i]);
 677   2          ucAddr +=2;
 678   2        }
 679   1        W1302(0x8e,0x80);
 680   1        KickDog();
 681   1      }
 682          /*****************************************/
 683          /*                                       */
 684          /* The function change dec to  hex       */
 685          /* designed by xl.zhang                  */
 686          /* Date 2007-4-11                        */
 687          /*                                       */
 688          /*****************************************/
 689          uchar dec_to_hex(uchar dec_dat)
 690          {
 691   1           uchar k1,k2;
 692   1           k1=dec_dat/10;
 693   1           k2=dec_dat%10;
 694   1           k1=k2+k1*16;
 695   1           return(k1);
 696   1      }
 697          /*****************************************/
 698          /*                                       */
 699          /* The function use to init TIMER0       */
 700          /* designed by xl.zhang                  */
 701          /* Date 2007-4-11                        */
 702          /*                                       */
 703          /*****************************************/
 704          /*void InitTimer0()
 705          {
 706              TMOD |= 0x01;       //TMOD: timer 0, mode 1, 16 - bit
 707              PCON |= 0x00;       //SMOD=0;
 708              TH0   = 0x4C;       // Interrupt interval is 50ms for fosc=11.0592
 709              TL0   = 0x00;       //Baud:9600  fosc=11.0592MHz    mode1
 710              IE   |= 0x02;       //Enable Timer 0 Interrupt
 711              TR0   = 0;          // start timer 0 run
 712          }*/
 713          
 714          /**************************************************/
 715          /*****************************************/
 716          /*                                       */
 717          /* The function use to init TIMER0       */
 718          /* designed by xl.zhang                  */
 719          /* Date 2007-4-11                        */
 720          /*                                       */
 721          /*****************************************/
 722          void InitTimer2()
 723          {
 724   1      
 725   1          RCLK=0;  // timer 2, 16 - bit
 726   1          TCLK=0;
 727   1          CP_RL2=0;
 728   1          TR2=0;
 729   1          TH2= 0x4C;       // Interrupt interval is 50ms for fosc=11.0592
 730   1          TL2= 0x00;       //
 731   1          ET2=1;       //Enable Timer 2 Interrupt
 732   1          TR2=1;          // start timer 2 run
 733   1      }
 734          
 735          /**************************************************/
 736          /*                                                */
 737          /* The function set the year,month,day,hour,minute,*/
C51 COMPILER V6.00i MYLIB                                                                  08/21/2007 12:22:11 PAGE 13  

 738          /*second*/
 739          /* where Sx is the trouble type to display        */
 740          /* f_time is the trouble start time or stop time  */
 741          /* hour and minute <=255(FFH)                     */
 742          /* designed by ht.guan                           */
 743          /* Date 2007-4-10                                */
 744          /**************************************************/
 745          
 746          uchar Key5(void)
 747          {
 748   1         uchar flag=0;
 749   1         if(P3_2==0)
 750   1      	      flag=1;
 751   1         else
 752   1              flag=0;
 753   1         return(flag);
 754   1      }
 755          uchar Key6(void)
 756          {
 757   1         uchar flag=0;
 758   1         if(P3_4==0)
 759   1              flag=1;
 760   1         else flag=0;
 761   1         return(flag);
 762   1      }
 763          void set_time(void)
 764          {
 765   1           uint i;
 766   1           if(Key5())
 767   1               SetTimeFlag = 1;
 768   1           while(SetTimeFlag)
 769   1           {
 770   2               if(Key5())
 771   2               {
 772   3                   delay(DL10ms);
 773   3                     KickDog();
 774   3                   if(Key5())
 775   3                   {
 776   4                       modified %= 6;
 777   4                       modified ++;
 778   4                   }
 779   3               }
 780   2               switch(modified)
 781   2               {
 782   3                   case 1:
 783   3                       if(Key6())
 784   3                       {
 785   4                           delay(DL10ms);
 786   4                             KickDog();
 787   4                           if(Key6())
 788   4                               Curtime[6]++;//sec
 789   4                           if(Curtime[6]>59)
 790   4                               Curtime[6]=0;
 791   4                       }
 792   3                       DispIC2_time(S13,Curtime);
 793   3                       delay(DL11ms);
 794   3                         KickDog();
 795   3                       LCD_WD2(4,0x80);     //display S13
 796   3                       LCD_WD2(2,0x00);     //display S14
 797   3                   break;
 798   3                   case 2:
 799   3                       if(Key6())
C51 COMPILER V6.00i MYLIB                                                                  08/21/2007 12:22:11 PAGE 14  

 800   3                       {
 801   4                           delay(DL10ms);
 802   4                             KickDog();
 803   4                           if(Key6())
 804   4                               Curtime[5]++;//minute
 805   4                           if(Curtime[5]>59)
 806   4                               Curtime[5]=0;
 807   4                       }
 808   3                       DispIC2_time(S13,Curtime);
 809   3                       delay(DL11ms);
 810   3                         KickDog();
 811   3                       LCD_WD2(6,0x00);     //display S13
 812   3                       LCD_WD2(8,0x00);     //display S14
 813   3                   break;
 814   3                   case 3:
 815   3                       if(Key6())
 816   3                       {
 817   4                           delay(DL10ms);
 818   4                             KickDog();
 819   4                           if(Key6())
 820   4                               Curtime[4]++;
 821   4                           if(Curtime[4]>23)//hour
 822   4                               Curtime[4]=0;
 823   4                       }
 824   3                       DispIC2_time(S13,Curtime);
 825   3                       delay(DL11ms);
 826   3                         KickDog();
 827   3                       LCD_WD2(10,0x00);     //display S13
 828   3                       LCD_WD2(12,0x00);     //display S14
 829   3                   break;
 830   3                   case 4:            //flag of display speed or pwmwidth  or angle
 831   3                       if(Key6())
 832   3                       {
 833   4                           delay(DL10ms);
 834   4                             KickDog();
 835   4                           if(Key6())
 836   4                               Curtime[3]++;//date
 837   4                           if(Curtime[3]>31)
 838   4                               Curtime[3]=1;
 839   4                       }
 840   3                       DispIC2_time(S13,Curtime);
 841   3                       delay(DL11ms);
 842   3                         KickDog();
 843   3                       LCD_WD2(14,0x00);     //display S13
 844   3                       LCD_WD2(16,0x00);     //display S14
 845   3                   break;
 846   3                   case 5:
 847   3                       if(Key6())
 848   3                       {
 849   4                           delay(DL10ms);
 850   4                             KickDog();
 851   4                           if(Key6())
 852   4                               Curtime[2]++;
 853   4                           if(Curtime[2]>12)//month
 854   4                               Curtime[2]=1;
 855   4                       }
 856   3                       DispIC2_time(S13,Curtime);
 857   3                       delay(DL11ms);
 858   3                         KickDog();
 859   3                       LCD_WD2(18,0x00);     //display S13
 860   3                       LCD_WD2(20,0x00);     //display S14
 861   3                   break;
C51 COMPILER V6.00i MYLIB                                                                  08/21/2007 12:22:11 PAGE 15  

 862   3                   case 6:
 863   3                       if(Key6())
 864   3                       {
 865   4                           delay(DL10ms);
 866   4                             KickDog();
 867   4                           if(Key6())
 868   4                               Curtime[0]++;
 869   4                           if(Curtime[0]>99)//year
 870   4                               Curtime[0]=0;
 871   4                       }
 872   3                       DispIC2_time(S13,Curtime);
 873   3                       delay(DL11ms);
 874   3                         KickDog();
 875   3                       LCD_WD2(22,0x80);     //display S13
 876   3                       LCD_WD2(24,0x80);     //display S14
 877   3                   break;
 878   3                   default:
 879   3                   break;
 880   3               }
 881   2               if(Key6() && Key5())
 882   2               {
 883   3                   delay(DL10ms);
 884   3                     KickDog();
 885   3                   if(Key6()&& Key5())
 886   3                   {
 887   4                       SetTimeFlag = 0;
 888   4                       for(i=0;i<7;i++)
 889   4                           Curtime[i] = dec_to_hex(Curtime[i]);
 890   4                       Set1302(Curtime);
 891   4                   }
 892   3               }
 893   2           }
 894   1      }
 895          ///////////////////////////////////////////
 896          /*void timer0() interrupt 1 using 2
 897          {
 898          	  if(UaDis5Start && a_b==0)
 899          	  {

⌨️ 快捷键说明

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