File tree Expand file tree Collapse file tree
src/SCRIPTS/TELEMETRY/iNav Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ data.hdg_id = getTelemetryId("Yaw")
1212data.fpv_id = getTelemetryId("Hdg")
1313data.tpwr = 0
1414data.rfmd = "--"
15+ data.batt_percent_id = getTelemetryId("Bat")
1516data.fuelRaw = 0
1617config[9].v = 0
1718config[14].v = 0
@@ -54,14 +55,18 @@ local function crsf(data)
5455 ]]
5556 data.fuelRaw = data.fuel
5657 if data.showFuel and config[23].v == 0 then
57- if data.fuelEst == -1 and data.cell > 0 then
58- if data.fuel < 25 and config[29].v - data.cell >= 0.2 then
59- 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
60- else
61- data.fuelEst = 0
58+ if data.batt_percent_id > -1 then
59+ data.fuel = getValue(data.batt_percent_id)
60+ else
61+ if data.fuelEst == -1 and data.cell > 0 then
62+ if data.fuel < 25 and config[29].v - data.cell >= 0.2 then
63+ 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
64+ else
65+ data.fuelEst = 0
66+ end
6267 end
68+ data.fuel = math.max(math.min(math.floor((1 - (data.fuel + data.fuelEst) / config[27].v) * 100 + 0.5), 100), 0)
6369 end
64- data.fuel = math.max(math.min(math.floor((1 - (data.fuel + data.fuelEst) / config[27].v) * 100 + 0.5), 100), 0)
6570 end
6671 data.fm = getValue(data.fm_id)
6772 data.modePrev = data.mode
You can’t perform that action at this time.
0 commit comments