2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00
koreader/frontend/device/pocketbook/powerd.lua

50 lines
1.0 KiB
Lua
Raw Normal View History

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