mirror of
https://github.com/koreader/koreader
synced 2024-11-11 19:11:14 +00:00
3066c86e38
This is a major overhaul of the hardware abstraction layer. A few notes: General platform distinction happens in frontend/device.lua which will delegate everything else to frontend/device/<platform_name>/device.lua which should extend frontend/device/generic/device.lua Screen handling is implemented in frontend/device/screen.lua which includes the *functionality* to support device specifics. Actually setting up the device specific functionality, however, is done in the device specific setup code in the relevant device.lua file. The same goes for input handling.
51 lines
1.2 KiB
Lua
51 lines
1.2 KiB
Lua
local BasePowerD = require("device/generic/powerd")
|
|
|
|
local KoboPowerD = BasePowerD:new{
|
|
fl_min = 0, fl_max = 100,
|
|
flIntensity = 20,
|
|
restore_settings = true,
|
|
fl = nil,
|
|
|
|
batt_capacity_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity",
|
|
is_charging_file = "/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/charge_now",
|
|
battCapacity = nil,
|
|
is_charging = nil,
|
|
}
|
|
|
|
function KoboPowerD:init()
|
|
local kobolight = require("ffi/kobolight")
|
|
local ok, light = pcall(kobolight.open)
|
|
if ok then self.fl = light end
|
|
end
|
|
|
|
function KoboPowerD:toggleFrontlight()
|
|
if self.fl ~= nil then
|
|
self.fl:toggle()
|
|
end
|
|
end
|
|
|
|
function KoboPowerD:setIntensityHW()
|
|
if self.fl ~= nil then
|
|
self.fl:setBrightness(self.flIntensity)
|
|
end
|
|
end
|
|
|
|
function KoboPowerD:setIntensitySW()
|
|
if self.fl ~= nil then
|
|
self.fl:restoreBrightness(self.flIntensity)
|
|
end
|
|
end
|
|
|
|
|
|
function KoboPowerD:getCapacityHW()
|
|
self.battCapacity = self:read_int_file(self.batt_capacity_file)
|
|
return self.battCapacity
|
|
end
|
|
|
|
function KoboPowerD:isChargingHW()
|
|
self.is_charging = self:read_int_file(self.is_charging_file)
|
|
return self.is_charging == 1
|
|
end
|
|
|
|
return KoboPowerD
|