Skip to content

Commit

Permalink
replace legacy escaped characters for EdgeTX (and OpenTX)
Browse files Browse the repository at this point in the history
  • Loading branch information
stronnag committed Jan 19, 2025
1 parent f8d010b commit 448ff48
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
8 changes: 5 additions & 3 deletions src/SCRIPTS/TELEMETRY/iNav/alt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/SCRIPTS/TELEMETRY/iNav/func_t.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions src/SCRIPTS/TELEMETRY/iNav/pilot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions src/SCRIPTS/TELEMETRY/iNav/radar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/SCRIPTS/TELEMETRY/iNav/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 448ff48

Please sign in to comment.