Skip to content

Commit 4fd9cbe

Browse files
authored
Virtual events (WiP) (#250)
Virtual events (WiP)
2 parents 7244e10 + 6afc979 commit 4fd9cbe

File tree

5 files changed

+25
-63
lines changed

5 files changed

+25
-63
lines changed

src/BF/bf.lua

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ assert(loadScript(radio.preLoad))()
99
assert(loadScript(protocol.transport))()
1010
assert(loadScript(SCRIPT_HOME.."/MSP/common.lua"))()
1111

12+
isTelemetryScript = false
13+
1214
local run_ui = assert(loadScript(SCRIPT_HOME.."/ui.lua"))()
1315

1416
return { run=run_ui }

src/SCRIPTS/BF/events.lua

-29
This file was deleted.

src/SCRIPTS/BF/radios.lua

+5-17
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,14 @@ local supportedPlatforms = {
3333

3434
local supportedRadios =
3535
{
36-
["x3"] = supportedPlatforms.x7,
37-
["x7"] = supportedPlatforms.x7,
38-
["x7s"] = supportedPlatforms.x7,
39-
["t12"] = supportedPlatforms.x7,
40-
["xlite"] = supportedPlatforms.x7,
41-
["xlites"] = supportedPlatforms.x7,
42-
["x9lite"] = supportedPlatforms.x7,
43-
["x9d"] = supportedPlatforms.x9,
44-
["x9d+"] = supportedPlatforms.x9,
45-
["x9d+2019"] = supportedPlatforms.x9,
46-
["x9e"] = supportedPlatforms.x9,
47-
["x10"] = supportedPlatforms.horus,
48-
["x10express"] = supportedPlatforms.horus,
49-
["x12s"] = supportedPlatforms.horus,
50-
["NV14"] = supportedPlatforms.nv14,
51-
["t16"] = supportedPlatforms.horus,
36+
["128x64"] = supportedPlatforms.x7,
37+
["212x64"] = supportedPlatforms.x9,
38+
["480x272"] = supportedPlatforms.horus,
39+
["320x480"] = supportedPlatforms.nv14,
5240
}
5341

5442
local ver, rad, maj, min, rev = getVersion()
55-
local radio = supportedRadios[rad]
43+
local radio = supportedRadios[tostring(LCD_W) .. "x" .. tostring(LCD_H)]
5644

5745
if not radio then
5846
error("Radio not supported: "..rad)

src/SCRIPTS/BF/ui.lua

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
local userEvent = assert(loadScript(SCRIPT_HOME.."/events.lua"))()
2-
31
local pageStatus =
42
{
53
display = 2,
@@ -302,22 +300,22 @@ function run_ui(event)
302300
-- process send queue
303301
mspProcessTxQ()
304302
-- navigation
305-
if (event == userEvent.longPress.menu) then -- Taranis QX7 / X9
303+
if isTelemetryScript and event == EVT_VIRTUAL_MENU_LONG then -- telemetry script
306304
menuActive = 1
307305
currentState = pageStatus.displayMenu
308-
elseif userEvent.press.pageDown and (event == userEvent.longPress.enter) then -- Horus
306+
elseif (not isTelemetryScript) and event == EVT_VIRTUAL_ENTER_LONG then -- standalone
309307
menuActive = 1
310308
killEnterBreak = 1
311309
currentState = pageStatus.displayMenu
312310
-- menu is currently displayed
313311
elseif currentState == pageStatus.displayMenu then
314-
if event == userEvent.release.exit then
312+
if event == EVT_VIRTUAL_EXIT then
315313
currentState = pageStatus.display
316-
elseif event == userEvent.release.plus or event == userEvent.dial.left then
314+
elseif event == EVT_VIRTUAL_PREV then
317315
incMenu(-1)
318-
elseif event == userEvent.release.minus or event == userEvent.dial.right then
316+
elseif event == EVT_VIRTUAL_NEXT then
319317
incMenu(1)
320-
elseif event == userEvent.release.enter then
318+
elseif event == EVT_VIRTUAL_ENTER then
321319
if killEnterBreak == 1 then
322320
killEnterBreak = 0
323321
else
@@ -327,30 +325,31 @@ function run_ui(event)
327325
end
328326
-- normal page viewing
329327
elseif currentState <= pageStatus.display then
330-
if event == userEvent.press.pageUp then
328+
if event == EVT_VIRTUAL_PREV_PAGE then
331329
incPage(-1)
332-
elseif event == userEvent.release.menu or event == userEvent.press.pageDown then
330+
killEvents(event) -- X10/T16 issue: pageUp is a long press
331+
elseif event == EVT_VIRTUAL_NEXT_PAGE or event == EVT_VIRTUAL_MENU then
333332
incPage(1)
334-
elseif event == userEvent.release.plus or event == userEvent.repeatPress.plus or event == userEvent.dial.left then
333+
elseif event == EVT_VIRTUAL_PREV or event == EVT_VIRTUAL_PREV_REPT then
335334
incLine(-1)
336-
elseif event == userEvent.release.minus or event == userEvent.repeatPress.minus or event == userEvent.dial.right then
335+
elseif event == EVT_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REPT then
337336
incLine(1)
338-
elseif event == userEvent.release.enter then
337+
elseif event == EVT_VIRTUAL_ENTER then
339338
local field = Page.fields[currentLine]
340339
local idx = field.i or currentLine
341340
if Page.values and Page.values[idx] and (field.ro ~= true) then
342341
currentState = pageStatus.editing
343342
end
344-
elseif event == userEvent.release.exit then
343+
elseif event == EVT_VIRTUAL_EXIT then
345344
return protocol.exitFunc();
346345
end
347346
-- editing value
348347
elseif currentState == pageStatus.editing then
349-
if (event == userEvent.release.exit) or (event == userEvent.release.enter) then
348+
if event == EVT_VIRTUAL_EXIT or event == EVT_VIRTUAL_ENTER then
350349
currentState = pageStatus.display
351-
elseif event == userEvent.press.plus or event == userEvent.repeatPress.plus or event == userEvent.dial.right then
350+
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
352351
incValue(1)
353-
elseif event == userEvent.press.minus or event == userEvent.repeatPress.minus or event == userEvent.dial.left then
352+
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
354353
incValue(-1)
355354
killEvents(event)
356355
end

src/SCRIPTS/TELEMETRY/bf.lua

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ assert(loadScript(radio.preLoad))()
99
assert(loadScript(protocol.transport))()
1010
assert(loadScript(SCRIPT_HOME.."/MSP/common.lua"))()
1111

12+
isTelemetryScript = true
13+
1214
local run_ui = assert(loadScript(SCRIPT_HOME.."/ui.lua"))()
1315
local background = assert(loadScript(SCRIPT_HOME.."/background.lua"))()
1416

0 commit comments

Comments
 (0)