Skip to content

Commit

Permalink
Merge pull request #420 from klutvott123/cms-periodic-refresh
Browse files Browse the repository at this point in the history
CMS periodic refresh when stick movement detected
  • Loading branch information
haslinghuis authored Jan 11, 2022
2 parents da35504 + 56a88b1 commit 76b4beb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/SCRIPTS/BF/CMS/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ screen = {

cms = {
menuOpen = false,
synced = false,
init = function(cmsConfig)
screen.config = assert(cmsConfig, "Resolution not supported")
screen.reset()
screen.clear()
protocol.cms.close()
cms.menuOpen = false
cms.synced = false
end,
open = function()
protocol.cms.open(screen.config.rows, screen.config.cols)
Expand Down Expand Up @@ -112,6 +114,7 @@ cms = {
screen.buffer = cRleDecode(screen.data)
screen.draw()
screen.reset()
cms.synced = true
end
else
protocol.cms.refresh()
Expand Down
15 changes: 12 additions & 3 deletions src/SCRIPTS/BF/cms.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
lastMenuEventTime = 0
local lastMenuEventTime = 0
local INTERVAL = 80

local function init()
cms.init(radio)
end

local function stickMovement()
local threshold = 30
return math.abs(getValue('ele')) > threshold or math.abs(getValue('ail')) > threshold or math.abs(getValue('rud')) > threshold
end

local function run(event)
lastMenuEventTime = getTime()
if stickMovement() then
cms.synced = false
lastMenuEventTime = getTime()
end
cms.update()
if (cms.menuOpen == false) then
cms.open()
end
if (event == radio.refresh.event) then
if (event == radio.refresh.event) or (lastMenuEventTime + INTERVAL < getTime() and not cms.synced) then
cms.refresh()
end
if (event == EVT_VIRTUAL_EXIT) then
Expand Down

0 comments on commit 76b4beb

Please sign in to comment.