Skip to content

Commit

Permalink
Use virtual events
Browse files Browse the repository at this point in the history
- uses the screen resolution to determine the target.
- changes menu key mapping based on telemetry script vs standalone script.
  • Loading branch information
raphaelcoeffic committed Oct 9, 2019
1 parent fef1445 commit 6afc979
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 46 deletions.
2 changes: 2 additions & 0 deletions src/BF/bf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
29 changes: 0 additions & 29 deletions src/SCRIPTS/BF/events.lua

This file was deleted.

33 changes: 16 additions & 17 deletions src/SCRIPTS/BF/ui.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local userEvent = assert(loadScript(SCRIPT_HOME.."/events.lua"))()

local pageStatus =
{
display = 2,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/SCRIPTS/TELEMETRY/bf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"))()

Expand Down

0 comments on commit 6afc979

Please sign in to comment.