mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Fix some dumb mistakes, toggle light now works
This commit is contained in:
@@ -4,7 +4,7 @@ require "ui/device"
|
||||
ReaderFrontLight = InputContainer:new{
|
||||
steps = {0,1,2,3,4,5,6,7,8,9,10},
|
||||
intensity = nil,
|
||||
ld = nil,
|
||||
fl = nil,
|
||||
}
|
||||
|
||||
function ReaderFrontLight:init()
|
||||
@@ -30,7 +30,8 @@ function ReaderFrontLight:init()
|
||||
}
|
||||
end
|
||||
if Device:isKobo() then
|
||||
self.ld = kobolight.open()
|
||||
self.fl = kobolight.open()
|
||||
self.intensity = 20
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,21 +65,25 @@ function ReaderFrontLight:setIntensity(intensity, msg)
|
||||
})
|
||||
end
|
||||
if Device:isKobo() then
|
||||
if self.ld == nil then
|
||||
return true
|
||||
if self.fl == nil then
|
||||
ReaderFrontLight:init()
|
||||
end
|
||||
if self.fl ~= nil then
|
||||
self.fl:setBrightness(intensity)
|
||||
self.intensity = intensity
|
||||
end
|
||||
self.intensity = intensity
|
||||
self.ld:setBrightness(intensity)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderFrontLight:toggle()
|
||||
if Device:isKobo() then
|
||||
if self.ld == nil then
|
||||
return true
|
||||
if self.fl == nil then
|
||||
ReaderFrontLight:init()
|
||||
end
|
||||
if self.fl ~= nil then
|
||||
self.fl:toggle()
|
||||
end
|
||||
self.ld:toggle()
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user