Kiran George Vetteth / Mbed 2 deprecated Steering_Display

Dependencies:   Digital_InOut KS0108 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SteeringTemp.h Source File

SteeringTemp.h

00001 #include "Steering.h"
00002 
00003 void HomeScreen()
00004 {
00005     CANMessage Rxmsg;
00006     ftc rcv,send;
00007     
00008     send.FLOAT=45.4444;
00009     Rxmsg.id=BATTERY_VOLTAGE_ID;
00010     for(int i=0; i<4; i++)
00011         Rxmsg.data[i]=send.C_FLOAT[i];
00012     display.ClearScreen();
00013     display.SelectFont(Arial12,BLACK,ReadData);
00014     if(CAN_Steering.read(Rxmsg))
00015     {
00016         for(int i=0; i<4; i++)
00017             rcv.C_FLOAT[i]=Rxmsg.data[i];
00018         if(Rxmsg.id == BATTERY_VOLTAGE_ID)
00019         {
00020             display.GotoXY(0,0);
00021             display.PrintString(" PV: ");     
00022             display.PrintNumber(rcv.FLOAT);
00023             display.PrintString("V");
00024         }
00025         if(Rxmsg.id == BATTERY_POWER_ID)
00026         {
00027             display.GotoXY(0,16);
00028             display.PrintString(" PP: ");        
00029             display.PrintNumber(rcv.FLOAT);
00030             display.PrintString("KW");
00031         }
00032         if(Rxmsg.id == BATTERY_STATE_ID)
00033         {
00034             display.GotoXY(0,32);
00035             display.PrintString(" STATE: ");      
00036             display.PrintString(rcv.C_FLOAT);
00037         }
00038     }
00039     wait(2);
00040     return;    
00041 }
00042 
00043 /*
00044 void ShutdwnScreen()
00045 {
00046     screen=1;
00047     CANMessage Rxmsg;
00048     uint16_t recv=0, temp=0, i=0;
00049     //Test
00050     
00051         //uint16_t Rxpoll=15;
00052         //char Result[4]={0};
00053         //Result[0]=(char)(Rxpoll&0x00ff);
00054         //Result[1]=(char)((Rxpoll&0xff00)>>8);
00055         //CANMessage Rxmsg(410,Result,sizeof(Result));
00056         
00057     display.ClearScreen();
00058     display.GotoXY(0,0);
00059     display.SelectFont(Arial12,BLACK,ReadData);
00060     display.PrintString("SHTDWN SWTCH OPEN");
00061 
00062         if(CAN_Steering.read(Rxmsg))
00063         {
00064             if(Rxmsg.id == SWITCH_ID)
00065             {
00066                 recv=(((uint16_t)Rxmsg.data[1]<<8) | (0x00ff&(uint16_t)Rxmsg.data[0]));
00067                 display.GotoXY(0,16);
00068                 while(i < 12)
00069                 {
00070                     temp=recv;
00071                     if(((temp & (1 << i))>>i) == 1)
00072                     {
00073                         display.GotoXY(SwitchPosition[i][0],SwitchPosition[i][1]);
00074                         display.PrintString(SwitchName[i]);
00075                     }    
00076                 }
00077             }
00078         }
00079         return;    
00080 }    
00081 
00082 void AMS1Screen()
00083 {
00084     screen=2;
00085     CANMessage Rxmsg;
00086     ftc rcv;
00087     rcv.FLOAT=0.0;
00088     
00089     display.ClearScreen();
00090     display.SelectFont(Arial12,BLACK,ReadData);
00091    
00092     if(CAN_Steering.read(Rxmsg))
00093     {
00094         for(int i=0; i<4; i++)
00095             rcv.C_FLOAT[i]=Rxmsg.data[i];
00096         if(Rxmsg.id == BATTERY_VOLTAGE_ID)
00097         {
00098             display.GotoXY(0,0);
00099             display.PrintString(" PV: ");     
00100             display.PrintNumber(rcv.FLOAT);
00101             display.PrintString("V");
00102         }
00103         if(Rxmsg.id == BATTERY_POWER_ID)
00104         {
00105             display.GotoXY(0,16);
00106             display.PrintString(" PV: ");     
00107             display.PrintNumber(rcv.FLOAT);
00108             display.PrintString("KW");
00109         }
00110         if(Rxmsg.id == BATTERY_CURRENT_ID)
00111         {
00112             display.GotoXY(0,32);
00113             display.PrintString(" PC: ");        
00114             display.PrintNumber(rcv.FLOAT);
00115             display.PrintString("KW");
00116         }
00117     }   
00118 }
00119 
00120 void AMS2Screen()
00121 {
00122     screen=3;
00123     CANMessage Rxmsg;
00124     ftc rcv;
00125     rcv.FLOAT=0.0;
00126     
00127     display.ClearScreen();
00128     display.SelectFont(Arial12,BLACK,ReadData);
00129     
00130     if(CAN_Steering.read(Rxmsg))
00131     {   
00132         for(int i=0; i<4; i++)
00133                 rcv.C_FLOAT[i]=Rxmsg.data[i];
00134         if(Rxmsg.id == BATTERY_MIN_CELLVOLTAGE_ID)
00135         {
00136             display.GotoXY(0,0);
00137             display.PrintString(" Min Cell V:");
00138             display.PrintNumber(rcv.FLOAT);
00139             display.PrintString("V");
00140         }
00141         if(Rxmsg.id == BATTERY_MAX_CELLVOLTAGE_ID)
00142         {
00143             display.GotoXY(0,16);
00144             display.PrintString(" Max Cell V:");
00145             display.PrintNumber(rcv.FLOAT);
00146             display.PrintString("V");
00147         }
00148         if(Rxmsg.id == BATTERY_AVG_CELLVOLTAGE_ID)
00149         {
00150             display.GotoXY(0,32);
00151             display.PrintString(" Max Cell V:");
00152             display.PrintNumber(rcv.FLOAT);
00153             display.PrintString("V");
00154         }
00155     }   
00156 }
00157 
00158 void AMS3Screen()
00159 {
00160     screen=4;
00161     CANMessage Rxmsg;    
00162     ftc rcv;
00163     rcv.FLOAT=0.0;
00164     
00165     display.ClearScreen();
00166     display.SelectFont(Arial12,BLACK,ReadData);
00167     
00168     if(CAN_Steering.read(Rxmsg))
00169     {   
00170         for(int i=0; i<4; i++)
00171                 rcv.C_FLOAT[i]=Rxmsg.data[i];
00172         if(Rxmsg.id == BATTERY_MIN_CELLTEMPERATURE_ID)
00173         {
00174             display.GotoXY(0,0);
00175             display.PrintString(" Min Cell T:");
00176             display.PrintNumber(rcv.FLOAT);
00177             display.PrintString("deg");
00178         }
00179         if(Rxmsg.id == BATTERY_MAX_CELLTEMPERATURE_ID)
00180         {
00181             display.GotoXY(0,16);
00182             display.PrintString(" Max Cell T:");
00183             display.PrintNumber(rcv.FLOAT);
00184             display.PrintString("deg");
00185         }
00186         if(Rxmsg.id == BATTERY_AVG_CELLTEMPERATURE_ID)
00187         {
00188             display.GotoXY(0,32);
00189             display.PrintString(" Avg Cell T:");
00190             display.PrintNumber(rcv.FLOAT);
00191             display.PrintString("deg");
00192         }
00193     }   
00194 }
00195 
00196 void AMS4Screen()
00197 {
00198     screen =5;
00199     CANMessage Rxmsg;
00200     ftc rcv;
00201     
00202     display.ClearScreen();
00203     display.SelectFont(Arial12,BLACK,ReadData);
00204     
00205     if(CAN_Steering.read(Rxmsg))
00206     {   
00207         for(int i=0; i<4; i++)
00208                 rcv.C_FLOAT[i]=Rxmsg.data[i];
00209         if(Rxmsg.id == AMS_AIRS_ID)
00210         {
00211             display.GotoXY(0,0);
00212             display.PrintString(" AIRS: ");
00213             display.PrintString(rcv.C_FLOAT);
00214         }
00215         if(Rxmsg.id == AMS_PRECHARGING_ID)
00216         {
00217             display.GotoXY(0,16);
00218             display.PrintString(" Precharging: ");
00219             display.PrintString(rcv.C_FLOAT);
00220         }
00221     }   
00222 }
00223 */
00224 void ON()
00225 {
00226     char OnData[4]="ON";
00227     CANMessage Txmsg(101,OnData,sizeof(OnData));
00228     wait(0.1);
00229     
00230     display.ClearScreen();
00231     display.SelectFont(Arial12,BLACK,ReadData);
00232     display.GotoXY(16,16);
00233     display.PrintString(" ON    INITIATED");
00234     //screen=0;
00235     return;
00236 }
00237 
00238 void ResetCommand()
00239 {
00240     char ResetData[4]="RES";
00241     CANMessage Txmsg(102,ResetData,sizeof(ResetData));
00242     wait(0.1);
00243     
00244     display.ClearScreen();
00245     display.SelectFont(Arial12,BLACK,ReadData);
00246     display.GotoXY(16,16);
00247     display.PrintString(" RESET INITIATED");
00248     //screen=0;
00249     
00250     return;
00251 }
00252 
00253 void Init()
00254 {
00255     pc.baud(230400);
00256     CAN_Steering.frequency(500000);
00257 }
00258 
00259 int main()
00260 {
00261     Init();
00262     //int flag=1;
00263     wait(0.1);
00264     display.GotoXY(10,16);
00265     display.SelectFont(Arial_14,BLACK,ReadData);
00266     display.PrintString("Penn Electric Racing");
00267     display.GotoXY(20,32); 
00268     display.PrintString("Live The Dream");
00269     screen=0;
00270     wait(2);
00271     
00272     while(1)
00273     {
00274         if(biSWBL.read())
00275             HomeScreen();
00276         
00277         if(biSWTR.read())
00278             ON();
00279         
00280         if(biSWTL.read())
00281             ResetCommand();
00282         
00283         printf("SCreen:%d\n\r",screen);        
00284         wait(0.1);    
00285     }   
00286 }    
00287 
00288 /*
00289         else if(screen == 1)
00290             ShutdwnScreen();  
00291         else if(screen == 2)
00292             AMS1Screen();    
00293         else if(screen == 3)
00294             AMS2Screen();    
00295         else if(screen == 4)
00296             AMS3Screen();    
00297         else if(screen == 5)
00298             AMS4Screen();    
00299         */
00300         /*
00301         if(biSWBR.read())
00302         {
00303             if(screen == maxScreen)
00304                 screen=0;
00305             else    
00306                 ++screen;
00307             wait(1);
00308         }
00309         */