@@ -204,7 +204,7 @@ int main(void) {
204204 taskCreate (pedalsPeriodic , 15 );
205205 taskCreate (handleDashboardInputs , 50 );
206206 taskCreate (heartBeatTask , 100 );
207- taskCreate (sendShockpots , 15 );
207+ taskCreate (sendShockpots , PERIOD_SHOCK_FRONT_MS );
208208 taskCreate (sendVersion , 5000 );
209209 taskCreate (interpretLoadSensor , 15 );
210210 taskCreate (updateTelemetryPages , 200 );
@@ -284,17 +284,20 @@ void sendVersion() {
284284 * Converts raw ADC values from left and right shock potentiometers into parsed displacement values
285285 * and sends them through CAN bus. Values are scaled linearly and adjusted for droop.
286286 */
287- int16_t shock_l_parsed ;
288- int16_t shock_r_parsed ;
287+ int16_t shock_l_scaled ;
288+ int16_t shock_r_scaled ;
289289
290290void sendShockpots () {
291291 uint16_t shock_l = raw_adc_values .shock_left ;
292292 uint16_t shock_r = raw_adc_values .shock_right ;
293293
294294 // Will scale linearly from 0 - 3744. so 75 - (percent of 3744 * 75)
295- shock_l_parsed = -1 * ((POT_MAX_DIST - (int16_t )((shock_l / (POT_VOLT_MIN_L - POT_VOLT_MAX_L )) * POT_MAX_DIST )) - POT_DIST_DROOP_L );
296- shock_r_parsed = -1 * ((POT_MAX_DIST - (int16_t )((shock_r / (POT_VOLT_MIN_R - POT_VOLT_MAX_R )) * POT_MAX_DIST )) - POT_DIST_DROOP_R );
297- SEND_SHOCK_FRONT (shock_l_parsed , shock_r_parsed );
295+ float shock_l_parsed = -1.0 * ((POT_MAX_DIST - ((shock_l / (POT_VOLT_MIN_L - POT_VOLT_MAX_L )) * POT_MAX_DIST )) - POT_DIST_DROOP_L );
296+ float shock_r_parsed = -1.0 * ((POT_MAX_DIST - ((shock_r / (POT_VOLT_MIN_R - POT_VOLT_MAX_R )) * POT_MAX_DIST )) - POT_DIST_DROOP_R );
297+
298+ shock_l_scaled = (int16_t )(shock_l_parsed * SCALE_INV_SHOCK_FRONT_LEFT_SHOCK );
299+ shock_r_scaled = (int16_t )(shock_r_parsed * SCALE_INV_SHOCK_FRONT_RIGHT_SHOCK );
300+ SEND_SHOCK_FRONT (shock_l_scaled , shock_r_scaled );
298301}
299302
300303// jose was here
0 commit comments