Skip to content

Commit

Permalink
update log name conventions for EdgeTX
Browse files Browse the repository at this point in the history
  • Loading branch information
stronnag committed May 18, 2022
1 parent d70ffa1 commit d649d03
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/SCRIPTS/TELEMETRY/iNav.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Docs: https://github.com/iNavFlight/OpenTX-Telemetry-Widget

local zone, options = ...
local VERSION = "2.1.1-a1"
local VERSION = "2.1.1-rc1"
local FILE_PATH = "/SCRIPTS/TELEMETRY/iNav/"
local SMLCD = LCD_W < 212
local HORUS = LCD_W >= 480 or LCD_H >= 480
Expand Down
3 changes: 2 additions & 1 deletion src/SCRIPTS/TELEMETRY/iNav/load_e.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ end
local log = getDateTime()
config[34].x = -1

local mbase = string.gsub(model.getInfo().name, " ", ".") .. "-20"
-- From EdgeTX 2.7.1 (at least) we don't need to translate spaces
local mbase = model.getInfo().name .. "-20"
local mblen = string.len(mbase)
local tempf = {}
local tempi = 0
Expand Down
7 changes: 4 additions & 3 deletions src/SCRIPTS/TELEMETRY/iNav/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ end

local function playLog(data, config, distCalc, date)
local gpsTemp = nil
local replc = data.etx and "." or "_"
if logfh == nil then
logfh = io.open("/LOGS/" .. string.gsub(model.getInfo().name, " ", replc) .. "-20" .. date .. ".csv")
fake = loadScript(FILE_PATH .. "log_" .. (data.crsf and "c" or "s") .. ".luac", env)()
local mbase = data.etx and model.getInfo().name or string.gsub(model.getInfo().name, " ", "_")
logfh = io.open("/LOGS/" .. mbase .. "-20" .. date .. ".csv")
data.showMax = false
seek = 0
end
Expand Down Expand Up @@ -115,7 +114,9 @@ local function playLog(data, config, distCalc, date)
if record[i] == "Rud" then break end
label[string.lower(record[i])] = i
end
if record[i] == "1RSS(dB)" then data.crsf = true end
end
fake = loadScript(FILE_PATH .. "log_" .. (data.crsf and "c" or "s") .. ".luac", env)()
else
-- Fake telemetry specific to Crossfire or S.Port
fake(data, config, record, label, toNum)
Expand Down
56 changes: 28 additions & 28 deletions src/SCRIPTS/TELEMETRY/iNav/log_c.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
--Date,Time,FM,1RSS(dB),2RSS(dB),RQly(%),RSNR(dB),RFMD,TPWR(mW),TRSS(dB),TQly(%),TSNR(dB),RxBt(V),Curr(A),Capa(mAh),GPS,GSpd(mph),Hdg(@),Alt(ft),Sats,Ptch(rad),Roll(rad),Yaw(rad),Rud,Ele,Thr,Ail,S1,6P,S2,LS,RS,SA,SB,SC,SD,SE,SF,SG,SH,LSW,TxBat(V)

local function fake(data, config, record, label, toNum)
data.rssi = toNum(record[label.rqly])
data.tpwr = toNum(record[label.tpwr])
data.rfmd = toNum(record[label.rfmd])
data.pitch = math.deg(toNum(record[label.ptch])) * 10
data.roll = math.deg(toNum(record[label.roll])) * 10
data.batt = toNum(record[label.rxbt])
if data.lang == "fr" and data.batt == 0 then data.batt = toNum(record[label.btrx]) end
-- Overflow shenanigans
local tmp = toNum(record[label.yaw])
data.heading = math.deg(tmp < 0 and tmp + 6.55 or tmp)
if data.fpv_id > -1 then
tmp = toNum(record[label.hdg])
data.fpv = (tmp < 0 and tmp + 65.54 or tmp) * 10
end
--[[ Replacement code once the Crossfire/OpenTX Yaw/Hdg int overflow shenanigans are corrected
data.heading = math.deg(toNum(record[label.yaw]))
if data.fpv_id > -1 then data.fpv =toNum(record[label.hdg]) * 10 end
]]
data.fuel = toNum(record[label.capa])
data.fuelRaw = data.fuel
if data.showFuel and config[23].v == 0 then
data.fuel = math.max(math.min(math.floor((1 - (data.fuel) / config[27].v) * 100 + 0.5), 100), 0)
end
-- Don't know the flight mode with Crossfire, so assume armed and ACRO
data.mode = 5
data.satellites = toNum(record[label.sats])
--Fake HDOP based on satellite lock count and assume GPS fix when there's at least 6 satellites
data.hdop = data.satellites + (math.floor(math.min(data.satellites + 10, 25) * 0.36 + 0.5) * 100) + (data.satellites >= 6 and 3000 or 0)
data.rssi = toNum(record[label.rqly])
data.tpwr = toNum(record[label.tpwr])
data.rfmd = toNum(record[label.rfmd])
data.pitch = math.deg(toNum(record[label.ptch])) * 10
data.roll = math.deg(toNum(record[label.roll])) * 10
data.batt = toNum(record[label.rxbt])
if data.lang == "fr" and data.batt == 0 then data.batt = toNum(record[label.btrx]) end
-- Overflow shenanigans
local tmp = toNum(record[label.yaw])
data.heading = math.deg(tmp < 0 and tmp + 6.55 or tmp)
if data.fpv_id > -1 then
tmp = toNum(record[label.hdg])
data.fpv = (tmp < 0 and tmp + 65.54 or tmp) * 10
end
--[[ Replacement code once the Crossfire/OpenTX Yaw/Hdg int overflow shenanigans are corrected
data.heading = math.deg(toNum(record[label.yaw]))
if data.fpv_id > -1 then data.fpv =toNum(record[label.hdg]) * 10 end
]]
data.fuel = toNum(record[label.capa])
data.fuelRaw = data.fuel
if data.showFuel and config[23].v == 0 then
data.fuel = math.max(math.min(math.floor((1 - (data.fuel) / config[27].v) * 100 + 0.5), 100), 0)
end
-- Don't know the flight mode with Crossfire, so assume armed and ACRO
data.mode = 5
data.satellites = toNum(record[label.sats])
--Fake HDOP based on satellite lock count and assume GPS fix when there's at least 6 satellites
data.satellites = data.satellites + (math.floor(math.min(data.satellites + 10, 25) * 0.36 + 0.5) * 100) + (data.satellites >= 6 and 3000 or 0)
end

return fake
2 changes: 1 addition & 1 deletion src/SCRIPTS/TELEMETRY/iNav/log_s.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ local function fake(data, config, record, label, toNum)
data.batt = toNum(record[label.vfas])
end

return fake
return fake
5 changes: 0 additions & 5 deletions src/SCRIPTS/TELEMETRY/iNav/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ local function view(data, config, units, lang, event, gpsDegMin, getTelemetryId,
]]
-- Select config option
if data.configSelect == 0 then
--[[
if event ~= 0 then
print("DBG EVT="..event.." VNEXT="..EVT_VIRTUAL_NEXT.." VPREV="..EVT_VIRTUAL_PREV)
end
]]
if event == EVT_VIRTUAL_NEXT then -- Next option
data.configStatus = data.configStatus == #config and 1 or data.configStatus + 1
data.configTop = data.configStatus > math.min(#config, data.configTop + ROWS) and data.configTop + 1 or (data.configStatus == 1 and 1 or data.configTop)
Expand Down

0 comments on commit d649d03

Please sign in to comment.