Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8c3dcd3

Browse files
Hide GPS settings if unavailable
1 parent 9e7c375 commit 8c3dcd3

File tree

6 files changed

+68
-26
lines changed

6 files changed

+68
-26
lines changed

‎src/SCRIPTS/BF/PAGES/vtx.lua‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
local template = assert(loadScript(radio.template))()
22
local margin = template.margin
3-
local indent = template.indent
43
local lineSpacing = template.lineSpacing
5-
local tableSpacing = template.tableSpacing
64
local sp = template.listSpacing.field
75
local yMinLim = radio.yMinLimit
86
local x = margin

‎src/SCRIPTS/BF/features.lua‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local features = {
22
vtx = true,
3+
gps = true,
34
}
45

56
return features

‎src/SCRIPTS/BF/features_info.lua‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
local MSP_GPS_CONFIG = 135
2+
local MSP_VTX_CONFIG = 88
3+
4+
local isGpsRead = false
5+
local isVtxRead = true -- Checking VTX is done in `vtx_tables.lua`
6+
7+
local lastRunTS = 0
8+
local INTERVAL = 100
9+
10+
local returnTable = {
11+
f = nil,
12+
t = "",
13+
}
14+
15+
local function processMspReply(cmd, payload, err)
16+
local isOkay = not err
17+
if cmd == MSP_GPS_CONFIG then
18+
isGpsRead = true
19+
local providerSet = payload[1] ~= 0
20+
features.gps = isOkay and providerSet
21+
elseif cmd == MSP_VTX_CONFIG then
22+
isVtxRead = true
23+
local vtxTableAvailable = payload[12] ~= 0
24+
features.vtx = isOkay and vtxTableAvailable
25+
end
26+
end
27+
28+
local function updateFeatures()
29+
if lastRunTS + INTERVAL < getTime() then
30+
lastRunTS = getTime()
31+
local cmd
32+
if not isGpsRead then
33+
cmd = MSP_GPS_CONFIG
34+
returnTable.t = "Checking GPS..."
35+
elseif not isVtxRead then
36+
cmd = MSP_VTX_CONFIG
37+
returnTable.t = "Checking VTX..."
38+
end
39+
if cmd then
40+
protocol.mspRead(cmd)
41+
else
42+
return true
43+
end
44+
end
45+
mspProcessTxQ()
46+
processMspReply(mspPollReply())
47+
return false
48+
end
49+
50+
returnTable.f = updateFeatures
51+
52+
return returnTable

‎src/SCRIPTS/BF/pages.lua‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local PageFiles = {}
22

3-
if apiVersion >= 1.36 then
3+
if apiVersion >= 1.36 andfeatures.vtxthen
44
PageFiles[#PageFiles + 1] = { title = "VTX Settings", script = "vtx.lua" }
55
end
66

@@ -48,11 +48,11 @@ if apiVersion >= 1.16 then
4848
PageFiles[#PageFiles + 1] = { title = "Failsafe", script = "failsafe.lua" }
4949
end
5050

51-
if apiVersion >= 1.41 then
51+
if apiVersion >= 1.41 andfeatures.gpsthen
5252
PageFiles[#PageFiles + 1] = { title = "GPS Rescue", script = "rescue.lua" }
5353
end
5454

55-
if apiVersion >= 1.41 then
55+
if apiVersion >= 1.41 andfeatures.gpsthen
5656
PageFiles[#PageFiles + 1] = { title = "GPS PIDs", script = "gpspids.lua" }
5757
end
5858

‎src/SCRIPTS/BF/ui.lua‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,6 @@ local function confirm(page)
8282
collectgarbage()
8383
end
8484

85-
local function filterAvailablePages(pageFiles)
86-
local newPageFiles = pageFiles
87-
88-
local function skipPage(script)
89-
local currentPageFiles = {}
90-
for i = 1, #newPageFiles do
91-
if newPageFiles[i].script ~= script then
92-
currentPageFiles[#currentPageFiles + 1] = newPageFiles[i]
93-
end
94-
end
95-
newPageFiles = currentPageFiles
96-
end
97-
98-
if not features.vtx then skipPage("vtx.lua") end
99-
100-
return newPageFiles
101-
end
102-
10385
local function createPopupMenu()
10486
popupMenuActive = 1
10587
popupMenu = {}
@@ -314,7 +296,7 @@ local function run_ui(event)
314296
return 0
315297
end
316298
init = nil
317-
PageFiles = filterAvailablePages(assert(loadScript("pages.lua"))())
299+
PageFiles = assert(loadScript("pages.lua"))()
318300
invalidatePages()
319301
uiState = prevUiState or uiStatus.mainMenu
320302
prevUiState = nil

‎src/SCRIPTS/BF/ui_init.lua‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ local apiVersionReceived = false
22
local vtxTablesReceived = false
33
local mcuIdReceived = false
44
local boardInfoReceived = false
5-
local getApiVersion, getVtxTables, getMCUId, getBoardInfo
5+
local featuresReceived = false
6+
local getApiVersion, getVtxTables, getMCUId, getBoardInfo, getFeaturesInfo
67
local returnTable = { f = nil, t = "" }
78

89
local function init()
@@ -56,10 +57,18 @@ local function init()
5657
getBoardInfo = nil
5758
collectgarbage()
5859
end
60+
elseif not featuresReceived and apiVersion >= 1.41 then
61+
getFeaturesInfo = getFeaturesInfo or assert(loadScript("features_info.lua"))()
62+
returnTable.t = getFeaturesInfo.t
63+
featuresReceived = getFeaturesInfo.f()
64+
if featuresReceived then
65+
getFeaturesInfo = nil
66+
collectgarbage()
67+
end
5968
else
6069
return true
6170
end
62-
return apiVersionReceived and vtxTablesReceived and mcuId and boardInfoReceived
71+
return apiVersionReceived and vtxTablesReceived and mcuId and boardInfoReceivedandfeaturesReceived
6372
end
6473

6574
returnTable.f = init

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /