From be64da3bda0ec81f21bceac9da6ab580451e8eb1 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 9 Jun 2020 21:15:36 +0200 Subject: [PATCH] battery: Prioritize full-at over state (#2019) * Prioritize battery full-at over state The `full-at` option should take priority over the charging state of the battery. Closes #1622 (issue for Thinkpad laptops) * Remove typo from clamp_percentage --- src/modules/battery.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 4b52fbcf..a3f57739 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -286,12 +286,12 @@ namespace modules { * Get the current battery state */ battery_module::state battery_module::current_state() { - if (!read(*m_state_reader)) { - return battery_module::state::DISCHARGING; - } else if (read(*m_capacity_reader) < m_fullat) { - return battery_module::state::CHARGING; - } else { + if (read(*m_capacity_reader) >= m_fullat) { return battery_module::state::FULL; + } else if (!read(*m_state_reader)) { + return battery_module::state::DISCHARGING; + } else { + return battery_module::state::CHARGING; } }