AutoWarmth: force setWarmth after resume (#9289)

reviewable/pr9182/r5
zwim 2 years ago committed by GitHub
parent b70043b981
commit 05c586c4be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -201,9 +201,9 @@ function BasePowerD:fromNativeWarmth(nat_warmth)
end end
--- @note: Takes a warmth in the *KOReader* scale (i.e., [0, 100], *sic*) --- @note: Takes a warmth in the *KOReader* scale (i.e., [0, 100], *sic*)
function BasePowerD:setWarmth(warmth) function BasePowerD:setWarmth(warmth, force_setting)
if not self.device:hasNaturalLight() then return false end if not self.device:hasNaturalLight() then return false end
if warmth == self:frontlightWarmth() then return false end if not force_setting and warmth == self:frontlightWarmth() then return false end
-- Which means that fl_warmth is *also* in the KOReader scale (unlike fl_intensity) -- Which means that fl_warmth is *also* in the KOReader scale (unlike fl_intensity)
self.fl_warmth = self:normalizeWarmth(warmth) self.fl_warmth = self:normalizeWarmth(warmth)
local nat_warmth = self:toNativeWarmth(self.fl_warmth) local nat_warmth = self:toNativeWarmth(self.fl_warmth)

@ -136,7 +136,7 @@ end
AutoWarmth.onLeaveStandby = AutoWarmth.onResume AutoWarmth.onLeaveStandby = AutoWarmth.onResume
-- wrapper for unscheduling, so that only our setWarmth gets unscheduled -- wrapper for unscheduling, so that only our setWarmth gets unscheduled
function AutoWarmth.setWarmth(val) function AutoWarmth.setWarmth(val, force)
if val then if val then
if val > 100 then if val > 100 then
DeviceListener:onSetNightMode(true) DeviceListener:onSetNightMode(true)
@ -145,7 +145,7 @@ function AutoWarmth.setWarmth(val)
end end
if Device:hasNaturalLight() then if Device:hasNaturalLight() then
val = math.min(val, 100) val = math.min(val, 100)
Device.powerd:setWarmth(val) Device.powerd:setWarmth(val, force)
end end
end end
end end
@ -300,7 +300,7 @@ function AutoWarmth:scheduleWarmthChanges(time)
-- schedule setting of another valid warmth (=`next_warmth`) again (one time). -- schedule setting of another valid warmth (=`next_warmth`) again (one time).
-- On sane devices this schedule does no harm. -- On sane devices this schedule does no harm.
-- see https://github.com/koreader/koreader/issues/8363 -- see https://github.com/koreader/koreader/issues/8363
UIManager:scheduleIn(delay_time, self.setWarmth, next_warmth) UIManager:scheduleIn(delay_time, self.setWarmth, next_warmth, true)
end end
function AutoWarmth:hoursToClock(hours) function AutoWarmth:hoursToClock(hours)

Loading…
Cancel
Save