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

📄 lib.h

📁 这是一个飞思卡尔智能车比赛的一个完整的程序
💻 H
📖 第 1 页 / 共 3 页
字号:
           } 
         }
      }
/*----------------------------------LibLCDNumChgPost(unsigned int num)----------------------------------*/    
void LibLCDNumChgPost(unsigned int num)
     { 
     unsigned char temp;   
     if(num<10)
        {
        temp=ExtNumTbl[num];
        LibDsend(temp);
        LibDsend(' ');
        } 
     else if(num>9 & num<100)
        {
        temp=ExtNumTbl[num/10];//十
        LibDsend(temp);  
        temp=ExtNumTbl[num%10];//个
        LibDsend(temp);
        LibDsend(' ');
        }
     else if(num>99 & num<1000)
        { 
        temp=ExtNumTbl[num/100];//百
        LibDsend(temp);
        temp=ExtNumTbl[(num%100)/10];//十
        LibDsend(temp);
        temp=ExtNumTbl[num%10];//个
        LibDsend(temp);
        LibDsend(' ');
        }    
     else if(num>999 & num<10000)   
        {
        temp=ExtNumTbl[num/1000];//千
        LibDsend(temp);
        temp=ExtNumTbl[(num%1000)/100];//百
        LibDsend(temp);  
        temp=ExtNumTbl[(num%100)/10];//十
        LibDsend(temp);
        temp=ExtNumTbl[num%10];//个
        LibDsend(temp);
        LibDsend(' ');
        }
     else if(num>9999)   
        {
        temp=ExtNumTbl[num/10000];//万
        LibDsend(temp);
        temp=ExtNumTbl[(num%10000)/1000];//千
        LibDsend(temp);
        temp=ExtNumTbl[(num%1000)/100];//百
        LibDsend(temp);  
        temp=ExtNumTbl[(num%100)/10];//十
        LibDsend(temp);
        temp=ExtNumTbl[num%10];//个
        LibDsend(temp);
        LibDsend(' ');
        } 
      } 
/*----------------------------------LibLCDNumChgPost(unsigned int num)----------------------------------*/    
void LibLCDInfoDis(void)
     {
          LibKeyAction();
          switch (ExtMenu) 
                 {
                 case 1:
                       {
                       if(ExtLcdPost==1||ExtLcdPWMDTY45Dis)
                       {
                       LibLCDInit();
                       LibLCDSendChr("Steer:/");
                       Lib_LCD_lINE_CHG();
                       LibLCDNumChgPost(PWMDTY45);
                       ExtLcdPost=0;
                       ExtLcdPWMDTY45Dis=0;
                       }
                       break;
                       }
                 case 2:
                       {
                       if(ExtLcdPost==1||ExtLcdPWMDTY23Dis)
                       {
                       LibLCDInit();
                       LibLCDSendChr("MotorForward:/");
                       Lib_LCD_lINE_CHG();
                       LibLCDNumChgPost(*((uint *)2048));
                       ExtLcdPost=0;
                       ExtLcdPWMDTY23Dis=0;
                       }
                       break;
                       } 
                 case 3:
                       {
                       if(ExtLcdPost==1||ExtLcdPWMDTY01Dis)
                       {
                       LibLCDInit();
                       LibLCDSendChr("MotorReverse:/");
                       Lib_LCD_lINE_CHG();
                       LibLCDNumChgPost(PWMDTY01);
                       ExtLcdPost=0;
                       ExtLcdPWMDTY01Dis=0;
                       }
                       break;
                       }
                 case 4:
                       {
                       if(ExtLcdPost==1)
                       {
                       LibLCDInit();
                       LibLCDSendChr("ExtSpeedSet:/");
                       Lib_LCD_lINE_CHG();
                       LibLCDNumChgPost(*((uint *)2054));      
                       ExtLcdPost=0;
                       }
                       break;
                       }                       
                 case 5:
                       {
                       if(ExtLcdPost==1)
                       {
                       LibLCDInit();
                       LibLCDSendChr("ExtPWM23Set:/");
                       Lib_LCD_lINE_CHG();
                       LibLCDNumChgPost(*((uint *)2056));      
                       ExtLcdPost=0;
                       }                      
                       break;
                       }           
                 case 6:
                       {
                       if(ExtLcdPost==1)
                       {
                       LibLCDInit();
                       LibLCDSendChr("ExtPk:/");
                       Lib_LCD_lINE_CHG();
                       LibLCDNumChgPost(*((uint *)2050));      
                       ExtLcdPost=0;
                       }
                       break;
                       }
                 case 7:
                       {
                       if(ExtLcdPost==1)
                       {
                       LibLCDInit();
                       LibLCDSendChr("ExtPd:/");
                       Lib_LCD_lINE_CHG();
                       LibLCDNumChgPost(*((uint *)2052));      
                       ExtLcdPost=0;
                       }
                       break;
                       }                          
                 case 8:
                       {
                       if(ExtLcdPost==1||ExtLcdCPUUsageDis==1||ExtLcdPosDis==1)
                       {
                       if(ExtOSSystemStart==1)
                         {
                         if(ExtLcdCPUUsageDis==1||ExtLcdPosDis==1)
                           {
                           LibLCDInit();
                           LibLCDSendChr("U:/");
                           LibLCDNumChgPost(OSCPUUsage);
                           LibLCDSendChr("V:/");
                           LibLCDNumChgPost(ExtPelsValve);
                           Lib_LCD_lINE_CHG();
                           LibLCDSendChr("P:/");
                           LibLCDNumChgPost(ExtPos);
                           LibLCDSendChr("S:/");
                           LibLCDNumChgPost(PACN10);
                           ExtLcdPosDis=0;
                           ExtLcdCPUUsageDis=0;
                           }
                         }
                         else
                         {
                         LibLCDInit();
                         LibLCDSendChr("Sys Waiting:/");
                         Lib_LCD_lINE_CHG();
                         LibLCDSendChr("Press 4/");                         
                         }
                       ExtLcdPost=0;
                       }
                       break;
                       }               
                  }       
     } 

     
/*************************************************************************************************/
/*************************************************************************************************/
/*************************************************************************************************/

     
/*----------------------------------LibGetKey(void)----------------------------------*/
char LibGetKey(void)                      //scan keyboard
     {
     char key;
     uchar ptj;
     if(PTJ==0b11000011)
       {return key=0;}
     else
       {
       ptj=PTJ;
       LibDelay(600);
       if(ptj==PTJ)
         {
         while(ptj==PTJ);
         switch (ptj) 
            {
            case 0b11000010 :return key=1; 
            case 0b11000001 :return key=2; 
            case 0b10000011 :return key=3; 
            case 0b01000011 :return key=4;    
            }  
         }
       }  
     }     
/*----------------------------------LibKeyAction(void)----------------------------------*/
void LibKeyAction(void) 
     {
     char key;
     key=LibGetKey();
     if(key!=0)
       {
        Lib_AlARM_END();
        switch (key) 
            {
            case 1 :
                   {
                    ExtMenu--;
                    if(ExtMenu<1)
                      {ExtMenu=8;}
                    ExtLcdPost=1;   
                    break;      
                   }  
            case 2 :
                   {
                    switch (ExtMenu) 
                           {
                           case 1:
                                 {
                                  PWMDTY45=PWMDTY45+10;
                                  if(PWMDTY45>4850)
                                    {PWMDTY45=4850;}
                                  ExtLcdPost=1;
                                  break;
                                 }
                           case 2:
                                 {
                                 ExtPWMDTY23=*((uint *)2048);
                                 ExtPWMDTY23=ExtPWMDTY23+30;
                                 PWMDTY23=ExtPWMDTY23;
                                 if(ExtPWMDTY23>2400)
                                   {ExtPWMDTY23=0;}
                                 LibEepromReProgWord(PWMDTY23,2048);
                                 ExtLcdPost=1;
                                 break; 
                                 }
                           case 3:
                                 {
                                 PWMDTY01=PWMDTY01+100;
                                 if(PWMDTY01>2400)
                                   {PWMDTY01=0;}
                                 ExtLcdPost=1;
                                 break; 
                                 } 
                           case 4:
                                 {
                                 ExtSpeedSet++;
                                 LibEepromReProgWord(ExtSpeedSet,2054);
                                 ExtLcdPost=1;
                                 break; 
                                 } 
                           case 5:
                                 {
                                 ExtPWM23Set=ExtPWM23Set+30;
                                 LibEepromReProgWord(ExtPWM23Set,2056);
                                 ExtLcdPost=1;
                                 break; 
                                 }                            
                           case 6:
                                 {
                                 ExtPk=*((uint *)2050);
                                 ExtPk++;
                                 LibEepromReProgWord(ExtPk,2050);
                                 ExtLcdPost=1;
                                 break; 
                                 } 
                           case 7:
                                 {
                                 ExtPd=*((uint *)2052);
                                 ExtPd++;
                                 LibEepromReProgWord(ExtPd,2052);
                                 ExtLcdPost=1;
                                 break; 
                                 }
                            case 8:
                                 {
                                 PIEH=0X0;
                                 PACN32=0;
                                 OSTaskSuspend(9);
                                 OSTaskResume(16);
                                 ExtLcdPost=1;
                                 break; 
                                 }                                                                
                            }      
                   break;                                         
                   } 
            case 3 :
                   {
                    switch (ExtMenu) 
                           {
                           case 1:
                                 {
                                  PWMDTY45=PWMDTY45-10;
                                  if(PWMDTY45<4120)
                                    {PWMDTY45=4120;}
                                    ExtLcdPost=1;
                                  break;  
                                 }
                           case 2:
                                 {
                                 ExtPWMDTY23=*((uint *)2048);
                                 ExtPWMDTY23=ExtPWMDTY23-30;
                                 PWMDTY23=ExtPWMDTY23-30;
                                 if(ExtPWMDTY23>2400)
                                   {ExtPWMDTY23=2400;}
                                 LibEepromReProgWord(PWMDTY23,2048);
                                 ExtLcdPost=1;
                                 break; 
                                 }
                           case 3:
                                 {
                                 PWMDTY01=PWMDTY01-100;
                                 if(PWMDTY01>2400)
                                   {PWMDTY01=2400;}
                                 ExtLcdPost=1;
                                 break; 

⌨️ 快捷键说明

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