Skip to content
12 changes: 12 additions & 0 deletions docs/Configuration-Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@

![sample](https://raw.githubusercontent.com/iNavFlight/LuaTelemetry/master/assets/iNavConfigHorus.png "Horus config menu")

### EdgeTX 3.0 and above
_Entering the setup menu_
To enter the configuration settings for a Lua script on newer version of EdgeTX:
* Ensure the script is set to run in "app mode"
* Long press the scroll wheel until the blue "EdgeTX" icon in the upper left disappears
* Press the Sys button

_Exiting the setup mode_
* Press RTN to exit Lua configuration menu
* Long press the TN button until the blue EdgeTX icon appears at top left
* You can then use the Page buttons to swap between screens

### Other radios

The following applies generically to all non-Colour (B&W) / small screen radios:
Expand Down
13 changes: 11 additions & 2 deletions docs/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@ Don't be too concerned about the length of these instructions. The first two sec
1. In model setup, page to `DISPLAY`
1. Set desired screen to `Script`
1. Select `iNav`
* Horus/Jumper T16:
* Horus/Jumper T16 (EdgeTX before v2.11):
1. Long-press `TELE` to access the user interface/views layout
1. Select the desired view (or create a new one)
1. Make `Layout` full screen, turn off `Top bar` and `Sliders+Trims`
1. Select `Setup widgets`
1. Press `Enter` till a menu appears and select `Select widget`
1. Scroll to the `iNav` widget and press `Enter`
1. Optionally (while still selecting the `iNAV` script), long-press `Enter`, select `Widget settings` where you can enable `Restore` (to restore your theme's colors) and set your theme's `Text` color and `Warning` color
1. Optionally (while still selecting the `iNAV` script), long-press `Enter`, select `Widget settings` where you can set your theme's `Text` color and `Warning` color
* RadioMaster TX16S and other color touchscreen radios (EdgeTX v2.11+):
1. Long-press `TELE` to access the user interface/views layout
1. Select the desired view (or create a new one)
1. Choose the `App Mode` layout (not `Full screen`) — this allows the widget to receive key and touch events and automatically hides the top bar and sliders/trims
1. Long-press `Enter` (jog wheel) — it may take more than one long-press for the widget selection menu to appear
1. Select `Select widget`, scroll to `iNav` and press `Enter`
1. Optionally, long-press `Enter`, select `Widget settings` to set your theme's `Text` color and `Warning` color
1. Press `RTN` to exit setup
1. After a reboot, you may need to long-press the jog wheel or long-touch the screen to re-enter app mode (events are not passed to the widget until app mode is active)
* Nirvana NV14:
1. Press the Widgets icon
1. Select the desired view
Expand Down
55 changes: 53 additions & 2 deletions src/SCRIPTS/TELEMETRY/iNav.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local FILE_PATH = "/SCRIPTS/TELEMETRY/iNav/"
local SMLCD = LCD_W < 212
local HORUS = LCD_W >= 480 or LCD_H >= 480
local TX15 = LCD_W == 480 and LCD_H == 320
local TX16S = LCD_W >= 800 and LCD_H >= 480
local tmp, view, lang, playLog
local env = "bt" -- compile on platform
local inav = {}
Expand Down Expand Up @@ -454,7 +455,7 @@ function inav.background()
data.bkgd = true
end

function inav.run(event)
function inav.run(event, touchState)
--[[ Show FPS
data.start = getTime()
]]
Expand Down Expand Up @@ -494,6 +495,56 @@ function inav.run(event)
end
]]

-- Touch event handling (TX16S and other touchscreen radios)
-- Must run before config menu check so touch works in both menu and views
if TX16S and touchState and event ~= nil and event ~= 0 then
if event == EVT_TOUCH_TAP then
if data.configStatus > 0 then
-- In config menu: tap to select row or toggle edit
local tapped = data.configTop + math.floor((touchState.y - 37) / 22)
if tapped >= 1 and tapped <= #config and tapped ~= data.configStatus then
data.configStatus = tapped
data.configSelect = 0
event = 0
else
event = EVT_ENTER_BREAK
end
elseif touchState.y < 277 then
-- Tap on upper area: toggle max/min values
if not data.armed then
data.showMax = not data.showMax
end
data.showDir = not data.showDir
event = 0
else
-- Tap on data area: enter config menu
event = MENU
end
elseif event == EVT_TOUCH_SLIDE then
if touchState.swipeUp then
event = EVT_VIRTUAL_NEXT
elseif touchState.swipeDown then
event = EVT_VIRTUAL_PREV
elseif touchState.slideY then
-- Accumulate drag distance for continuous scroll
data.touchAccumY = (data.touchAccumY or 0) + touchState.slideY
if data.touchAccumY > 30 then
event = EVT_VIRTUAL_NEXT
data.touchAccumY = 0
elseif data.touchAccumY < -30 then
event = EVT_VIRTUAL_PREV
data.touchAccumY = 0
else
event = 0
end
else
event = 0
end
else
event = 0
end
end

-- Config menu or views
if data.configStatus > 0 then
if data.v ~= 9 then
Expand Down Expand Up @@ -538,7 +589,7 @@ function inav.run(event)
if data.v ~= config[25].v then
view = nil
collectgarbage()
view = loadScript(FILE_PATH .. (HORUS and (TX15 and "tx15" or (data.nv and "nirvana" or "horus")) or (config[25].v == 0 and "view" or (config[25].v == 1 and "pilot" or (config[25].v == 2 and "radar" or "alt")))) .. ext, env)()
view = loadScript(FILE_PATH .. (HORUS and (TX16S and "tx16s" or (TX15 and "tx15" or (data.nv and "nirvana" or "horus"))) or (config[25].v == 0 and "view" or (config[25].v == 1 and "pilot" or (config[25].v == 2 and "radar" or "alt")))) .. ext, env)()
data.v = config[25].v
end
view(data, config, modes, dir, units, labels, gpsDegMin, hdopGraph, icons, calcBearing, calcDir, VERSION, SMLCD, FILE_PATH, text, line, rect, fill, frmt)
Expand Down
1 change: 1 addition & 0 deletions src/SCRIPTS/TELEMETRY/iNav/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ local config = {
{ o = 26, c = 1, v = 0 }, -- Roll Scale - 33
{ o = 34, c = 1, v = 0, l = {[0] = "?"}, x = -1 }, -- Review Log Date - 34
{ o = 35, c = 1, v = 0 }, -- Greyscale toggle - 35
{ o = 36, c = 1, v = 0 }, -- Horizon Mode - 36
}

for i = 1, #config do
Expand Down
49 changes: 42 additions & 7 deletions src/SCRIPTS/TELEMETRY/iNav/horus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap

-- Draw ground
local gflag = data.set_flags(0, GROUND)
if skip then
local fixedHorizon = config[36] ~= nil and config[36].v == 1
if fixedHorizon then
-- Fixed horizon: flat ground below center
fill(tl.x, Y_CNTR, br.x - tl.x + 1, br.y - Y_CNTR + 1, gflag)
line(tl.x, Y_CNTR, br.x, Y_CNTR, SOLID, data.set_flags(0, LIGHTGREY))
elseif skip then
-- Must be going down hard!
if (pitch - 90) * (upsideDown and -1 or 1) < 0 then
fill(tl.x, tl.y, br.x - tl.x + 1, br.y - tl.y + 1, gflag)
Expand Down Expand Up @@ -237,10 +242,12 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap
-- Pitch ladder
if data.telem then
tmp = pitch - 90
local tmp2 = max(min((tmp >= 0 and floor(tmp * 0.2) or math.ceil(tmp * 0.2)) * 5, 30), -30)
for x = tmp2 - 20, tmp2 + 20, 5 do
if x ~= 0 and (x % 10 == 0 or (x > -30 and x < 30)) then
pitchLadder(x % 10 == 0 and 20 or 15, x)
if not fixedHorizon then
local tmp2 = max(min((tmp >= 0 and floor(tmp * 0.2) or math.ceil(tmp * 0.2)) * 5, 30), -30)
for x = tmp2 - 20, tmp2 + 20, 5 do
if x ~= 0 and (x % 10 == 0 or (x > -30 and x < 30)) then
pitchLadder(x % 10 == 0 and 20 or 15, x)
end
end
end

Expand Down Expand Up @@ -324,8 +331,36 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap
end
end

-- View overlay
bmap(icons.fg, 1, 20)
-- View overlay / aircraft symbol
if fixedHorizon then
-- Fixed horizon mode: aircraft symbol moves with pitch/roll
local py = Y_CNTR - (pitch - 90) * DEGV / 90
py = max(TOP + 10, min(BOTTOM - 10, py))
local r = rad(roll - 90)
local s, c = sin(r), cos(r)
local wing = 40
local gap = 8
local ycol = data.set_flags(0, OYELLOW)
local oc = data.set_flags(0, BLACK)
-- Wing bars: perpendicular-offset lines for thickness (5px: 3 yellow + 2 black outline)
for d = -2, 2 do
local col = (d > -2 and d < 2) and ycol or oc
local ox, oy = -s * d, c * d
line(X_CNTR - c * wing + ox, py + s * wing + oy, X_CNTR - c * gap + ox, py + s * gap + oy, SOLID, col)
line(X_CNTR + c * gap + ox, py - s * gap + oy, X_CNTR + c * wing + ox, py - s * wing + oy, SOLID, col)
end
-- Tail (points up from center when level)
local tail = 15
for d = -1, 1 do
local col = d == 0 and ycol or oc
line(X_CNTR, py + d, X_CNTR - s * tail, py - c * tail + d, SOLID, col)
end
-- Center dot
fill(X_CNTR - 2, py - 2, 5, 5, oc)
fill(X_CNTR - 1, py - 1, 3, 3, ycol)
else
bmap(icons.fg, 1, 20)
end

-- Speed & altitude
tmp = data.showMax and data.speedMax or data.speed
Expand Down
1 change: 1 addition & 0 deletions src/SCRIPTS/TELEMETRY/iNav/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ local function view(data, config, units, lang, event, gpsDegMin, getTelemetryId,
{ t = "Roll Scale", l = 1 }, -- 33
{ t = "Playback Log", l = config[34].l }, -- 34
{ t = "Greyscale Gfx", l = {[0] = "On", "Off"} }, -- 35
{ t = "Horizon Mode", l = {[0] = "Standard", "Fixed"} }, -- 36
}

-- Import language changes
Expand Down
49 changes: 42 additions & 7 deletions src/SCRIPTS/TELEMETRY/iNav/nirvana.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap

-- Draw ground
local gflag = data.set_flags(0, GROUND)
if skip then
local fixedHorizon = config[36] ~= nil and config[36].v == 1
if fixedHorizon then
-- Fixed horizon: flat ground below center
fill(tl.x, Y_CNTR, br.x - tl.x + 1, br.y - Y_CNTR + 1, gflag)
line(tl.x, Y_CNTR, br.x, Y_CNTR, SOLID, data.set_flags(0, LIGHTGREY))
elseif skip then
-- Must be going down hard!
if (pitch - 90) * (upsideDown and -1 or 1) < 0 then
fill(tl.x, tl.y, br.x - tl.x + 1, br.y - tl.y + 1, gflag)
Expand Down Expand Up @@ -239,10 +244,12 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap
-- Pitch ladder
if data.telem then
tmp = pitch - 90
local tmp2 = max(min((tmp >= 0 and floor(tmp * 0.2) or math.ceil(tmp * 0.2)) * 5, 30), -30)
for x = tmp2 - 20, tmp2 + 20, 5 do
if x ~= 0 and (x % 10 == 0 or (x > -30 and x < 30)) then
pitchLadder(x % 10 == 0 and 20 or 15, x)
if not fixedHorizon then
local tmp2 = max(min((tmp >= 0 and floor(tmp * 0.2) or math.ceil(tmp * 0.2)) * 5, 30), -30)
for x = tmp2 - 20, tmp2 + 20, 5 do
if x ~= 0 and (x % 10 == 0 or (x > -30 and x < 30)) then
pitchLadder(x % 10 == 0 and 20 or 15, x)
end
end
end
if not data.showMax then
Expand Down Expand Up @@ -323,8 +330,36 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap
end
end

-- View overlay
bmap(icons.fg, 1, 20)
-- View overlay / aircraft symbol
if fixedHorizon then
-- Fixed horizon mode: aircraft symbol moves with pitch/roll
local py = Y_CNTR - (pitch - 90) * DEGV / 90
py = max(TOP + 10, min(BOTTOM - 10, py))
local r = rad(roll - 90)
local s, c = sin(r), cos(r)
local wing = 35
local ycol = data.set_flags(0, OYELLOW)
local oc = data.set_flags(0, BLACK)
-- Rotated wings (with black outline, perpendicular thickness)
local gap = 8
for d = -2, 2 do
local col = (d > -2 and d < 2) and ycol or oc
local ox, oy = -s * d, c * d
line(X_CNTR - c * wing + ox, py + s * wing + oy, X_CNTR - c * gap + ox, py + s * gap + oy, SOLID, col)
line(X_CNTR + c * gap + ox, py - s * gap + oy, X_CNTR + c * wing + ox, py - s * wing + oy, SOLID, col)
end
-- Tail
local tail = 15
for d = -1, 1 do
local col = (d == 0) and ycol or oc
line(X_CNTR, py + d, X_CNTR - s * tail, py - c * tail + d, SOLID, col)
end
-- Center dot
fill(X_CNTR - 2, py - 2, 5, 5, oc)
fill(X_CNTR - 1, py - 1, 3, 3, ycol)
else
bmap(icons.fg, 1, 20)
end
--line(0, BOTTOM, RIGHT_POS, BOTTOM, SOLID, DKGREY)
line(0, BOTTOM + 1, RIGHT_POS, BOTTOM + 1, SOLID, data.set_flags(0, MAP))
local telemCol = (data.telem) and data.TextColor or RED
Expand Down
Loading
Loading