smartel99

bug TSO-S4-Projet

May 8th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.35 KB | None | 0 0
  1. while(1) // in main()
  2.   {
  3.     Stabby->GereLeMode(); // This is where the cpu determines what to do
  4.                           // (if it should move or not, according to the data received by rs232)
  5.     // Some non-related stuff
  6.  
  7.     if(semaphoreAffiche == MAIN_REQUETE_ACTIVE) // If it should update the screen (at around every seconds or so)
  8.     {
  9.       semaphoreAffiche = MAIN_REQUETE_TRAITEE;  // Don't enter again
  10.       Stabby->UpdateTension();                  // Updates the battery's voltage
  11.      
  12.       // Updates other stuff and refresh the LCD display, not causing any problem
  13.     }
  14.   }
  15.  
  16. void Vehicule::UpdateTension(void) // Method that updates the variables containing the status of the battery
  17. {
  18.   Vehicule::TensionVolt = (iLectureChanel1236(BATTERIE)/1000) * 3; // Gets the voltage in a 0-12V range
  19.  
  20.   Vehicule::TensionPourcentage = (unsigned char)(Vehicule::TensionVolt * 100 / 12); // Convert the float into a pourcentage of
  21.                                                                                     //remaining life of the battery (sorry if that
  22.                                                                                     //comment makes no sense)
  23. }
  24.  
  25. void Vehicule::UpdateDac(void) // Method that sends the data to the 4 channels of the DAC
  26. {
  27.    vI2CEcrireInt6574(CONFIGURE0DAC6574, Moteur_ARG);
  28.    vI2CEcrireInt6574(CONFIGURE1DAC6574, Moteur_ARD);
  29.    vI2CEcrireInt6574(CONFIGURE2DAC6574, Moteur_AVG);
  30.    vI2CEcrireInt6574(CONFIGURE3DAC6574, Moteur_AVD);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment