Koreader won't start on Kobo without frontlight, powerd.fl may be nil.

pull/1928/head
hzj-jie 8 years ago committed by Hzj_jie
parent 9a3e262bb3
commit d1e8b8098d

@ -117,22 +117,24 @@ end
-- restore kobo frontlight settings and probe kobo touch coordinates -- restore kobo frontlight settings and probe kobo touch coordinates
if Device:isKobo() then if Device:isKobo() then
local powerd = Device:getPowerDevice() if Device.hasFrontlight then
if powerd and powerd.restore_settings then local powerd = Device:getPowerDevice()
-- UIManager:init() should have sanely set up the frontlight_stuff by this point if powerd and powerd.restore_settings then
local intensity = G_reader_settings:readSetting("frontlight_intensity") -- UIManager:init() should have sanely set up the frontlight_stuff by this point
powerd.fl_intensity = intensity or powerd.fl_intensity local intensity = G_reader_settings:readSetting("frontlight_intensity")
local is_frontlight_on = G_reader_settings:readSetting("is_frontlight_on") powerd.fl_intensity = intensity or powerd.fl_intensity
if is_frontlight_on then local is_frontlight_on = G_reader_settings:readSetting("is_frontlight_on")
-- default powerd.is_fl_on is false, turn it on if is_frontlight_on then
powerd:toggleFrontlight() -- default powerd.is_fl_on is false, turn it on
else powerd:toggleFrontlight()
-- the light can still be turned on manually outside of koreader else
-- or nickel. so we always set the intensity to 0 here to keep it -- the light can still be turned on manually outside of koreader
-- in sync with powerd.is_fl_on (false by default) -- or nickel. so we always set the intensity to 0 here to keep it
-- NOTE: we cant use setIntensity method here because for kobo the -- in sync with powerd.is_fl_on (false by default)
-- min intensity is 1 :( -- NOTE: we cant use setIntensity method here because for kobo the
powerd.fl:setBrightness(0) -- min intensity is 1 :(
powerd.fl:setBrightness(0)
end
end end
end end
if Device:getCodeName() == "trilogy" then if Device:getCodeName() == "trilogy" then

Loading…
Cancel
Save