Skip to content

Commit

Permalink
Fixed conversion of MPS to MPH
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanielDelgado committed Jun 2, 2024
1 parent bb76451 commit 4bdc5ca
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Apps/Src/ReadTritium.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ void Task_ReadTritium(void *p_arg){

//Car Velocity (in m/s) is in bytes 4-7
Motor_Velocity = *((float*)(&dataBuf.data[4]));
uint32_t Car_Velocity = Motor_Velocity;
float Car_Velocity = Motor_Velocity * 1000;

Car_Velocity = ((Car_Velocity * 100) * 3600); //Converting from m/s to m/h, using fixed point factor of 100
Car_Velocity = ((Car_Velocity / 160934) * 10); //Converting from m/h to mph, multiplying by 10 to make value "larger" for displaying
Car_Velocity = (Car_Velocity * 223694) / 10000000;

UpdateDisplay_SetVelocity(Car_Velocity);

Expand Down

0 comments on commit 4bdc5ca

Please sign in to comment.