From a153286f447b830aeceb05f3d40ae98e398f5f73 Mon Sep 17 00:00:00 2001 From: Markismus Date: Fri, 2 May 2014 16:06:18 +0200 Subject: [PATCH] Kobo Frontlight Tweaks Now the frontlight remains unchanged from Nickel to koreader and vice versa. Also ffi/kobolight.lua has been changed to allow for usage of the toggle button in the filemanager. --- frontend/ui/device/basepowerd.lua | 9 +++++++++ frontend/ui/device/kobopowerd.lua | 7 +++++++ reader.lua | 7 ++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/ui/device/basepowerd.lua b/frontend/ui/device/basepowerd.lua index 2ce343b24..af36cbdf6 100644 --- a/frontend/ui/device/basepowerd.lua +++ b/frontend/ui/device/basepowerd.lua @@ -20,6 +20,7 @@ end function BasePowerD:init() end function BasePowerD:toggleFrontlight() end function BasePowerD:setIntensityHW() end +function BasePowerD:setIntensitySW() end function BasePowerD:getCapacityHW() end function BasePowerD:isChargingHW() end function BasePowerD:suspendHW() end @@ -39,6 +40,14 @@ function BasePowerD:setIntensity(intensity) self:setIntensityHW() end +function BasePowerD:setIntensityWithoutHW(intensity) + intensity = intensity < self.fl_min and self.fl_min or intensity + intensity = intensity > self.fl_max and self.fl_max or intensity + self.flIntensity = intensity + self:setIntensitySW() +end + + function BasePowerD:getCapacity() if capacity_pulled_count == capacity_cached_count then capacity_pulled_count = 0 diff --git a/frontend/ui/device/kobopowerd.lua b/frontend/ui/device/kobopowerd.lua index fef464d17..5ed20dc9b 100644 --- a/frontend/ui/device/kobopowerd.lua +++ b/frontend/ui/device/kobopowerd.lua @@ -28,6 +28,13 @@ function KoboPowerD:setIntensityHW() end end +function KoboPowerD:setIntensitySW() + if self.fl ~= nil then + self.fl:restoreBrightness(self.flIntensity) + end +end + + function KoboPowerD:getCapacityHW() self.battCapacity = self:read_int_file(self.batt_capacity_file) return self.battCapacity diff --git a/reader.lua b/reader.lua index ba6d3c939..bca6fc3ee 100755 --- a/reader.lua +++ b/reader.lua @@ -1,8 +1,8 @@ #!./koreader-base require "defaults" -package.path = "./frontend/?.lua;./?.lua" -package.cpath = "?.so;/usr/lib/lua/?.so" +package.path = "?.lua;common/?.lua;frontend/?.lua" +package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so" local DocSettings = require("docsettings") local _ = require("gettext") @@ -184,7 +184,8 @@ do if powerd and powerd.restore_settings then local intensity = G_reader_settings:readSetting("frontlight_intensity") intensity = intensity or powerd.flIntensity - powerd:setIntensity(intensity) + powerd:setIntensityWithoutHW(intensity) + -- powerd:setIntensity(intensity) end end