2
0
mirror of https://github.com/koreader/koreader synced 2024-11-16 06:12:56 +00:00
koreader/frontend/device/pocketbook/powerd.lua

32 lines
936 B
Lua
Raw Normal View History

2015-01-17 15:54:49 +00:00
local BasePowerD = require("device/generic/powerd")
local ffi = require("ffi")
2016-02-15 09:33:48 +00:00
-- local inkview = ffi.load("inkview")
2015-01-17 15:54:49 +00:00
ffi.cdef[[
int IsCharging();
]]
local PocketBookPowerD = BasePowerD:new{
battCapacity = nil,
is_charging = nil,
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()
end
function PocketBookPowerD:getCapacityHW()
self.battCapacity = self:read_int_file(self.batt_capacity_file)
return self.battCapacity
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