From 448ff4855d6e1adf83a0b1c844f868d451ee6e1c Mon Sep 17 00:00:00 2001 From: Jonathan Hudson Date: Sun, 19 Jan 2025 16:54:31 +0000 Subject: [PATCH] replace legacy escaped characters for EdgeTX (and OpenTX) --- src/SCRIPTS/TELEMETRY/iNav/alt.lua | 8 +++++--- src/SCRIPTS/TELEMETRY/iNav/func_t.lua | 5 +++-- src/SCRIPTS/TELEMETRY/iNav/pilot.lua | 11 +++++++---- src/SCRIPTS/TELEMETRY/iNav/radar.lua | 17 ++++++++++++----- src/SCRIPTS/TELEMETRY/iNav/view.lua | 8 ++++++-- 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/SCRIPTS/TELEMETRY/iNav/alt.lua b/src/SCRIPTS/TELEMETRY/iNav/alt.lua index 47dae2e..942db7d 100644 --- a/src/SCRIPTS/TELEMETRY/iNav/alt.lua +++ b/src/SCRIPTS/TELEMETRY/iNav/alt.lua @@ -6,6 +6,8 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap local FLASH = 3 -- legacy value local gpsFlags = SMLSIZE + RIGHT + ((not data.telem or not data.gpsFix) and FLASH or 0) local tmp, pitch + local SHOWMAX = data.etx and CHAR_UP or "\192" + local DEGSYM = data.etx and "°" or "@" -- Startup message if data.startup == 2 then @@ -55,7 +57,7 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap end -- Min/Max if not data.showDir and data.showMax then - text(RIGHT_POS, 9, "\192", SMLSIZE + RIGHT) + text(RIGHT_POS, 9, SHOWMAX, SMLSIZE + RIGHT) end if data.startup == 0 then @@ -85,7 +87,7 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap if not SMLCD and data.telem then if data.showDir or data.headingRef == -1 then text(LEFT_POS + 12, 29, dir[0], SMLSIZE) - text(LEFT_POS + 25 - (data.heading < 100 and 3 or 0) - (data.heading < 10 and 3 or 0), 57, math.floor(data.heading + 0.5) % 360 .. "\64", SMLSIZE + RIGHT + telemFlag) + text(LEFT_POS + 25 - (data.heading < 100 and 3 or 0) - (data.heading < 10 and 3 or 0), 57, math.floor(data.heading + 0.5) % 360 .. DEGSYM, SMLSIZE + RIGHT + telemFlag) tmp = data.heading else tmp = data.heading - data.headingRef @@ -191,7 +193,7 @@ end --Pitch line(LEFT_DIV, 50, LEFT_POS, 50, SOLID, FORCE) text(LEFT_DIV + 5, 54, pitch > 0 and "\194" or (pitch == 0 and "->" or "\195"), SMLSIZE) - text(LEFT_POS, 53, "\64", SMLSIZE + RIGHT + telemFlag) + text(LEFT_POS, 53, DEGSYM, SMLSIZE + RIGHT + telemFlag) text(LEFT_POS - 4, 52, pitch, MIDSIZE + RIGHT + telemFlag) end end diff --git a/src/SCRIPTS/TELEMETRY/iNav/func_t.lua b/src/SCRIPTS/TELEMETRY/iNav/func_t.lua index 532ad70..b6eab5a 100644 --- a/src/SCRIPTS/TELEMETRY/iNav/func_t.lua +++ b/src/SCRIPTS/TELEMETRY/iNav/func_t.lua @@ -56,8 +56,9 @@ local function title() end local function gpsDegMin(c, lat) - local gpsD = math.floor(math.abs(c)) - return gpsD .. frmt("\64%05.2f", (math.abs(c) - gpsD) * 60) .. (lat and (c >= 0 and dir[0] or dir[4]) or (c >= 0 and dir[2] or dir[6])) + local DEGSYM = data.etx and "°" or "@" + local gpsD = math.floor(math.abs(c)) + return gpsD .. frmt(DEGSYM .. "%05.2f", (math.abs(c) - gpsD) * 60) .. (lat and (c >= 0 and dir[0] or dir[4]) or (c >= 0 and dir[2] or dir[6])) end local function hdopGraph(x, y, s, SMLCD) diff --git a/src/SCRIPTS/TELEMETRY/iNav/pilot.lua b/src/SCRIPTS/TELEMETRY/iNav/pilot.lua index a4a7e43..50822ca 100644 --- a/src/SCRIPTS/TELEMETRY/iNav/pilot.lua +++ b/src/SCRIPTS/TELEMETRY/iNav/pilot.lua @@ -8,6 +8,9 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap local FLASH = 3 -- legacy value local gpsFlags = SMLSIZE + RIGHT + ((not data.telem or not data.gpsFix) and FLASH or 0) local tmp, pitch, roll, roll1, upsideDown + local DEGSYM = data.etx and "°" or "@" + local SHOWMAX = data.etx and CHAR_UP or "\192" + local SHOWMIN = data.etx and CHAR_DOWN or "\193" local function pitchLadder(r, adj) --[[ Caged mode @@ -109,7 +112,7 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap end if not data.showMax then tmp2 = tmp >= 0 and (tmp < 1 and 0 or math.floor(tmp + 0.5)) or (tmp > -1 and 0 or math.ceil(tmp - 0.5)) - text(X_CNTR - (SMLCD and 14 or 24), 33, math.abs(tmp2) .. (SMLCD and "" or "\64"), SMLSIZE + RIGHT) + text(X_CNTR - (SMLCD and 14 or 24), 33, math.abs(tmp2) .. (SMLCD and "" or DEGSYM), SMLSIZE + RIGHT) end end @@ -129,8 +132,8 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap icons.home(home, tmp) end elseif data.showMax then - text(LEFT_POS + 21, 33, "\192", SMLSIZE) - text(RIGHT_POS - 22, 33, "\192", SMLSIZE + RIGHT) + text(LEFT_POS + 21, 33, SHOWMAX, SMLSIZE) + text(RIGHT_POS - 22, 33, SHOWMAX, SMLSIZE + RIGHT) end -- Heading part 1 @@ -262,7 +265,7 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap line(X_CNTR - 9, 56, X_CNTR + 10, 56, SOLID, ERASE) line(X_CNTR - 10, 56, X_CNTR - 10, 63, SOLID, ERASE) text(X_CNTR - 9, 57, " ", SMLSIZE + telemFlag) - text(X_CNTR + 11, 57, math.floor(data.heading + 0.5) % 360 .. "\64", SMLSIZE + RIGHT + telemFlag) + text(X_CNTR + 11, 57, math.floor(data.heading + 0.5) % 360 .. DEGSYM, SMLSIZE + RIGHT + telemFlag) if not SMLCD then lcd.drawRectangle(X_CNTR - 11, 55, 23, 10, FORCE) end diff --git a/src/SCRIPTS/TELEMETRY/iNav/radar.lua b/src/SCRIPTS/TELEMETRY/iNav/radar.lua index 4f1b1d9..36d9643 100644 --- a/src/SCRIPTS/TELEMETRY/iNav/radar.lua +++ b/src/SCRIPTS/TELEMETRY/iNav/radar.lua @@ -7,6 +7,13 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap local X_CNTR = (RIGHT_POS + LEFT_POS) * 0.5 - 1 local gpsFlags = SMLSIZE + RIGHT + ((not data.telem or not data.gpsFix) and FLASH or 0) local tmp, pitch + local DEGSYM = data.etx and "°" or "@" + local SHOWMAX = data.etx and CHAR_UP or "\192" + local SHOWMIN = data.etx and CHAR_DOWN or "\193" + + -- May not be right .... + local SHOWLEFT = data.etx and CHAR_LEFT or "\194" + local SHOWRIGHT = data.etx and CHAR_RIGHT or "\195" -- Startup message if data.startup == 2 then @@ -51,18 +58,18 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap end -- Pitch if data.startup == 0 then - text(LEFT_POS + 15, 17, pitch .. (math.abs(pitch) < 10 and "\64" or ""), SMLSIZE + RIGHT + telemFlag) + text(LEFT_POS + 15, 17, pitch .. (math.abs(pitch) < 10 and DEGSYM or ""), SMLSIZE + RIGHT + telemFlag) line(LEFT_POS + 1, 17, LEFT_POS + 1, 24, SOLID, ERASE) else text(LEFT_POS + 2, 17, "Ptch", SMLSIZE) end elseif data.showDir or data.headingRef == -1 then -- Heading - text(X_CNTR + 14 - (data.heading < 100 and 3 or 0) - (data.heading < 10 and 3 or 0), 57, math.floor(data.heading + 0.5) % 360 .. "\64", SMLSIZE + RIGHT + telemFlag) + text(X_CNTR + 14 - (data.heading < 100 and 3 or 0) - (data.heading < 10 and 3 or 0), 57, math.floor(data.heading + 0.5) % 360 .. DEGSYM, SMLSIZE + RIGHT + telemFlag) end -- Min/Max if not data.showDir and data.showMax then - text(RIGHT_POS, 9, "\192", SMLSIZE + RIGHT) + text(RIGHT_POS, 9, SHOWMAX, SMLSIZE + RIGHT) end -- Radar @@ -204,8 +211,8 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap text(LEFT_POS - tmp2, 37, tmp < 1000 and math.floor(tmp + 0.5) or frmt("%.1f", tmp / (data.dist_unit == 9 and 1000 or 5280)), MIDSIZE + RIGHT + telemFlag) --Pitch line(LEFT_DIV, 50, LEFT_POS, 50, SOLID, FORCE) - text(LEFT_DIV + 5, 54, pitch > 0 and "\194" or (pitch == 0 and "->" or "\195"), SMLSIZE) - text(LEFT_POS, 53, "\64", SMLSIZE + RIGHT + telemFlag) + text(LEFT_DIV + 5, 54, pitch > 0 and SHOWLEFT or (pitch == 0 and "->" or SHOWRIGHT), SMLSIZE) + text(LEFT_POS, 53, DEGSYM, SMLSIZE + RIGHT + telemFlag) text(LEFT_POS - 4, 52, pitch, MIDSIZE + RIGHT + telemFlag) end end diff --git a/src/SCRIPTS/TELEMETRY/iNav/view.lua b/src/SCRIPTS/TELEMETRY/iNav/view.lua index 2b358a4..0be2c51 100644 --- a/src/SCRIPTS/TELEMETRY/iNav/view.lua +++ b/src/SCRIPTS/TELEMETRY/iNav/view.lua @@ -6,6 +6,10 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap local X_CNTR_2 = SMLCD and 63 or 104 local tmp local FLASH = 3 -- legacy constant (wtf??) + local SHOWMAX = data.etx and CHAR_UP or "\192" + local SHOWMIN = data.etx and CHAR_DOWN or "\193" + local DEGSYM = data.etx and "°" or "@" + local function drawDirection(h, w, r, x, y) local r1 = math.rad(h) local r2 = math.rad(h + w) @@ -24,7 +28,7 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap if data.showMax and d > 0 then vc = vm text(0, y, string.sub(txt, 1, 3), SMLSIZE) - text(15, y, d == 1 and "\192" or "\193", SMLSIZE) + text(15, y, d == 1 and SHOWMAX or SHOWMIN, SMLSIZE) else text(0, y, txt, SMLSIZE) end @@ -64,7 +68,7 @@ local function view(data, config, modes, dir, units, labels, gpsDegMin, hdopGrap if data.telem then local indicatorDisplayed = false if data.showDir or data.headingRef == -1 or not SMLCD then - text(X_CNTR_1 - 2, 9, dir[0] .. " " .. math.floor(data.heading + 0.5) % 360 .. "\64", SMLSIZE) + text(X_CNTR_1 - 2, 9, dir[0] .. " " .. math.floor(data.heading + 0.5) % 360 .. DEGSYM, SMLSIZE) text(X_CNTR_1 + 10, 21, dir[2], SMLSIZE) text(X_CNTR_1 - 14, 21, dir[6], SMLSIZE) if not SMLCD then