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

📄 main.lst

📁 自己写的测试程序,调试已通过,可以直接使用, 而且有的还有详细的注释.红外采集器软件
💻 LST
📖 第 1 页 / 共 5 页
字号:
 714   1           h=temp/100;
 715   1        if(j<=3){ if(h==0){w0-=7;}                   //w0    
 716   2      
 717   2         write_byte(0,y,7,&number[25]);
 718   2         write_byte(0,y,18,&number[22]);
 719   2      
 720   2         
 721   2       
 722   2       if(~err){if(qq){write_byte(0,y,23,&number[25]);}   //负号!
 723   3                write_byte(0,y,w0+18,&number[26]);
 724   3                write_byte(0,y,w0+26,&number[12]);}
 725   2        
C51 COMPILER V7.08   MAIN                                                                  06/13/2007 16:48:08 PAGE 13  

 726   2        write_byte(0,y,0,&number[i+10]);
 727   2        write_byte(0,y,12,&number[j]);    
 728   2         if(~err){               
 729   3        if(h==1)
 730   3           {
 731   4         write_byte(0,y,w0,&number[h]);}
 732   3        z=(temp-(h*100))/10;
 733   3         write_byte(0,y,w0+7,&number[z]);
 734   3        z=temp%10;
 735   3         write_byte(0,y,w0+14,&number[z]);
 736   3         }}
 737   1        else
 738   1        {
 739   2           if(h==0){w1-=7;}
 740   2        write_byte(1,y,10,&number[25]);
 741   2        write_byte(1,y,21,&number[22]);    //:
 742   2        if(~err){if(qq){write_byte(1,y,26,&number[25]);}   //负号!
 743   3                write_byte(1,y,w1+26,&number[12]);  
 744   3                write_byte(1,y,w1+18,&number[26]);
 745   3                }
 746   2      
 747   2      
 748   2       
 749   2        write_byte(1,y,3,&number[i+10]);
 750   2        write_byte(1,y,15,&number[j]);
 751   2      
 752   2        if(~err)
 753   2          {                         
 754   3        
 755   3        if(h==1){
 756   4         write_byte(1,y,w1,&number[h]);}
 757   3        z=(temp-(h*100))/10;
 758   3         write_byte(1,y,w1+7,&number[z]);
 759   3        z=temp%10;
 760   3         write_byte(1,y,w1+14,&number[z]);
 761   3         }}
 762   1                                  // SEND RS485
 763   1                            if(err){t_buf[(i*6+j)*2-1]=i*6+j; t_buf[(i*6+j)*2]=0xfe;}
 764   1                             else {t_buf[(i*6+j)*2-1]=i*6+j; t_buf[(i*6+j)*2]=temp&0xff; }  
 765   1              
 766   1       }
 767          /********************  display single temp *********************************************/
 768          void display_temp_single(unsigned i,unsigned char j,short int temp)
 769          {
 770   1       unsigned char y,z,h,w0,w1;
 771   1       signed char down,up;
 772   1       bit err,qq;                                                            
 773   1       err=0;
 774   1       qq=0;
 775   1       w0=28;w1=31;
 776   1        
 777   1       z=0;
 778   1       if(j==1|j==4){y=2;}
 779   1       if(j==2|j==5){y=4;}
 780   1       if(j==3|j==6){y=6;}
 781   1      // if(j==4|j==8){y=6;}
 782   1                                                     if(j<=3){
 783   2                                                    //      write_byte(0,y,23,&number[19]); 
 784   2                                                   //        write_byte(0,y,31,&number[19]); 
 785   2                                                   //        write_byte(0,y,39,&number[19]);
 786   2                                                   //         write_byte(0,y,47,&number[19]); 
 787   2                                                           write_byte(0,y,55,&number[19]); }
C51 COMPILER V7.08   MAIN                                                                  06/13/2007 16:48:08 PAGE 14  

 788   1                                                    if(j>3){ write_byte(1,y,23,&number[19]); 
 789   2                                                      //     write_byte(1,y,31,&number[19]); 
 790   2                                                     //      write_byte(1,y,39,&number[19]);
 791   2                                                     //       write_byte(1,y,47,&number[19]); 
 792   2                                                           write_byte(1,y,55,&number[19]); }
 793   1      
 794   1         if(temp<-880|temp>2000|temp==-1)
 795   1                         {if(j<=3){write_word(0,y,28,&chinese[51]);
 796   3                                                write_word(0,y,44,&chinese[52]);}
 797   2                                               else{write_word(1,y,28,&chinese[51]);
 798   3                                                write_word(1,y,44,&chinese[52]);}      
 799   2                                                    err=1;                 // err control r ,l
 800   2                                                  }
 801   1         if(temp<0){temp*=(-1);qq=1;}                 // qq control z ,f
 802   1         temp*=0.0625;                  
 803   1                                                   if(~err)
 804   1                                                                                                  {
 805   2                                                                                                       read_iic_data(1,&iic_read,0,8);        //继电器
 806   2                                                                                                         if(iic_read[3]==1){down=iic_read[1]*(-1);}
 807   2                                                                                                             else down=iic_read[1];
 808   2                                                                                                          if(iic_read[4]==1){up=iic_read[2]*(-1);}
 809   2                                                                                                              else {up=iic_read[2];}
 810   2                                                       if(temp<=down|temp>=up)
 811   2                                                                                                         {
 812   3                                                                                                          call=0;
 813   3                                                                                                         }
 814   2                                                                                                   }
 815   1                              // SEND RS485
 816   1                            if(err){t_buf[(i*6+j)*2-1]=i*6+j; t_buf[(i*6+j)*2]=0xfe;}
 817   1                             else {t_buf[(i*6+j)*2-1]=i*6+j; t_buf[(i*6+j)*2]=temp&0xff; }  
 818   1       
 819   1                       
 820   1           h=temp/100;                   
 821   1        if(j<=3){ if(h==0){w0-=7;}                   //w0    
 822   2                      
 823   2         write_byte(0,y,7,&number[25]);             //-
 824   2         write_byte(0,y,18,&number[22]);           //:
 825   2      
 826   2      
 827   2      
 828   2        
 829   2       if(~err){if(qq){write_byte(0,y,23,&number[25]);}   //负号!
 830   3                write_byte(0,y,w0+18,&number[26]);
 831   3                write_byte(0,y,w0+26,&number[12]);}
 832   2                        
 833   2                        
 834   2        write_byte(0,y,0,&number[j+10-1]);
 835   2        write_byte(0,y,12,&number[1]);    
 836   2         if(~err){            
 837   3        if(h==1)
 838   3           {
 839   4         write_byte(0,y,w0,&number[h]);}
 840   3        z=(temp-(h*100))/10;
 841   3         write_byte(0,y,w0+7,&number[z]);
 842   3        z=temp%10;
 843   3         write_byte(0,y,w0+14,&number[z]);
 844   3         }}
 845   1        else
 846   1        {  
 847   2                                                           
 848   2      
 849   2           if(j>3){j-=3;}
C51 COMPILER V7.08   MAIN                                                                  06/13/2007 16:48:08 PAGE 15  

 850   2           if(h==0){w1-=7;}
 851   2        write_byte(1,y,10,&number[25]);
 852   2        write_byte(1,y,21,&number[22]);    //:
 853   2        if(~err){if(qq){write_byte(1,y,26,&number[25]);}   //负号!
 854   3                write_byte(1,y,w1+26,&number[12]);  
 855   3                write_byte(1,y,w1+18,&number[26]);
 856   3                }
 857   2      
 858   2      
 859   2       
 860   2        write_byte(1,y,3,&number[j+10-1]);
 861   2        write_byte(1,y,15,&number[2]);
 862   2      
 863   2        if(~err)
 864   2          {                         
 865   3        
 866   3        if(h==1){
 867   4         write_byte(1,y,w1,&number[h]);}
 868   3        z=(temp-(h*100))/10;
 869   3         write_byte(1,y,w1+7,&number[z]);
 870   3        z=temp%10;
 871   3         write_byte(1,y,w1+14,&number[z]);
 872   3         }}
 873   1                             
 874   1              
 875   1       }
 876          
 877          /**************  timer interrupt 0 *********************************/
 878           void time_0(void)interrupt 1 using 3
 879           {
 880   1         
 881   1        ch451_clk=0;
 882   1        ch451_clk=1;
 883   1        base_time=!base_time;
 884   1      
 885   1        TH0=0x00;
 886   1        TL0=0x00;
 887   1      //  if(flag_s){ok_es++;if(ok_es>500){ok_es=0;ES=1;}}
 888   1        if(flag_exit){ok_n_times++;}
 889   1        if(ok_n_times>100){flag_exit_ok=1;ok_n_times=0;}
 890   1      
 891   1       }
 892          
 893          ///////////////////////////////////////////////////////////////////////////////////////////////////////
 894          ///////////////////////////////////////////////////////////////////////////////////////////////////////
 895          
 896          /*********   ch451 init *************************/
 897          void ch451_init(void)
 898          {
 899   1       ch451_din=0;
 900   1       ch451_din=1;
 901   1       
 902   1       ch451_load=1;
 903   1       ch451_clk=1;
 904   1       _nop_();
 905   1       }
 906          /************  write 12 bit to ch451 *************/
 907          void ch451_write(unsigned short int command)
 908          {
 909   1       unsigned char i;
 910   1       EX1=0;
 911   1       ch451_load=0;
C51 COMPILER V7.08   MAIN                                                                  06/13/2007 16:48:08 PAGE 16  

 912   1       for(i=0;i<12;i++)
 913   1        {
 914   2         ch451_din=command&1;
 915   2         ch451_clk=0;
 916   2         command>>=1;
 917   2         ch451_clk=1;
 918   2         }
 919   1        ch451_load=1;
 920   1       EX1=1;
 921   1       }
 922          
 923          /**********  CH451 interrupt **************************/
 924          
 925          void ch451_inter() interrupt 2 using 1
 926          {
 927   1       key_flag=1;
 928   1      }
 929          /**********   bring a key code  ************************/
 930          unsigned char key_code()
 931          {
 932   1       unsigned char i;
 933   1       unsigned char command,keycode;
 934   1      
 935   1       command=0x07;
 936   1       EX1=0;
 937   1       ch451_load=0;
 938   1       for(i=0;i<4;i++)
 939   1       {
 940   2        ch451_din=command&1;
 941   2        ch451_clk=0;
 942   2         command>>=1;
 943   2        ch451_clk=1;
 944   2       }
 945   1       ch451_load=1;
 946   1       keycode=0;
 947   1       for(i=0;i<7;i++)
 948   1        {
 949   2        keycode<<=1; 
 950   2        keycode|=ch451_dout;
 951   2        ch451_clk=0;
 952   2        ch451_clk=1;
 953   2        }
 954   1       
 955   1       EX1=1;            // open outinterrupt
 956   1       IE1=0;            // interrupt flag bit ;
 957   1      

⌨️ 快捷键说明

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