From 56a88b1fb75bf6fa0b3624d8ae5ef79ded2584b7 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Mon, 10 Jan 2022 20:53:18 +0100 Subject: [PATCH] CMS periodic refresh when stick movement detected --- src/SCRIPTS/BF/CMS/common.lua | 3 +++ src/SCRIPTS/BF/cms.lua | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/SCRIPTS/BF/CMS/common.lua b/src/SCRIPTS/BF/CMS/common.lua index 6c1f7033..b562fedd 100644 --- a/src/SCRIPTS/BF/CMS/common.lua +++ b/src/SCRIPTS/BF/CMS/common.lua @@ -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) @@ -112,6 +114,7 @@ cms = { screen.buffer = cRleDecode(screen.data) screen.draw() screen.reset() + cms.synced = true end else protocol.cms.refresh() diff --git a/src/SCRIPTS/BF/cms.lua b/src/SCRIPTS/BF/cms.lua index 15ca3395..364bf054 100644 --- a/src/SCRIPTS/BF/cms.lua +++ b/src/SCRIPTS/BF/cms.lua @@ -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