2014-01-04 13:38:07 +00:00
|
|
|
local BasePowerD = require("ui/device/basepowerd")
|
|
|
|
|
|
|
|
local KoboPowerD = BasePowerD:new{
|
2014-03-13 13:52:43 +00:00
|
|
|
fl_min = 1, fl_max = 100,
|
|
|
|
flIntensity = 20,
|
|
|
|
restore_settings = true,
|
|
|
|
fl = nil,
|
|
|
|
|
|
|
|
batt_capacity_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity",
|
|
|
|
is_charging_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/charge_now",
|
|
|
|
battCapacity = nil,
|
|
|
|
is_charging = nil,
|
2014-01-04 13:38:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function KoboPowerD:init()
|
2014-06-04 13:38:12 +00:00
|
|
|
local ok, light = pcall(kobolight.open)
|
|
|
|
if ok then self.fl = light 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)
|
|
|
|
end
|
2014-01-04 13:38:07 +00:00
|
|
|
end
|
|
|
|
|
2014-05-02 14:06:18 +00:00
|
|
|
function KoboPowerD:setIntensitySW()
|
|
|
|
if self.fl ~= nil then
|
|
|
|
self.fl:restoreBrightness(self.flIntensity)
|
|
|
|
end
|
|
|
|
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()
|
2014-03-13 13:52:43 +00:00
|
|
|
self.is_charging = self:read_int_file(self.is_charging_file)
|
|
|
|
return self.is_charging == 1
|
2014-01-04 16:29:41 +00:00
|
|
|
end
|
|
|
|
|
2014-01-04 13:38:07 +00:00
|
|
|
return KoboPowerD
|