mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_BatteryMoniter: fix mah to wah conversion
This commit is contained in:
parent
66bc673442
commit
8ea9803193
@ -232,13 +232,13 @@ void AP_BattMonitor_Backend::check_failsafe_types(bool &low_voltage, bool &low_c
|
|||||||
bool AP_BattMonitor_Backend::reset_remaining(float percentage)
|
bool AP_BattMonitor_Backend::reset_remaining(float percentage)
|
||||||
{
|
{
|
||||||
percentage = constrain_float(percentage, 0, 100);
|
percentage = constrain_float(percentage, 0, 100);
|
||||||
const float used_proportion = (100 - percentage) * 0.01;
|
const float used_proportion = (100.0f - percentage) * 0.01f;
|
||||||
_state.consumed_mah = used_proportion * _params._pack_capacity;
|
_state.consumed_mah = used_proportion * _params._pack_capacity;
|
||||||
// without knowing the history we can't do consumed_wh
|
// without knowing the history we can't do consumed_wh
|
||||||
// accurately. Best estimate is based on current voltage. This
|
// accurately. Best estimate is based on current voltage. This
|
||||||
// will be good when resetting the battery to a value close to
|
// will be good when resetting the battery to a value close to
|
||||||
// full charge
|
// full charge
|
||||||
_state.consumed_wh = _state.consumed_mah * 1000 * _state.voltage;
|
_state.consumed_wh = _state.consumed_mah * 0.001f * _state.voltage;
|
||||||
|
|
||||||
// reset failsafe state for this backend
|
// reset failsafe state for this backend
|
||||||
_state.failsafe = update_failsafes();
|
_state.failsafe = update_failsafes();
|
||||||
|
Loading…
Reference in New Issue
Block a user