Files
koreader/frontend/device/pocketbook/powerd.lua
Fabian Müller-Knapp 7d81aa5cf4 [feat] Pocketbook840 enable frontlight (#3294)
* Detect PocketBook840 by GetSoftwareVersion()

* implement Frontlight-support for 840 via inkview
2017-10-03 14:59:41 +02:00

49 lines
1.4 KiB
Lua

local BasePowerD = require("device/generic/powerd")
local ffi = require("ffi")
local inkview = ffi.load("inkview")
ffi.cdef[[
void OpenScreen();
int GetFrontlightState(void);
void SetFrontlightState(int flstate);
]]
local PocketBookPowerD = BasePowerD:new{
is_charging = nil,
fl_min = 0,
fl_max = 100,
batt_capacity_file = "/sys/devices/platform/sun5i-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/battery/capacity",
is_charging_file = "/sys/devices/platform/sun5i-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/battery/status",
}
function PocketBookPowerD:init()
-- needed for SetFrontlightState / GetFrontlightState
inkview.OpenScreen()
end
function PocketBookPowerD:frontlightIntensityHW()
if not self.device.hasFrontlight() then return 0 end
return inkview.GetFrontlightState()
end
function PocketBookPowerD:setIntensityHW(intensity)
if intensity == 0 then
inkview.SetFrontlightState(-1)
else
inkview.SetFrontlightState(intensity)
end
end
function PocketBookPowerD:getCapacityHW()
return self:read_int_file(self.batt_capacity_file)
end
function PocketBookPowerD:isChargingHW()
self.is_charging = self:read_str_file(self.is_charging_file)
return self.is_charging == "Charging"
-- or we can query using SDK method `IsCharging`
--return inkview.IsCharging() == 1
end
return PocketBookPowerD