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

📄 ddcjc.lst

📁 电动车测试平台控制系统。自动测量电动车各项参数
💻 LST
📖 第 1 页 / 共 3 页
字号:
 564   3                                       IntToLED (Dia, 2, 2, FALSE, FALSE, 5);
 565   3                                       //换算得到当前值的下标
 566   3                                       InitCodeIndex(Dia);
 567   3                               break;
 568   3                        case 10:
 569   3                               //计算滚筒直径
 570   3                               Dia = GetResult(1);
 571   3      
 572   3                                       //滚筒直径
 573   3                                       //Convert.w = Dia;
 574   3                                       //Set8583Data (WHEEL_DIA, Convert.b, 2);
 575   3                                       WriteParam ();
 576   3                                       Wheel = GetWheel (); 
 577   3                                       IntToLED (DIA_SEL[BikeIndex], 3, 3, FALSE, TRUE, 4);   
 578   3                               break;
 579   3                        case 11: 
 580   3                               //保存轮子直径
 581   3                                       //Set8583Byte (BIKE_DIA, BikeIndex);
 582   3                                       WriteParam ();
 583   3                                       //显示时间
 584   3                                       ShiftIndex ++;
 585   3                                   GetDateTime ();
 586   3                               break;
 587   3                        case 12:
 588   3                               //保存日期
 589   3                                       WriteDateTime();
 590   3                                       //保存其他参数
 591   3                               //WriteParam (); 
 592   3                               break;
 593   3                        default: 
 594   3                               //退出设置
 595   3                               return ~P2;
 596   3                        }
 597   2                        OptIndex ++;
 598   2                        OptIndex %= 13;
 599   2                    break;  
 600   2               case 0x02:               //置数
 601   2                    bDispTime = FALSE;
 602   2                    if (IsOption)
 603   2                        {
 604   3                            switch (OptIndex)
 605   3                            {
 606   4                                case 1:
 607   4                            case 3:
 608   4                            case 4:
 609   4                            case 5:
 610   4                            case 6:
 611   4                                case 8:
 612   4                                case 9:
 613   4                                case 10:
C51 COMPILER V7.50   DDCJC                                                                 11/28/2006 20:24:32 PAGE 11  

 614   4                                   DataIndex ++;
 615   4                                   DataIndex %= 10;
 616   4                                   DispBuf[ShiftIndex] = LED_CODE[DataIndex] | (DispBuf[ShiftIndex] & 0x80); 
 617   4                                   CodeIndex[ShiftIndex - 4] = DataIndex;
 618   4                                   break;
 619   4                                case 7:
 620   4                                       PrinterIndex ++;
 621   4                                               PrinterIndex %= 2; 
 622   4                                               DispBuf[7] = LED_CODE[PrinterIndex];
 623   4                                       break;
 624   4                                case 2:
 625   4                                       ModeIndex ++;
 626   4                                               ModeIndex %= 4; 
 627   4                                               DispBuf[7] = LED_CODE[ModeIndex];
 628   4                                               DispMode();
 629   4                                               break;
 630   4                                case 11:
 631   4                                       BikeIndex ++;
 632   4                                   BikeIndex %= 5;
 633   4                                           DispBuf[6] = LED_CODE[DIA_SEL[BikeIndex]/10];
 634   4                                           DispBuf[7] = LED_CODE[DIA_SEL[BikeIndex]%10];
 635   4                                               GetBike (); 
 636   4                                   break;
 637   4                                case 12:
 638   4                                       DataIndex ++;
 639   4                                   DataIndex %= 10;
 640   4                                   DispBuf[ShiftIndex] = LED_CODE[DataIndex] | (DispBuf[ShiftIndex] & 0x80); 
 641   4                                   UartBuf[ShiftIndex] = DataIndex;
 642   4                                   break;
 643   4                            }
 644   3                        }
 645   2                    break;  
 646   2               case 0x04:               //移位
 647   2                    bDispTime = FALSE;
 648   2                    if (IsOption)
 649   2                        {
 650   3                        if (OptIndex != 7 &&
 651   3                                    OptIndex != 2 &&
 652   3                                        OptIndex != 11&&
 653   3                                        OptIndex != 0)
 654   3                            {
 655   4                            IsShine = TRUE;    
 656   4                            ShiftIndex ++;
 657   4                                        switch(OptIndex)
 658   4                                        {
 659   5                                        case 1:
 660   5                                        case 3:
 661   5                                        case 5:
 662   5                                        case 9:
 663   5                                            if (ShiftIndex == 8)
 664   5                                        ShiftIndex = 4; 
 665   5                                                DataIndex = CodeIndex[ShiftIndex - 4];
 666   5                                                break;
 667   5                                        case 8:
 668   5                                            if (ShiftIndex == 8)
 669   5                                        ShiftIndex = 6; 
 670   5                                                DataIndex = CodeIndex[ShiftIndex - 4];
 671   5                                            break;
 672   5                                        case 12:      
 673   5                                            if (ShiftIndex == 8)
 674   5                                                    ShiftIndex ++;
 675   5                                            if (ShiftIndex == 17)
C51 COMPILER V7.50   DDCJC                                                                 11/28/2006 20:24:32 PAGE 12  

 676   5                                                    ShiftIndex = 5;
 677   5                                                DataIndex = UartBuf[ShiftIndex]; 
 678   5                                            break;
 679   5                                        default:
 680   5                                    if (ShiftIndex == 8)
 681   5                                        ShiftIndex = 5; 
 682   5                                                DataIndex = CodeIndex[ShiftIndex - 4];
 683   5                                                break;
 684   5                                        }
 685   4                        }
 686   3                        }
 687   2                        else
 688   2                        {
 689   3                            InitUart ();
 690   3                                Printer(0);
 691   3                        }
 692   2                        break;  
 693   2               default:               
 694   2                    break; 
 695   2               }
 696   1               return ~P2;
 697   1      }
 698          
 699          void SendLED (uchar *DataBuf)
 700          {
 701   1           uchar data i, j;
 702   1               uchar data mid;
 703   1           
 704   1               _nop_ ();       
 705   1               
 706   1               for (i=0; i<3; i++)
 707   1               {
 708   2                for (j=0; j<8; j++)
 709   2                { 
 710   3                             mid = 0x80 >> j;
 711   3                     if (DataBuf[i] & mid)
 712   3                         DAT_595 = HIGH;
 713   3                     else
 714   3                         DAT_595 = LOW;
 715   3                     _nop_ ();
 716   3                     CLK_595 = LOW;
 717   3                     _nop_ ();
 718   3                     CLK_595 = HIGH;
 719   3                     _nop_ ();
 720   3                }               
 721   2               }       
 722   1               
 723   1               SEL_595 = (DispIndex == 8) ? LOW:HIGH; 
 724   1      
 725   1               STB_595 = LOW;
 726   1           _nop_ ();
 727   1               STB_595 = HIGH; 
 728   1               _nop_ (); 
 729   1           DAT_595 = HIGH; //数据线保持高电平
 730   1           _nop_ ();           
 731   1      }     
 732          
 733          void GetDateTime ()
 734          {
 735   1           uchar i;
 736   1               uchar cTemp, cBaseYear;
 737   1               //读年月日时分秒
C51 COMPILER V7.50   DDCJC                                                                 11/28/2006 20:24:32 PAGE 13  

 738   1               Set8583Byte (PCF8583_CTR, 0x40);
 739   1               Get8583Data (SECOND, UartBuf, 5);
 740   1               Set8583Byte (PCF8583_CTR, 0x00);
 741   1               Get8583Data (BASE_YEAR, &cBaseYear, 1);
 742   1           
 743   1               //初始化显示下标
 744   1               UartBuf[17] = UartBuf[0] & 0x0F;                        
 745   1               UartBuf[16] = UartBuf[0]>>4 & 0x0F;                 //秒
 746   1               UartBuf[15] = UartBuf[1] & 0x0F; 
 747   1               UartBuf[14] = UartBuf[1]>>4 & 0x0F;             //分 
 748   1               UartBuf[13] = UartBuf[2] & 0x0F;
 749   1               UartBuf[12] = UartBuf[2]>>4 & 0x0F;             //时
 750   1                      
 751   1               cTemp = GetDate (UartBuf[3]);                               //日  
 752   1               UartBuf[11] = cTemp & 0x0F;
 753   1               UartBuf[10] = cTemp>>4 & 0x0F; 
 754   1      
 755   1               cTemp = GetMonth (UartBuf[4]);                      //月
 756   1               UartBuf[9] = cTemp & 0x0F;
 757   1               UartBuf[7] = cTemp>>4 & 0x0F;
 758   1      
 759   1               cTemp = GetYear (UartBuf[3]) + cBaseYear*4;     //年 
 760   1               UartBuf[6] = cTemp & 0x0F;
 761   1               UartBuf[5] = (cTemp>>4) & 0x0F;  
 762   1               UartBuf[4] = 0;
 763   1               UartBuf[3] = 2; 
 764   1               //换算到LED
 765   1               for (i=3; i<18; i++)
 766   1               {
 767   2                    if (i == 8)
 768   2                            i++;
 769   2                        DispBuf[i] = LED_CODE[UartBuf[i]];
 770   2               }           
 771   1      }
 772          
 773          void Display ()                                                                                                 
 774          {                                                                                          
 775   1          uchar data595[3];
 776   1      
 777   1              //计算显示数据
 778   1              data595[0] = 0x01 << DispIndex;
 779   1              
 780   1              if (DispIndex == 0)
 781   1              {
 782   2                  data595[0] = 0x01 << DispIndex;
 783   2                      data595[2] = 0x00;//DispBuf[DispIndex];
 784   2                  data595[1] = 0x00;//DispBuf[DispIndex+9];
 785   2                      SendLED (data595);
 786   2              } 
 787   1              
 788   1              data595[0] = 0x01 << DispIndex; 
 789   1              
 790   1              if (IsShine)
 791   1              {
 792   2                  if (ShiftIndex < 9)
 793   2                      {
 794   3                          if (ShiftIndex == DispIndex)
 795   3                              {
 796   4                                      if (ShineTime < 5)
 797   4                                          data595[2] = 0;
 798   4                                      else if (ShineTime < 10)
 799   4                                      {
C51 COMPILER V7.50   DDCJC                                                                 11/28/2006 20:24:32 PAGE 14  

 800   5                                           data595[2] = DispBuf[DispIndex];
 801   5                                      }
 802   4                                      ShineTime ++;
 803   4                                      ShineTime %= 10;
 804   4                              }
 805   3                              else
 806   3                                  data595[2] = DispBuf[DispIndex];
 807   3                      data595[1] = DispBuf[DispIndex+9];      
 808   3                      }
 809   2                      else 
 810   2                      {
 811   3                          if (ShiftIndex == DispIndex + 9)
 812   3                              {
 813   4                              if (ShineTime < 5)
 814   4                                          data595[1] = 0;
 815   4                                      else if (ShineTime < 10)
 816   4                                      {
 817   5                                          data595[1] = DispBuf[DispIndex+9];  
 818   5                                      }
 819   4                                      ShineTime ++;
 820   4                                      ShineTime %= 10;
 821   4                              }
 822   3                              else
 823   3                                      data595[1] = DispBuf[DispIndex+9];       
 824   3                      data595[2] = DispBuf[DispIndex];        
 825   3                      }       
 826   2              }
 827   1              else
 828   1              {  
 829   2                  data595[2] = DispBuf[DispIndex];
 830   2                  data595[1] = DispBuf[DispIndex+9];   
 831   2              }
 832   1              
 833   1              //SEL_595 = (DispIndex == 8) ? LOW:HIGH;        
 834   1      
 835   1              SendLED (data595);
 836   1      
 837   1              if (DispIndex == 7)
 838   1              {
 839   2                  data595[0] = 0x01 << DispIndex;
 840   2                      data595[2] = 0x00;//DispBuf[DispIndex];
 841   2                  data595[1] = 0x00;//DispBuf[DispIndex+9];
 842   2                      SendLED (data595);
 843   2              }
 844   1                      
 845   1          //计算下一次显示下标
 846   1              DispIndex ++;
 847   1          DispIndex = DispIndex % DISPLAY_BUF_LEN;
 848   1      }
 849          
 850          void IntToLED (uint uData, uchar uLength, uchar uDotPos, bit bIsDot, bit bClear, uchar StartIndex)   //数

⌨️ 快捷键说明

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