[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
reviewable/pr6669/r1
NiLuJe 4 years ago committed by GitHub
parent 2afec592f8
commit f1918cdfbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save