mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[Kobo] Don't send a flood a FrontlightStateChanged events during the FL ramps (#6667)
* Only send a single FrontlightStateChanged event on toggle Prevents the ReaderFooter refresh from going wonky
This commit is contained in:
@@ -141,11 +141,11 @@ function BasePowerD:isCharging()
|
||||
return self:isChargingHW()
|
||||
end
|
||||
|
||||
function BasePowerD:_setIntensity(intensity)
|
||||
function BasePowerD:_setIntensity(intensity, silent)
|
||||
self:setIntensityHW(intensity)
|
||||
-- BasePowerD is loaded before UIManager. So we cannot broadcast events before UIManager has
|
||||
-- been loaded.
|
||||
if package.loaded["ui/uimanager"] ~= nil then
|
||||
-- BasePowerD is loaded before UIManager. So we cannot broadcast events before UIManager has been loaded.
|
||||
-- NOTE: If silent is set, inhibit the Event (useful for platforms that do a ramp-up/ramp-down on toggle).
|
||||
if not silent and package.loaded["ui/uimanager"] ~= nil then
|
||||
local Event = require("ui/event")
|
||||
local UIManager = require("ui/uimanager")
|
||||
UIManager:broadcastEvent(Event:new("FrontlightStateChanged"))
|
||||
|
||||
@@ -327,7 +327,8 @@ function KoboPowerD:turnOffFrontlightHW()
|
||||
end
|
||||
ffiUtil.runInSubProcess(function()
|
||||
for i = 1,5 do
|
||||
self:_setIntensity(math.floor(self.fl_intensity - ((self.fl_intensity / 5) * i)))
|
||||
-- NOTE: Make sure _setIntensity doesn't send a FrontlightStateChanged event for those!
|
||||
self:_setIntensity(math.floor(self.fl_intensity - ((self.fl_intensity / 5) * i)), true)
|
||||
--- @note: Newer devices appear to block slightly longer on FL ioctls/sysfs, so only sleep on older devices,
|
||||
--- otherwise we get a jump and not a ramp ;).
|
||||
if not self.device:hasNaturalLight() then
|
||||
@@ -366,7 +367,8 @@ function KoboPowerD:turnOnFrontlightHW()
|
||||
end
|
||||
ffiUtil.runInSubProcess(function()
|
||||
for i = 1,5 do
|
||||
self:_setIntensity(math.ceil(self.fl_min + ((self.fl_intensity / 5) * i)))
|
||||
-- NOTE: Make sure _setIntensity doesn't send a FrontlightStateChanged event for those!
|
||||
self:_setIntensity(math.ceil(self.fl_min + ((self.fl_intensity / 5) * i)), true)
|
||||
--- @note: Newer devices appear to block slightly longer on FL ioctls/sysfs, so only sleep on older devices,
|
||||
--- otherwise we get a jump and not a ramp ;).
|
||||
if not self.device:hasNaturalLight() then
|
||||
|
||||
Reference in New Issue
Block a user