Skip to content

Commit

Permalink
Virtual events (WiP) (#250)
Browse files Browse the repository at this point in the history
Virtual events (WiP)
  • Loading branch information
mikeller authored Oct 13, 2019
2 parents 7244e10 + 6afc979 commit 4fd9cbe
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 63 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.

22 changes: 5 additions & 17 deletions src/SCRIPTS/BF/radios.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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)
killEvents(event)
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 4fd9cbe

Please sign in to comment.