mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
add powerd for PocketBook device
This commit is contained in:
@@ -37,6 +37,17 @@ function BasePowerD:read_int_file(file)
|
||||
end
|
||||
end
|
||||
|
||||
function BasePowerD:read_str_file(file)
|
||||
local fd = io.open(file, "r")
|
||||
if fd then
|
||||
local str = fd:read("*all")
|
||||
fd:close()
|
||||
return str
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
function BasePowerD:setIntensity(intensity)
|
||||
intensity = intensity < self.fl_min and self.fl_min or intensity
|
||||
intensity = intensity > self.fl_max and self.fl_max or intensity
|
||||
|
||||
@@ -74,6 +74,7 @@ local PocketBook840 = PocketBook:new{
|
||||
|
||||
function PocketBook840:init()
|
||||
self.screen = require("ffi/framebuffer_mxcfb"):new{device = self, debug = DEBUG}
|
||||
self.powerd = require("device/pocketbook/powerd"):new{device = self}
|
||||
self.input = require("device/input"):new{
|
||||
device = self,
|
||||
event_map = {
|
||||
|
||||
31
frontend/device/pocketbook/powerd.lua
Normal file
31
frontend/device/pocketbook/powerd.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
local BasePowerD = require("device/generic/powerd")
|
||||
local ffi = require("ffi")
|
||||
local inkview = ffi.load("inkview")
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user