battery: only propagate warning state in upwards

This commit is contained in:
Dennis Mannhart 2017-06-26 10:05:02 +02:00
parent f9b8afc006
commit 115e7246b0
1 changed files with 4 additions and 4 deletions

View File

@ -225,14 +225,14 @@ void
Battery::determineWarning(bool connected)
{
if (connected) {
// Smallest values must come first
if (_remaining < _param_emergency_thr.get()) {
// propagate warning state only if the state is higher, otherwise remain in current waringin state
if (_remaining < _param_emergency_thr.get() || (_warning == battery_status_s::BATTERY_WARNING_EMERGENCY)) {
_warning = battery_status_s::BATTERY_WARNING_EMERGENCY;
} else if (_remaining < _param_crit_thr.get()) {
} else if (_remaining < _param_crit_thr.get() || (_warning == battery_status_s::BATTERY_WARNING_CRITICAL)) {
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
} else if (_remaining < _param_low_thr.get()) {
} else if (_remaining < _param_low_thr.get() || (_warning == battery_status_s::BATTERY_WARNING_LOW)) {
_warning = battery_status_s::BATTERY_WARNING_LOW;
}
}