pocketbook: inkview handling rework (#15087)

See koreader/koreader-base#2294.
This commit is contained in:
Benoit Pierre authored and GitHub committed 2026-03-21 21:38:30 +01:00
1 parent be68f1ca8c
commit 298ebf2b5f
3 files changed
+14 -16

No files matched your search

+1 -1
Submodule base updated: e86d84e1f9...1fc8aa2f40.
+2 -6
View File
@@ -4,14 +4,12 @@ local UIManager
local logger = require("logger")
local ffi = require("ffi")
local C = ffi.C
local inkview = ffi.load("inkview")
local inkview = require("ffi/inkview")
local band = require("bit").band
local util = require("util")
local _ = require("gettext")
require("ffi/posix_h")
require("ffi/linux_input_h")
require("ffi/inkview_h")
local function yes() return true end
local function no() return false end
@@ -363,10 +361,8 @@ function PocketBook:initNetworkManager(NetworkMgr)
UIManager:unschedule(keepWifiAlive)
if NetworkMgr:isWifiOn() then
-- check if NetMgrPing is available on the device and skip keepalive if not
if pcall(function() return inkview.NetMgrPing and true end) then
if C.POCKETBOOK_VERSION >= 508 then
logger.dbg("ping wifi keep alive and reschedule")
inkview.NetMgrPing()
UIManager:scheduleIn(30, keepWifiAlive)
else
+11 -9
View File
@@ -1,7 +1,8 @@
local BasePowerD = require("device/generic/powerd")
local ffi = require("ffi")
local inkview = ffi.load("inkview")
local inkview = require("ffi/inkview")
local logger = require("logger")
local C = ffi.C
local PocketBookPowerD = BasePowerD:new{
is_charging = nil,
@@ -31,18 +32,17 @@ function PocketBookPowerD:frontlightIntensity()
end
function PocketBookPowerD:setIntensityHW(intensity)
local v2api = pcall(function()
if C.POCKETBOOK_VERSION >= 519 then
inkview.SetFrontlightEnabled(intensity == 0 and 0 or 1)
end)
end
if intensity == 0 then
-- -1 is valid only for the old api, on newer firmwares that's just a bogus brightness level
if not v2api then
if C.POCKETBOOK_VERSION < 519 then
-- -1 is valid only for the old api, on newer firmwares that's just a bogus brightness level
inkview.SetFrontlightState(-1)
end
else
inkview.SetFrontlightState(intensity)
end
-- We have a custom isFrontlightOn implementation, so this is redundant
self:_decideFrontlightState()
end
@@ -50,10 +50,12 @@ end
function PocketBookPowerD:isFrontlightOn()
if not self.device:hasFrontlight() then return false end
-- Query directly instead of assuming from cached value.
local enabled = inkview.GetFrontlightState() >= 0
pcall(function()
local enabled
if C.POCKETBOOK_VERSION >= 519 then
enabled = inkview.GetFrontlightEnabled() > 0
end)
else
enabled = inkview.GetFrontlightState() >= 0
end
return enabled
end