2015-01-17 15:54:49 +00:00
|
|
|
local BasePowerD = require("device/generic/powerd")
|
|
|
|
local ffi = require("ffi")
|
2017-10-03 12:59:41 +00:00
|
|
|
local inkview = ffi.load("inkview")
|
2015-01-17 15:54:49 +00:00
|
|
|
|
|
|
|
ffi.cdef[[
|
2017-10-03 12:59:41 +00:00
|
|
|
void OpenScreen();
|
|
|
|
int GetFrontlightState(void);
|
|
|
|
void SetFrontlightState(int flstate);
|
2017-10-22 15:49:48 +00:00
|
|
|
int GetBatteryPower();
|
|
|
|
int IsCharging();
|
2015-01-17 15:54:49 +00:00
|
|
|
]]
|
|
|
|
|
|
|
|
local PocketBookPowerD = BasePowerD:new{
|
|
|
|
is_charging = nil,
|
2017-10-03 12:59:41 +00:00
|
|
|
fl_min = 0,
|
|
|
|
fl_max = 100,
|
2015-01-17 15:54:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function PocketBookPowerD:init()
|
2017-10-03 12:59:41 +00:00
|
|
|
-- 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
|
2015-01-17 15:54:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function PocketBookPowerD:getCapacityHW()
|
2017-10-22 15:49:48 +00:00
|
|
|
return inkview.GetBatteryPower()
|
2015-01-17 15:54:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function PocketBookPowerD:isChargingHW()
|
2017-10-22 15:49:48 +00:00
|
|
|
if inkview.IsCharging() > 0 then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
2015-01-17 15:54:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return PocketBookPowerD
|