NOT WORKING initial kobo light support.

This commit is contained in:
Giorgio Micotti
2013-07-23 19:40:26 +02:00
parent ad4468aa4e
commit e4b8fc3266
3 changed files with 47 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ require "ui/device"
ReaderFrontLight = InputContainer:new{
steps = {0,1,2,3,4,5,6,7,8,9,10},
intensity = nil,
ld = nil,
}
function ReaderFrontLight:init()
@@ -13,20 +14,23 @@ function ReaderFrontLight:init()
if self.lipc_handle then
self.intensity = self.lipc_handle:get_int_property("com.lab126.powerd", "flIntensity")
end
self.ges_events = {
Adjust = {
GestureRange:new{
ges = "two_finger_pan",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
},
rate = 2.0,
}
},
}
end
if Device:isKobo() then
self.ld = kobolight.open()
end
self.ges_events = {
Adjust = {
GestureRange:new{
ges = "two_finger_pan",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
},
rate = 2.0,
}
},
}
end
function ReaderFrontLight:onAdjust(arg, ges)
@@ -57,5 +61,22 @@ function ReaderFrontLight:setIntensity(intensity, msg)
timeout = 1
})
end
if Device:isKobo() then
if self.ld == nil then
return true
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
end
self.ld:toggle()
end
return true
end