@ -21,6 +21,7 @@ local KoboPowerD = BasePowerD:new{
fl_warmth = nil ,
auto_warmth = false ,
max_warmth_hour = 23 ,
fl_was_on = nil ,
}
-- TODO: Remove KOBO_LIGHT_ON_START
@ -148,8 +149,9 @@ function KoboPowerD:init()
-- Use setIntensity to ensure it sets fl_intensity, and because we don't want the ramping behavior of turnOn
self : setIntensity ( self : frontlightIntensityHW ( ) )
else
-- Use setIntensityHW so as *NOT* to set fl_intensity, so toggle will still work.
self : setIntensityHW ( 0 )
-- Use _setIntensity for setIntensityHW so as *NOT* to set fl_intensity, so toggle will still work,
-- plus the FrontlightStateChanged event.
self : _setIntensity ( 0 )
end
end
end
@ -293,7 +295,7 @@ function KoboPowerD:isChargingHW()
end
function KoboPowerD : turnOffFrontlightHW ( )
if self : isFrontlightOff ( ) then
if not self : isFrontlightOnHW ( ) then
return
end
local util = require ( " ffi/util " )
@ -308,9 +310,20 @@ function KoboPowerD:turnOffFrontlightHW()
end
end
end , false , true )
-- NOTE: This is essentially what _setIntensity does, except we don't actually touch the FL,
-- we only sync the state of the main process with the final state of what we're doing in the forks.
-- And update hw_intensity in our actual process ;).
self.hw_intensity = self.fl_min
self : _decideFrontlightState ( )
-- And let the footer know of the change
if package.loaded [ " ui/uimanager " ] ~= nil then
local Event = require ( " ui/event " )
local UIManager = require ( " ui/uimanager " )
UIManager : broadcastEvent ( Event : new ( " FrontlightStateChanged " ) )
end
end
function KoboPowerD : turnOnFrontlightHW ( )
if self : isFrontlightOn ( ) then
if self : isFrontlightOn HW ( ) then
return
end
local util = require ( " ffi/util " )
@ -324,11 +337,24 @@ function KoboPowerD:turnOnFrontlightHW()
end
end
end , false , true )
-- NOTE: This is essentially what _setIntensity does, except we don't actually touch the FL,
-- we only sync the state of the main process with the final state of what we're doing in the forks.
-- And update hw_intensity in our actual process ;).
self.hw_intensity = self.fl_intensity
self : _decideFrontlightState ( )
-- And let the footer know of the change
if package.loaded [ " ui/uimanager " ] ~= nil then
local Event = require ( " ui/event " )
local UIManager = require ( " ui/uimanager " )
UIManager : broadcastEvent ( Event : new ( " FrontlightStateChanged " ) )
end
end
-- Turn off front light before suspend.
function KoboPowerD : beforeSuspend ( )
if self.fl == nil then return end
-- Remember the current frontlight state
self.fl_was_on = self : isFrontlightOnHW ( )
-- Turn off the frontlight
self : turnOffFrontlight ( )
end
@ -336,6 +362,8 @@ end
-- Restore front light state after resume.
function KoboPowerD : afterResume ( )
if self.fl == nil then return end
-- Don't bother if the light was already off on suspend
if not self.fl_was_on then return end
-- Update AutoWarmth state
if self.fl_warmth ~= nil and self.auto_warmth then
self : calculateAutoWarmth ( )