Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Configuration-Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Note also that on some of the smaller B&W radios (Boxer, Zorro, TX12) with a rol
* **GPS** - GPS coordinates as decimal or degrees/minutes format (default: Decimal)
* **Playback Log** - Playback telemetry log files (latest 5 logs from the last 2 weeks) **[[help](../Configuration-Settings/#playback-telemetry-log-files)]**
* **Greyscale Gfx** - Turn on/off the use of greyscale display graphics (only for monochrome displays)
* **CRSF Fuel Delay** - Set the delay before CRSF telemetry values are used for fuel calc, after the FC is initialised

### Suggested Battery Settings
#### Voltage and Current Calibration
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 @@ -38,6 +38,7 @@ local config = {
{ 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
{ o = 37, c = 2, v = 2.0, d = true, x = 5.0 }, -- CRSF Fuel Delay - 37
}

for i = 1, #config do
Expand Down
30 changes: 24 additions & 6 deletions src/SCRIPTS/TELEMETRY/iNav/crsf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data.fpv_id = getTelemetryId("Hdg")
data.tpwr = 0
data.rfmd = "--"
data.fuelRaw = 0

config[9].v = 0
config[14].v = 0
config[21].v = 2.5
Expand Down Expand Up @@ -52,16 +53,33 @@ local function crsf(data)
data.heading = math.deg(getValue(data.hdg_id))
if data.fpv_id > -1 then data.fpv = getValue(data.fpv_id) * 10 end
]]

data.fuelRaw = data.fuel
if data.showFuel and config[23].v == 0 then
if data.fuelEst == -1 and data.cell > 0 then
if data.fuel < 25 and config[29].v - data.cell >= 0.2 then
data.fuelEst = math.max(math.min(1 - (data.cell - config[2].v + 0.1) / (config[29].v - config[2].v), 1), 0) * config[27].v
else
data.fuelEst = 0
if config[37].v == 0 and data.voltStab == false then data.voltStab = true end
if data.voltStab then
if data.fuelEst == -1 and data.cell > 0 then
if data.fuel < 25 and config[29].v - data.cell >= 0.2 then
data.fuelEst = math.max(math.min(1 - (data.cell - config[2].v + 0.1) / (config[29].v - config[2].v), 1), 0) * config[27].v
else
data.fuelEst = 0
end
end
data.fuel = math.max(math.min(math.floor((1 - (data.fuel + data.fuelEst) / config[27].v) * 100 + 0.5), 100), 0)
else
data.fuel = -1 -- fuel set to -1 for obvious feedback that fuel is not yet calculated
if data.cell_prev ~= data.cell then
if data.cell > data.cell_prev then
data.voltTimer = getTime()
end
data.cell_prev = data.cell
end
if data.voltTimer > 0 and ( data.voltTimer and (getTime() - data.voltTimer) >= (config[37].v * 100) ) then
-- if no voltage increase in the set time, the pack voltage reading is taken as stabilised.
data.voltStab = true
data.voltTimer = (getTime() - data.voltTimer)
end
end
data.fuel = math.max(math.min(math.floor((1 - (data.fuel + data.fuelEst) / config[27].v) * 100 + 0.5), 100), 0)
end
data.fm = getValue(data.fm_id)
data.modePrev = data.mode
Expand Down
3 changes: 3 additions & 0 deletions src/SCRIPTS/TELEMETRY/iNav/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ local function view(data, config, units, lang, event, gpsDegMin, getTelemetryId,
{ t = "Playback Log", l = config[34].l }, -- 34
{ t = "Greyscale Gfx", l = {[0] = "On", "Off"} }, -- 35
{ t = "Horizon Mode", l = {[0] = "Standard", "Fixed"} }, -- 36
{ t = "CRSF Fuel Delay", m = 0, i = 0.5, a = "s" }, -- 37
}

-- Import language changes
Expand Down Expand Up @@ -81,6 +82,8 @@ local function view(data, config, units, lang, event, gpsDegMin, getTelemetryId,
config2[24].p = data.crsf and 1 or (config[7].v < 2 and 1 or nil)
config2[27].p = (not data.crsf or config[23].v > 0) and 1 or nil
config2[35].p = HORUS and 1 or nil
config2[36].p = not data.crsf and 1 or nil

if config2[17].p == nil then
config2[17].p = (not data.showCurr or config[23].v ~= 0) and 1 or nil
config2[18].p = config2[17].p
Expand Down
3 changes: 3 additions & 0 deletions src/SCRIPTS/TELEMETRY/iNav/reset.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
local data = ...

data.voltTimer = 0
data.voltStab = false
data.cell_prev = 0.0
data.armed = false
data.startup = 1
data.timerStart = 0
Expand Down