Skip to content

Commit 76b4beb

Browse files
authored
Merge pull request #420 from klutvott123/cms-periodic-refresh
CMS periodic refresh when stick movement detected
2 parents da35504 + 56a88b1 commit 76b4beb

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/SCRIPTS/BF/CMS/common.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ screen = {
7070

7171
cms = {
7272
menuOpen = false,
73+
synced = false,
7374
init = function(cmsConfig)
7475
screen.config = assert(cmsConfig, "Resolution not supported")
7576
screen.reset()
7677
screen.clear()
7778
protocol.cms.close()
7879
cms.menuOpen = false
80+
cms.synced = false
7981
end,
8082
open = function()
8183
protocol.cms.open(screen.config.rows, screen.config.cols)
@@ -112,6 +114,7 @@ cms = {
112114
screen.buffer = cRleDecode(screen.data)
113115
screen.draw()
114116
screen.reset()
117+
cms.synced = true
115118
end
116119
else
117120
protocol.cms.refresh()

src/SCRIPTS/BF/cms.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
lastMenuEventTime = 0
1+
local lastMenuEventTime = 0
2+
local INTERVAL = 80
23

34
local function init()
45
cms.init(radio)
56
end
67

8+
local function stickMovement()
9+
local threshold = 30
10+
return math.abs(getValue('ele')) > threshold or math.abs(getValue('ail')) > threshold or math.abs(getValue('rud')) > threshold
11+
end
12+
713
local function run(event)
8-
lastMenuEventTime = getTime()
14+
if stickMovement() then
15+
cms.synced = false
16+
lastMenuEventTime = getTime()
17+
end
918
cms.update()
1019
if (cms.menuOpen == false) then
1120
cms.open()
1221
end
13-
if (event == radio.refresh.event) then
22+
if (event == radio.refresh.event) or (lastMenuEventTime + INTERVAL < getTime() and not cms.synced) then
1423
cms.refresh()
1524
end
1625
if (event == EVT_VIRTUAL_EXIT) then

0 commit comments

Comments
 (0)