Skip to content

Commit

Permalink
Additional check for lost RSSI with Crossfire
Browse files Browse the repository at this point in the history
  • Loading branch information
teckel12 committed Aug 14, 2019
1 parent 301931c commit 89387d9
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 9 deletions.
Binary file modified dist/SCRIPTS/TELEMETRY/iNav.lua
Binary file not shown.
Binary file modified dist/SCRIPTS/TELEMETRY/iNav.luac
Binary file not shown.
Binary file modified dist/SCRIPTS/TELEMETRY/iNav/crsf.luac
Binary file not shown.
Binary file modified dist/SCRIPTS/TELEMETRY/iNav/horus.luac
Binary file not shown.
Binary file modified dist/SCRIPTS/TELEMETRY/iNav/other.luac
Binary file not shown.
2 changes: 1 addition & 1 deletion src/iNav.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ end
loadScript(FILE_PATH .. "reset" .. ext, env)(data)
collectgarbage()

local crsf, distCalc = loadScript(FILE_PATH .. "other" .. ext, env)(config, data, units, getTelemetryId, getTelemetryUnit, FILE_PATH, env, SMLCD)
local crsf, distCalc = loadScript(FILE_PATH .. "other" .. ext, env)(config, data, units, getTelemetryId, getTelemetryUnit, FILE_PATH, env, SMLCD, FLASH)
collectgarbage()

local title, gpsDegMin, hdopGraph, icons = loadScript(FILE_PATH .. "func_" .. (HORUS and "h" or "t") .. ext, env)(config, data, FILE_PATH)
Expand Down
4 changes: 2 additions & 2 deletions src/iNav/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ for abv = 1, #langs do
end

loadScript(FILE_PATH .. "reset", env)(data)
local crsf = loadScript(FILE_PATH .. "crsf", env)(config, data, getTelemetryId)
crsf, distCalc = loadScript(FILE_PATH .. "other", env)(config, data, units, getTelemetryId, getTelemetryUnit, FILE_PATH, env, SMLCD)
local crsf = loadScript(FILE_PATH .. "crsf", env)(config, data, getTelemetryId, FLASH)
crsf, distCalc = loadScript(FILE_PATH .. "other", env)(config, data, units, getTelemetryId, getTelemetryUnit, FILE_PATH, env, SMLCD, FLASH)
loadScript(FILE_PATH .. "view", env)()
loadScript(FILE_PATH .. "pilot", env)()
loadScript(FILE_PATH .. "radar", env)()
Expand Down
9 changes: 8 additions & 1 deletion src/iNav/crsf.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local config, data, getTelemetryId = ...
local config, data, getTelemetryId, FLASH = ...

data.crsf = true
data.rfmd_id = getTelemetryId("RFMD")
data.rssi_id = getTelemetryId("1RSS")
data.sat_id = getTelemetryId("Sats")
data.fuel_id = getTelemetryId("Capa")
data.batt_id = getTelemetryId("RxBt") > -1 and getTelemetryId("RxBt") or getTelemetryId("BtRx")
Expand All @@ -19,6 +20,12 @@ config[22].v = 0
config[23].x = 1

local function crsf(data)
if getValue(data.rssi_id) == 0 then
data.rssi = 0
data.telem = false
data.telemFlags = FLASH
return 0
end
if data.rssi == 99 then data.rssi = 100 end
data.tpwr = getValue(data.tpwr_id)
data.rfmd = getValue(data.rfmd_id)
Expand Down
6 changes: 3 additions & 3 deletions src/iNav/horus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -284,18 +284,18 @@ local function view(data, config, modes, units, labels, gpsDegMin, hdopGraph, ic
if data.distanceLast >= data.distRef then
local bearing = calcBearing(data.gpsHome, data.gpsLatLon) + 540 % 360
if config[15].v == 1 then
-- 3D HUD method
-- HUD method
local d = 1 - data.distanceLast / maxDist
local w = HEADING_DEG / (d + 1)
local h = floor((((upsideDown and data.heading - bearing or bearing - data.heading) + (361 + w * 0.5)) % 360) * (RIGHT_POS / w) - 0.5)
--local p = sin(math.atan(data.altitude / data.distanceLast) - math.atan(data.altitude / max(maxDist, data.altitude * 0.25))) * (upsideDown and DEGV or -DEGV)
local p = sin(math.atan(data.altitude / data.distanceLast * 0.5)) * (upsideDown and DEGV or -DEGV)
--local p = sin(rad(d * max(15 + (pitch - 90) * 0.5, 0))) * (upsideDown and DEGV or -DEGV)
local p = sin(math.atan(data.altitude / data.distanceLast * 0.5)) * (upsideDown and DEGV or -DEGV)
local x = (X_CNTR - cos(roll1) * p) + (sin(roll1) * (h - X_CNTR)) - 9
local y = ((Y_CNTR - cos(rad(pitch)) * DEGV) - sin(roll1) * p) - (cos(roll1) * (h - X_CNTR)) - 9
if x >= 0 and x < RIGHT_POS - 17 then
local s = floor(d * 2 + 0.5)
bmap(icons.home[s], x, min(max(y, s == 2 and 20 or 15), BOTTOM - (s == 2 and 35 or 30)))
bmap(icons.home[s], x, min(max(y, s == 2 and TOP or 15), BOTTOM - (s == 2 and 35 or 30)))
end
--[[
if x >= 0 and y >= TOP and x < RIGHT_POS - 17 and y < BOTTOM - 17 then
Expand Down
4 changes: 2 additions & 2 deletions src/iNav/other.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local config, data, units, getTelemetryId, getTelemetryUnit, FILE_PATH, env, SMLCD = ...
local config, data, units, getTelemetryId, getTelemetryUnit, FILE_PATH, env, SMLCD, FLASH = ...
local crsf = nil

-- Detect Crossfire
Expand All @@ -8,7 +8,7 @@ data.fm_id = getTelemetryId("FM") > -1 and getTelemetryId("FM") or getTelemetryI
--if data.simu then data.fm_id = 1 end

if data.fm_id > -1 then
crsf = loadScript(FILE_PATH .. "crsf.luac", env)(config, data, getTelemetryId)
crsf = loadScript(FILE_PATH .. "crsf.luac", env)(config, data, getTelemetryId, FLASH)
collectgarbage()
end

Expand Down

0 comments on commit 89387d9

Please sign in to comment.