forked from betaflight/betaflight-tx-lua-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request betaflight#495 from atomgomba/hide-gps-if-unavailable
Hide GPS settings if unavailable
- Loading branch information
Showing
8 changed files
with
98 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
local function precondition() | ||
local hasVtxTable = loadScript("VTX_TABLES/"..mcuId..".lua") | ||
collectgarbage() | ||
if hasVtxTable then | ||
return nil | ||
else | ||
return "CONFIRM/vtx_tables.lua" | ||
end | ||
end | ||
|
||
return precondition() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
local features = { | ||
vtx = true, | ||
gps = true, | ||
} | ||
|
||
return features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
local MSP_GPS_CONFIG = 135 | ||
local MSP_VTX_CONFIG = 88 | ||
|
||
local isGpsRead = false | ||
local isVtxRead = false | ||
|
||
local lastRunTS = 0 | ||
local INTERVAL = 100 | ||
|
||
local returnTable = { | ||
f = nil, | ||
t = "", | ||
} | ||
|
||
local function processMspReply(cmd, payload, err) | ||
local isOkay = not err | ||
if cmd == MSP_GPS_CONFIG then | ||
isGpsRead = true | ||
local providerSet = payload[1] ~= 0 | ||
features.gps = isOkay and providerSet | ||
elseif cmd == MSP_VTX_CONFIG then | ||
isVtxRead = true | ||
local vtxTableAvailable = payload[12] ~= 0 | ||
features.vtx = isOkay and vtxTableAvailable | ||
end | ||
end | ||
|
||
local function updateFeatures() | ||
if lastRunTS + INTERVAL < getTime() then | ||
lastRunTS = getTime() | ||
local cmd | ||
if not isGpsRead then | ||
cmd = MSP_GPS_CONFIG | ||
returnTable.t = "Checking GPS..." | ||
elseif not isVtxRead then | ||
cmd = MSP_VTX_CONFIG | ||
returnTable.t = "Checking VTX..." | ||
end | ||
if cmd then | ||
protocol.mspRead(cmd) | ||
else | ||
return true | ||
end | ||
end | ||
mspProcessTxQ() | ||
processMspReply(mspPollReply()) | ||
return false | ||
end | ||
|
||
returnTable.f = updateFeatures | ||
|
||
return returnTable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters