Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMS periodic refresh when stick movement detected #420

Merged
merged 1 commit into from
Jan 11, 2022
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
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