Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e360dd3

Browse files
committed
battery: make battery states not sticky
Signed-off-by: RomanBapst <[email protected]>
1 parent 1c30b10 commit e360dd3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/lib/battery/battery.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,17 @@ Battery::determineWarning(bool connected)
210210
{
211211
if (connected) {
212212
// propagate warning state only if the state is higher, otherwise remain in current warning state
213-
if (_remaining < _param_bat_emergen_thr.get() || (_warning == battery_status_s::BATTERY_WARNING_EMERGENCY)) {
213+
if (_remaining < _param_bat_emergen_thr.get()) {
214214
_warning = battery_status_s::BATTERY_WARNING_EMERGENCY;
215215

216-
} else if (_remaining < _param_bat_crit_thr.get() || (_warning == battery_status_s::BATTERY_WARNING_CRITICAL)) {
216+
} else if (_remaining < _param_bat_crit_thr.get()) {
217217
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
218218

219-
} else if (_remaining < _param_bat_low_thr.get() || (_warning == battery_status_s::BATTERY_WARNING_LOW)) {
219+
} else if (_remaining < _param_bat_low_thr.get()) {
220220
_warning = battery_status_s::BATTERY_WARNING_LOW;
221+
222+
} else {
223+
_warning = battery_status_s::BATTERY_WARNING_NONE;
221224
}
222225
}
223226
}

0 commit comments

Comments
 (0)