From fef14452f8ab28175a8fd6959e611f121f0b7fa8 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 6 Oct 2019 09:36:08 +0200 Subject: [PATCH 1/2] choose platform by screen resolution --- src/SCRIPTS/BF/radios.lua | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/SCRIPTS/BF/radios.lua b/src/SCRIPTS/BF/radios.lua index f4516acc..84cb77c3 100644 --- a/src/SCRIPTS/BF/radios.lua +++ b/src/SCRIPTS/BF/radios.lua @@ -33,26 +33,14 @@ local supportedPlatforms = { local supportedRadios = { - ["x3"] = supportedPlatforms.x7, - ["x7"] = supportedPlatforms.x7, - ["x7s"] = supportedPlatforms.x7, - ["t12"] = supportedPlatforms.x7, - ["xlite"] = supportedPlatforms.x7, - ["xlites"] = supportedPlatforms.x7, - ["x9lite"] = supportedPlatforms.x7, - ["x9d"] = supportedPlatforms.x9, - ["x9d+"] = supportedPlatforms.x9, - ["x9d+2019"] = supportedPlatforms.x9, - ["x9e"] = supportedPlatforms.x9, - ["x10"] = supportedPlatforms.horus, - ["x10express"] = supportedPlatforms.horus, - ["x12s"] = supportedPlatforms.horus, - ["NV14"] = supportedPlatforms.nv14, - ["t16"] = supportedPlatforms.horus, + ["128x64"] = supportedPlatforms.x7, + ["212x64"] = supportedPlatforms.x9, + ["480x272"] = supportedPlatforms.horus, + ["320x480"] = supportedPlatforms.nv14, } local ver, rad, maj, min, rev = getVersion() -local radio = supportedRadios[rad] +local radio = supportedRadios[tostring(LCD_W) .. "x" .. tostring(LCD_H)] if not radio then error("Radio not supported: "..rad) From 6afc979750002458db105ddb7a933df5551882b7 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 6 Oct 2019 09:36:28 +0200 Subject: [PATCH 2/2] Use virtual events - uses the screen resolution to determine the target. - changes menu key mapping based on telemetry script vs standalone script. --- src/BF/bf.lua | 2 ++ src/SCRIPTS/BF/events.lua | 29 ----------------------------- src/SCRIPTS/BF/ui.lua | 33 ++++++++++++++++----------------- src/SCRIPTS/TELEMETRY/bf.lua | 2 ++ 4 files changed, 20 insertions(+), 46 deletions(-) delete mode 100644 src/SCRIPTS/BF/events.lua diff --git a/src/BF/bf.lua b/src/BF/bf.lua index a61c46b2..eb4da1c0 100644 --- a/src/BF/bf.lua +++ b/src/BF/bf.lua @@ -9,6 +9,8 @@ assert(loadScript(radio.preLoad))() assert(loadScript(protocol.transport))() assert(loadScript(SCRIPT_HOME.."/MSP/common.lua"))() +isTelemetryScript = false + local run_ui = assert(loadScript(SCRIPT_HOME.."/ui.lua"))() return { run=run_ui } diff --git a/src/SCRIPTS/BF/events.lua b/src/SCRIPTS/BF/events.lua deleted file mode 100644 index eedecb76..00000000 --- a/src/SCRIPTS/BF/events.lua +++ /dev/null @@ -1,29 +0,0 @@ - -return -{ - press = { - minus = EVT_MINUS_FIRST, - plus = EVT_PLUS_FIRST, - pageDown = EVT_PAGEDN_FIRST, - pageUp = EVT_PAGEUP_FIRST or EVT_LEFT_BREAK - }, - longPress = { - enter = EVT_ENTER_LONG, - menu = EVT_MENU_LONG or EVT_RIGHT_LONG - }, - repeatPress = { - minus = EVT_MINUS_REPT, - plus = EVT_PLUS_REPT - }, - release = { - enter = EVT_ENTER_BREAK or EVT_ROT_BREAK, - exit = EVT_EXIT_BREAK, - menu = EVT_MENU_BREAK or EVT_RIGHT_BREAK, - minus = EVT_MINUS_BREAK, - plus = EVT_PLUS_BREAK - }, - dial = { - left = EVT_ROT_LEFT or EVT_UP_BREAK, - right = EVT_ROT_RIGHT or EVT_DOWN_BREAK - } -} diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index f61c7568..e4430fed 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -1,5 +1,3 @@ -local userEvent = assert(loadScript(SCRIPT_HOME.."/events.lua"))() - local pageStatus = { display = 2, @@ -302,22 +300,22 @@ function run_ui(event) -- process send queue mspProcessTxQ() -- navigation - if (event == userEvent.longPress.menu) then -- Taranis QX7 / X9 + if isTelemetryScript and event == EVT_VIRTUAL_MENU_LONG then -- telemetry script menuActive = 1 currentState = pageStatus.displayMenu - elseif userEvent.press.pageDown and (event == userEvent.longPress.enter) then -- Horus + elseif (not isTelemetryScript) and event == EVT_VIRTUAL_ENTER_LONG then -- standalone menuActive = 1 killEnterBreak = 1 currentState = pageStatus.displayMenu -- menu is currently displayed elseif currentState == pageStatus.displayMenu then - if event == userEvent.release.exit then + if event == EVT_VIRTUAL_EXIT then currentState = pageStatus.display - elseif event == userEvent.release.plus or event == userEvent.dial.left then + elseif event == EVT_VIRTUAL_PREV then incMenu(-1) - elseif event == userEvent.release.minus or event == userEvent.dial.right then + elseif event == EVT_VIRTUAL_NEXT then incMenu(1) - elseif event == userEvent.release.enter then + elseif event == EVT_VIRTUAL_ENTER then if killEnterBreak == 1 then killEnterBreak = 0 else @@ -327,30 +325,31 @@ function run_ui(event) end -- normal page viewing elseif currentState <= pageStatus.display then - if event == userEvent.press.pageUp then + if event == EVT_VIRTUAL_PREV_PAGE then incPage(-1) - elseif event == userEvent.release.menu or event == userEvent.press.pageDown then + killEvents(event) -- X10/T16 issue: pageUp is a long press + elseif event == EVT_VIRTUAL_NEXT_PAGE or event == EVT_VIRTUAL_MENU then incPage(1) - elseif event == userEvent.release.plus or event == userEvent.repeatPress.plus or event == userEvent.dial.left then + elseif event == EVT_VIRTUAL_PREV or event == EVT_VIRTUAL_PREV_REPT then incLine(-1) - elseif event == userEvent.release.minus or event == userEvent.repeatPress.minus or event == userEvent.dial.right then + elseif event == EVT_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REPT then incLine(1) - elseif event == userEvent.release.enter then + elseif event == EVT_VIRTUAL_ENTER then local field = Page.fields[currentLine] local idx = field.i or currentLine if Page.values and Page.values[idx] and (field.ro ~= true) then currentState = pageStatus.editing end - elseif event == userEvent.release.exit then + elseif event == EVT_VIRTUAL_EXIT then return protocol.exitFunc(); end -- editing value elseif currentState == pageStatus.editing then - if (event == userEvent.release.exit) or (event == userEvent.release.enter) then + if event == EVT_VIRTUAL_EXIT or event == EVT_VIRTUAL_ENTER then currentState = pageStatus.display - elseif event == userEvent.press.plus or event == userEvent.repeatPress.plus or event == userEvent.dial.right then + elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then incValue(1) - elseif event == userEvent.press.minus or event == userEvent.repeatPress.minus or event == userEvent.dial.left then + elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then incValue(-1) end end diff --git a/src/SCRIPTS/TELEMETRY/bf.lua b/src/SCRIPTS/TELEMETRY/bf.lua index 906ac8fa..1e2ea964 100644 --- a/src/SCRIPTS/TELEMETRY/bf.lua +++ b/src/SCRIPTS/TELEMETRY/bf.lua @@ -9,6 +9,8 @@ assert(loadScript(radio.preLoad))() assert(loadScript(protocol.transport))() assert(loadScript(SCRIPT_HOME.."/MSP/common.lua"))() +isTelemetryScript = true + local run_ui = assert(loadScript(SCRIPT_HOME.."/ui.lua"))() local background = assert(loadScript(SCRIPT_HOME.."/background.lua"))()