From 7e2aa2a209c882d4b270bcc53c5ea69e159a8eac Mon Sep 17 00:00:00 2001 From: zwim <36999612+zwim@users.noreply.github.com> Date: Fri, 8 Apr 2022 12:18:23 +0200 Subject: [PATCH] Kobo powerd: fix frequency in battery's getCapacity with enabled standby (#8958) --- frontend/device/generic/powerd.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/frontend/device/generic/powerd.lua b/frontend/device/generic/powerd.lua index e81b6548b..2ea487a39 100644 --- a/frontend/device/generic/powerd.lua +++ b/frontend/device/generic/powerd.lua @@ -212,16 +212,16 @@ end function BasePowerD:getCapacity() -- BasePowerD is loaded before UIManager. -- Nothing *currently* calls this before UIManager is actually loaded, but future-proof this anyway. - local now_ts + local now_btv if UIManager then - now_ts = UIManager:getTime() + now_btv = UIManager:getElapsedTimeSinceBoot() else - now_ts = TimeVal:now() + now_btv = TimeVal:now() + self.device.total_standby_tv -- Add time the device was in standby end - if (now_ts - self.last_capacity_pull_time):tonumber() >= 60 then + if (now_btv - self.last_capacity_pull_time):tonumber() >= 60 then self.batt_capacity = self:getCapacityHW() - self.last_capacity_pull_time = now_ts + self.last_capacity_pull_time = now_btv end return self.batt_capacity end @@ -231,19 +231,20 @@ function BasePowerD:isCharging() end function BasePowerD:getAuxCapacity() - local now_ts + local now_btv + if UIManager then - now_ts = UIManager:getTime() + now_btv = UIManager:getElapsedTimeSinceBoot() else - now_ts = TimeVal:now() + now_btv = TimeVal:now() + self.device.total_standby_tv -- Add time the device was in standby end - if (now_ts - self.last_aux_capacity_pull_time):tonumber() >= 60 then + if (now_btv - self.last_aux_capacity_pull_time):tonumber() >= 60 then local aux_batt_capa = self:getAuxCapacityHW() -- If the read failed, don't update our cache, and retry next time. if aux_batt_capa then self.aux_batt_capacity = aux_batt_capa - self.last_aux_capacity_pull_time = now_ts + self.last_aux_capacity_pull_time = now_btv end end return self.aux_batt_capacity