From 38fa6dcad5e9a59e85cc3bf912bd416eb31a25a1 Mon Sep 17 00:00:00 2001 From: Jan Liphardt Date: Fri, 7 Jul 2017 20:20:04 -0700 Subject: [PATCH] Clipping of the battery current due to Int*Float Note that Type buf_adc[i].am_data = int32_t, but everything else are floats. Suggest (float)(buf_adc[i].am_data), precisely as was done a few lines later for the voltage. --- src/modules/sensors/sensors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp index 4868c2715b..8577652969 100644 --- a/src/modules/sensors/sensors.cpp +++ b/src/modules/sensors/sensors.cpp @@ -489,7 +489,7 @@ Sensors::adc_poll(struct sensor_combined_s &raw) } } else if (ADC_BATTERY_CURRENT_CHANNEL == buf_adc[i].am_channel) { - bat_current_a = ((buf_adc[i].am_data * _parameters.battery_current_scaling) + bat_current_a = (((float)(buf_adc[i].am_data) * _parameters.battery_current_scaling) - _parameters.battery_current_offset) * _parameters.battery_a_per_v; #ifdef ADC_AIRSPEED_VOLTAGE_CHANNEL