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

26 lines
622 B
Lua
Raw Normal View History

local BasePowerD = require("device/generic/powerd")
local _, android = pcall(require, "android")
local AndroidPowerD = BasePowerD:new{
fl_min = 0, fl_max = 25,
fl_intensity = 10,
}
function AndroidPowerD:frontlightIntensityHW()
return math.floor(android.getScreenBrightness() / 255 * self.fl_max)
end
function AndroidPowerD:setIntensityHW(intensity)
2017-10-03 19:14:38 +00:00
android.setScreenBrightness(math.floor(255 * intensity / self.fl_max))
end
function AndroidPowerD:getCapacityHW()
return android.getBatteryLevel()
end
function AndroidPowerD:isChargingHW()
return android.isCharging()
end
return AndroidPowerD