Skip to content

Commit

Permalink
enhancements for android eink devices
Browse files Browse the repository at this point in the history
  • Loading branch information
pazos committed Jun 12, 2019
1 parent e6a1c51 commit 3b9c5c1
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions ffi/framebuffer_android.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local C = ffi.C
--[[ configuration for devices with an electric paper display controller ]]--

-- does the device has an e-ink screen?
local has_eink_screen = android.isEink()
local has_eink_screen, eink_platform = android.isEink()

-- does the device needs to handle all screen refreshes
local has_eink_full_support = android.isEinkFull()
Expand All @@ -15,9 +15,9 @@ local has_eink_full_support = android.isEinkFull()
local rk_full, rk_partial, rk_a2, rk_auto = 1, 2, 3, 4 -- luacheck: ignore

-- for *some* freescale devices
local ntx_du, ntx_gc16, ntx_regal, ntx_full = 1, 2, 7, 34 -- luacheck: ignore
local ntx_du, ntx_gc16, ntx_auto, ntx_regal, ntx_full = 1, 2, 5, 7, 34 -- luacheck: ignore

-- update only a region of the screen
-- update a region of the screen
local function updatePartial(mode, delay, x, y, w, h)
if not (x and y and w and h) then
x = 0
Expand All @@ -33,6 +33,23 @@ local function updatePartial(mode, delay, x, y, w, h)
android.einkUpdate(mode, delay, x, y, (x + w), (y + h))
end

-- update the entire screen
local function updateFull()
-- freescale ntx platform
if has_eink_screen and (eink_platform == "freescale") then
if has_eink_full_support then
-- we handle the screen entirely. Add a delay before a full update.
updatePartial(ntx_full, 50)
else
-- we're racing against system driver, update without delay to avoid artifacts
updatePartial(ntx_full, 0)
end
-- rockchip rk3x platform
elseif has_eink_screen and (eink_platform == "rockchip") then
android.einkUpdate(rk_full)
end
end

local framebuffer = {}

function framebuffer:init()
Expand Down Expand Up @@ -92,17 +109,13 @@ end

function framebuffer:refreshFullImp(x, y, w, h)
self:_updateWindow()
if has_eink_full_support then
updatePartial(ntx_full, 50, x, y, w, h)
elseif has_eink_screen then
android.einkUpdate(rk_full)
end
updateFull()
end

function framebuffer:refreshPartialImp(x, y, w, h)
self:_updateWindow()
if has_eink_full_support then
updatePartial(ntx_regal, 0, x, y, w, h)
updatePartial(ntx_auto, 0, x, y, w, h)
end
end

Expand All @@ -116,7 +129,7 @@ end
function framebuffer:refreshUIImp(x, y, w, h)
self:_updateWindow()
if has_eink_full_support then
updatePartial(ntx_regal, 0, x, y, w, h)
updatePartial(ntx_auto, 0, x, y, w, h)
end
end

Expand Down

0 comments on commit 3b9c5c1

Please sign in to comment.