Skip to content

Commit

Permalink
Merge pull request #3131 from shellixyz/fix_current_reading
Browse files Browse the repository at this point in the history
Fix overflow in currentSensorToCentiamps()
  • Loading branch information
digitalentity authored Apr 27, 2018
2 parents 869d393 + bd65cc2 commit 969e8e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/sensors/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ uint16_t batteryAdcToVoltage(uint16_t src)

int32_t currentSensorToCentiamps(uint16_t src)
{
int32_t microvolts = ((uint32_t)src * ADCVREF * 1000) / 0xFFF - (int32_t)batteryConfig()->current.offset * 1000;
int32_t microvolts = ((uint32_t)src * ADCVREF * 100) / 0xFFF * 10 - (int32_t)batteryConfig()->current.offset * 1000;
return microvolts / batteryConfig()->current.scale; // current in 0.01A steps
}

Expand Down

0 comments on commit 969e8e2

Please sign in to comment.