Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
CMS periodic refresh when stick movement detected
  • Loading branch information
klutvott123 committed Jan 10, 2022
commit 56a88b1fb75bf6fa0b3624d8ae5ef79ded2584b7
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