sensors: fixed bug discharged battery current

This commit is contained in:
Anton Babushkin 2013-11-08 21:28:22 +04:00
parent 08b2c338f6
commit 697df775f9
1 changed files with 1 additions and 1 deletions

View File

@ -1189,7 +1189,7 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
if (_battery_status.timestamp != 0) {
_battery_status.current_a = (buf_adc[i].am_data * _parameters.battery_current_scaling);
float dt = fminf(20.0f, (hrt_absolute_time() - _last_adc) * 0.001f); // in ms, limit to 20ms
_battery_status.discharged_mah += _battery_status.current_a * dt;
_battery_status.discharged_mah += _battery_status.current_a * dt / 3600.0f;
}
} else if (ADC_AIRSPEED_VOLTAGE_CHANNEL == buf_adc[i].am_channel) {