From bd65cc2f019997426089927cda2a055403157735 Mon Sep 17 00:00:00 2001 From: Michel Pastor Date: Fri, 27 Apr 2018 22:09:28 +0200 Subject: [PATCH] Fix overflow in currentSensorToCentiamps() --- src/main/sensors/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/sensors/battery.c b/src/main/sensors/battery.c index 99094e8bdfb..21e742479d9 100644 --- a/src/main/sensors/battery.c +++ b/src/main/sensors/battery.c @@ -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 }