From 68e63df442a414f851a639f630b80ad00d65db69 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Fri, 2 Mar 2018 23:03:00 +0100 Subject: [PATCH] [feat] Add H2O2 natural light (#3709) See https://www.mobileread.com/forums/showpost.php?p=3664352&postcount=66 --- frontend/device/kobo/device.lua | 6 ++++++ frontend/device/kobo/powerd.lua | 2 +- frontend/device/kobo/sysfs_light.lua | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua index 9c9406416..ead7e3a38 100644 --- a/frontend/device/kobo/device.lua +++ b/frontend/device/kobo/device.lua @@ -109,6 +109,12 @@ local KoboSnow = Kobo:new{ display_dpi = 265, -- the bezel covers the top 11 pixels: viewport = Geom:new{x=0, y=11, w=1080, h=1429}, + hasNaturalLight = yes, + frontlight_settings = { + frontlight_white = "/sys/class/backlight/lm3630a_ledb", + frontlight_red = "/sys/class/backlight/lm3630a_led", + frontlight_green = "/sys/class/backlight/lm3630a_leda", + }, } -- Kobo Aura second edition: diff --git a/frontend/device/kobo/powerd.lua b/frontend/device/kobo/powerd.lua index 9984927d1..c449ca6eb 100644 --- a/frontend/device/kobo/powerd.lua +++ b/frontend/device/kobo/powerd.lua @@ -97,7 +97,7 @@ function KoboPowerD:init() -- If this device has natural light (currently only KA1) -- use the SysFS interface, and ioctl otherwise. if self.device.hasNaturalLight() then - self.fl = SysfsLight + self.fl = SysfsLight:new(self.device.frontlight_settings) self.fl_warmth = 0 self:_syncKoboLightOnStart() else diff --git a/frontend/device/kobo/sysfs_light.lua b/frontend/device/kobo/sysfs_light.lua index 5559d2ee2..d524daa24 100644 --- a/frontend/device/kobo/sysfs_light.lua +++ b/frontend/device/kobo/sysfs_light.lua @@ -19,6 +19,14 @@ local KoboSysfsLight = { green_offset = -65, } +function KoboSysfsLight:new(o) + o = o or {} + setmetatable(o, self) + self.__index = self + if o.init then o:init() end + return o +end + function KoboSysfsLight:setBrightness(brightness) self:setNaturalBrightness(brightness, self.current_warmth) end