AP_BattMonitor: reset failsafe flags when we reset battery remaining

This commit is contained in:
Andrew Tridgell 2019-06-19 10:14:46 +10:00
parent f28df4dff1
commit 88111ef81a
2 changed files with 15 additions and 0 deletions

View File

@ -501,10 +501,22 @@ void AP_BattMonitor::checkPoweringOff(void)
bool AP_BattMonitor::reset_remaining(uint16_t battery_mask, float percentage)
{
bool ret = true;
BatteryFailsafe highest_failsafe = BatteryFailsafe_None;
for (uint8_t i = 0; i < _num_instances; i++) {
if ((1U<<i) & battery_mask) {
ret &= drivers[i]->reset_remaining(percentage);
}
if (state[i].failsafe > highest_failsafe) {
highest_failsafe = state[i].failsafe;
}
}
// If all backends are not in failsafe then set overall failsafe state
if (highest_failsafe == BatteryFailsafe_None) {
_highest_failsafe_priority = INT8_MAX;
_has_triggered_failsafe = false;
// and reset notify flag
AP_Notify::flags.failsafe_battery = false;
}
return ret;
}

View File

@ -232,5 +232,8 @@ bool AP_BattMonitor_Backend::reset_remaining(float percentage)
// full charge
_state.consumed_wh = _state.consumed_mah * 1000 * _state.voltage;
// reset failsafe state for this backend
_state.failsafe = update_failsafes();
return true;
}