Kobo: Handle a few PowerCover quirks...

* The first few capacity reads after connecting to the cover may fail

* The PowerCover may trigger spurious move/add usb_plug uevent,
which translate into Charging events for us.
Instead of blindly lighting up the charging LED on those,
check if the device is actually charging, first.
This commit is contained in:
NiLuJe
2022-01-16 19:08:42 +01:00
committed by poire-z
parent 7018853940
commit eb0c2bfc93
5 changed files with 31 additions and 13 deletions

View File

@@ -387,7 +387,7 @@ local KoboIo = Kobo:new{
},
}
function Kobo:_refreshChargingLED()
function Kobo:setupChargingLED()
if G_reader_settings:nilOrTrue("enable_charging_led") then
if self:hasAuxBattery() and self.powerd:isAuxBatteryConnected() then
self:toggleChargingLED(self.powerd:isAuxCharging())
@@ -512,7 +512,7 @@ function Kobo:init()
-- We have no way of querying the current state of the charging LED, so, start from scratch.
-- Much like Nickel, start by turning it off.
self:toggleChargingLED(false)
self:_refreshChargingLED()
self:setupChargingLED()
-- Only enable a single core on startup
self:enableCPUCores(1)
@@ -888,7 +888,7 @@ function Kobo:resume()
end
-- A full suspend may have toggled the LED off.
self:_refreshChargingLED()
self:setupChargingLED()
end
function Kobo:saveSettings()