2014-10-30 18:42:18 +00:00
|
|
|
local BasePowerD = require("device/generic/powerd")
|
2016-01-07 14:30:28 +00:00
|
|
|
local NickelConf = require("device/kobo/nickel_conf")
|
2014-01-04 13:38:07 +00:00
|
|
|
|
|
|
|
local KoboPowerD = BasePowerD:new{
|
2014-08-27 18:56:09 +00:00
|
|
|
fl_min = 0, fl_max = 100,
|
2014-03-13 13:52:43 +00:00
|
|
|
flIntensity = 20,
|
|
|
|
restore_settings = true,
|
|
|
|
fl = nil,
|
2014-10-03 08:11:53 +00:00
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
batt_capacity_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity",
|
2015-02-02 16:27:59 +00:00
|
|
|
is_charging_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/status",
|
2014-03-13 13:52:43 +00:00
|
|
|
battCapacity = nil,
|
|
|
|
is_charging = nil,
|
2014-01-04 13:38:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function KoboPowerD:init()
|
2014-12-02 10:15:23 +00:00
|
|
|
if self.device.hasFrontlight() then
|
|
|
|
local kobolight = require("ffi/kobolight")
|
|
|
|
local ok, light = pcall(kobolight.open)
|
|
|
|
if ok then self.fl = light end
|
|
|
|
end
|
2014-01-04 13:38:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function KoboPowerD:toggleFrontlight()
|
2014-03-13 13:52:43 +00:00
|
|
|
if self.fl ~= nil then
|
|
|
|
self.fl:toggle()
|
|
|
|
end
|
2014-01-04 13:38:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function KoboPowerD:setIntensityHW()
|
2014-03-13 13:52:43 +00:00
|
|
|
if self.fl ~= nil then
|
|
|
|
self.fl:setBrightness(self.flIntensity)
|
2016-01-07 14:30:28 +00:00
|
|
|
if KOBO_SYNC_BRIGHTNESS_WITH_NICKEL then
|
|
|
|
NickelConf.frontLightLevel.set(self.flIntensity)
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
end
|
2014-01-04 13:38:07 +00:00
|
|
|
end
|
|
|
|
|
2014-01-04 16:29:41 +00:00
|
|
|
function KoboPowerD:getCapacityHW()
|
2014-03-13 13:52:43 +00:00
|
|
|
self.battCapacity = self:read_int_file(self.batt_capacity_file)
|
|
|
|
return self.battCapacity
|
2014-01-04 16:29:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function KoboPowerD:isChargingHW()
|
2015-02-02 16:27:59 +00:00
|
|
|
self.is_charging = self:read_str_file(self.is_charging_file) == "Charging\n"
|
|
|
|
return self.is_charging
|
2014-01-04 16:29:41 +00:00
|
|
|
end
|
|
|
|
|
2014-01-04 13:38:07 +00:00
|
|
|
return KoboPowerD
|