mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
4005bf69aa
Companion PR to https://github.com/koreader/koreader-base/pull/884 * Basically flags devices known to be stable when using PxP inversion. * Plus, random fix for #4870 ;). * A few FrontLight tweaks & cleanups on Kobo: * Moved the Kobo-specific startup status insanity to Kobo-specific init * Made turnOff/turnOn frontlight do a smooth ramp down/up * On Kobo, use turnOff/turnOn for suspend/resume, to get that smooth toggle * On Kobo, for NaturalLight w/ a mixer, only set warmth for setWarmth, and only set Brightness for setBrightness, otherwise, it tried to set both with not in-sync values, which made the FL widget jittery.
50 lines
1.0 KiB
Lua
50 lines
1.0 KiB
Lua
local BasePowerD = require("device/generic/powerd")
|
|
local ffi = require("ffi")
|
|
local inkview = ffi.load("inkview")
|
|
|
|
ffi.cdef[[
|
|
void OpenScreen();
|
|
int GetFrontlightState(void);
|
|
void SetFrontlightState(int flstate);
|
|
int GetBatteryPower();
|
|
int IsCharging();
|
|
]]
|
|
|
|
local PocketBookPowerD = BasePowerD:new{
|
|
is_charging = nil,
|
|
fl_min = 0,
|
|
fl_max = 100,
|
|
}
|
|
|
|
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
|
|
end
|
|
|
|
function PocketBookPowerD:getCapacityHW()
|
|
return inkview.GetBatteryPower()
|
|
end
|
|
|
|
function PocketBookPowerD:isChargingHW()
|
|
if inkview.IsCharging() > 0 then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
return PocketBookPowerD
|