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 571dfd5

Browse files
Do not download VTX table prematurely
1 parent 8c3dcd3 commit 571dfd5

File tree

7 files changed

+32
-34
lines changed

7 files changed

+32
-34
lines changed

‎src/SCRIPTS/BF/CONFIRM/vtx_tables.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +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
6-
local sp = template.listSpacing.field
74
local yMinLim = radio.yMinLimit
85
local x = margin
96
local y = yMinLim - lineSpacing

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
local function precondition()
2+
local hasVtxTable = loadScript("VTX_TABLES/"..mcuId..".lua")
3+
collectgarbage()
4+
if hasVtxTable then
5+
return nil
6+
else
7+
return "CONFIRM/vtx_tables.lua"
8+
end
9+
end
10+
11+
return precondition()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local fields = {}
1111

1212
local vtx_tables
1313
if apiVersion >= 1.42 then
14-
vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"))()
14+
vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"), "No VTX table!")()
1515
else
1616
vtx_tables = assert(loadScript("VTX_TABLES/vtx_defaults.lua"))()
1717
end

‎src/SCRIPTS/BF/features_info.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local MSP_GPS_CONFIG = 135
22
local MSP_VTX_CONFIG = 88
33

44
local isGpsRead = false
5-
local isVtxRead = true-- Checking VTX is done in `vtx_tables.lua`
5+
local isVtxRead = false
66

77
local lastRunTS = 0
88
local INTERVAL = 100

‎src/SCRIPTS/BF/pages.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local PageFiles = {}
22

33
if apiVersion >= 1.36 and features.vtx then
4-
PageFiles[#PageFiles + 1] = { title = "VTX Settings", script = "vtx.lua" }
4+
PageFiles[#PageFiles + 1] = { title = "VTX Settings", script = "vtx.lua", init="PAGES/INIT/vtx.lua" }
55
end
66

77
if apiVersion >= 1.16 then

‎src/SCRIPTS/BF/ui.lua

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,23 @@ local function run_ui(event)
385385
end
386386
end
387387
if not Page then
388-
Page = assert(loadScript("PAGES/"..PageFiles[currentPage].script))()
389-
collectgarbage()
388+
local function selectPage(page)
389+
Page = assert(loadScript("PAGES/"..page))()
390+
collectgarbage()
391+
end
392+
393+
local selectedPage = PageFiles[currentPage]
394+
if selectedPage.init then
395+
local initScript = assert(loadScript(selectedPage.init), "Missing init script")()
396+
collectgarbage()
397+
if initScript then
398+
confirm(initScript)
399+
else
400+
selectPage(selectedPage.script)
401+
end
402+
else
403+
selectPage(selectedPage.script)
404+
end
390405
end
391406
if not Page.values and pageState == pageStatus.display then
392407
requestPage()

‎src/SCRIPTS/BF/ui_init.lua

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
local apiVersionReceived = false
2-
local vtxTablesReceived = false
32
local mcuIdReceived = false
43
local boardInfoReceived = false
54
local featuresReceived = false
6-
local getApiVersion, getVtxTables, getMCUId, getBoardInfo, getFeaturesInfo
5+
local getApiVersion, getMCUId, getBoardInfo, getFeaturesInfo
76
local returnTable = { f = nil, t = "" }
87

98
local function init()
@@ -23,30 +22,6 @@ local function init()
2322
mcuIdReceived = getMCUId.f()
2423
if mcuIdReceived then
2524
getMCUId = nil
26-
local f = loadScript("VTX_TABLES/" .. mcuId .. ".lua")
27-
if f then
28-
local table = f()
29-
if table then
30-
vtxTablesReceived = true
31-
features.vtx = 0 < table.frequenciesPerBand
32-
f = nil
33-
table = nil
34-
end
35-
end
36-
collectgarbage()
37-
f = loadScript("BOARD_INFO/"..mcuId..".lua")
38-
if f and f() then
39-
boardInfoReceived = true
40-
f = nil
41-
end
42-
collectgarbage()
43-
end
44-
elseif not vtxTablesReceived and apiVersion >= 1.42 then
45-
getVtxTables = getVtxTables or assert(loadScript("vtx_tables.lua"))()
46-
returnTable.t = getVtxTables.t
47-
vtxTablesReceived = getVtxTables.f()
48-
if vtxTablesReceived then
49-
getVtxTables = nil
5025
collectgarbage()
5126
end
5227
elseif not boardInfoReceived and apiVersion >= 1.44 then

0 commit comments

Comments
(0)

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