2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00

Final fixes for kobo suspend

This commit is contained in:
Giorgio Micotti 2013-09-30 21:48:46 +02:00
parent afd4a2d920
commit a2ff9b9a9b
2 changed files with 17 additions and 22 deletions

View File

@ -152,18 +152,16 @@ function Device:outofScreenSaver()
self.screen_saver_mode = false
end
function Device:Suspend()
UIManager:show(InfoMessage:new{
text = _("Standby"),
timeout = 4,
})
Screen:refresh(0)
function Device:prepareSuspend()
local fl = self:getFrontlight()
if fl ~= nil then
fl:sleep()
fl.fl:sleep()
end
util.usleep(1500000)
Screen:refresh(0)
self.screen_saver_mode = true
end
function Device:Suspend()
os.execute("./kobo_suspend.sh")
end
@ -173,19 +171,11 @@ function Device:Resume()
Screen:refresh(0)
local fl = self:getFrontlight()
if fl ~= nil then
fl:resume()
fl.fl:restore()
end
self.screen_saver_mode = false
end
function Device:Power()
if self.screen_saver_mode == true then
self:Resume()
else
self:Suspend()
end
end
function Device:usbPlugIn()
--os.execute("echo 'usb in' >> /mnt/us/event_test.txt")
if self.charging_mode == false and self.screen_saver_mode == false then

View File

@ -293,11 +293,16 @@ function UIManager:run()
Device:usbPlugOut()
elseif input_event == "Light" then
Device:getFrontlight():toggle()
elseif input_event == "Power" then
Device:Power()
elseif input_event == "Suspend" then
Device:Suspend()
elseif input_event == "Resume" then
elseif (input_event == "Power" and not Device.screen_saver_mode) or
input_event == "Suspend" then
UIManager:show(InfoMessage:new{
text = _("Standby"),
timeout = 1,
})
Device:prepareSuspend()
UIManager:scheduleIn(0.5, function() Device:Suspend() end)
elseif (input_event == "Power" and Device.screen_saver_mode) or
input_event == "Resume" then
Device:Resume()
else
self:sendEvent(input_event)