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 686a485

Browse files
Merge pull request #500 from atomgomba/skip-board-info-if-possible
Download board info only if necessary
2 parents c3c095f + 1c0f49d commit 686a485

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
local template = assert(loadScript(radio.template))()
2+
local margin = template.margin
3+
local lineSpacing = template.lineSpacing
4+
local yMinLim = radio.yMinLimit
5+
local x = margin
6+
local y = yMinLim - lineSpacing
7+
local inc = { x = function(val) x = x + val return x end, y = function(val) y = y + val return y end }
8+
local labels = {}
9+
local fields = {}
10+
11+
labels[#labels + 1] = { t = "Download Board Info? Press", x = x, y = inc.y(lineSpacing) }
12+
labels[#labels + 1] = { t = "[ENTER] to download, or", x = x, y = inc.y(lineSpacing) }
13+
labels[#labels + 1] = { t = "[EXIT] to cancel.", x = x, y = inc.y(lineSpacing) }
14+
fields[#fields + 1] = { x = x, y = inc.y(lineSpacing), value = "", ro = true }
15+
16+
return {
17+
title = "Board Info",
18+
labels = labels,
19+
fields = fields,
20+
init = assert(loadScript("board_info.lua"))(),
21+
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
local function precondition()
2+
if apiVersion < 1.44 then
3+
-- BOARD_INFO is unavailable below 1.44
4+
return nil
5+
end
6+
local hasBoardInfo = loadScript("BOARD_INFO/"..mcuId..".lua")
7+
collectgarbage()
8+
if hasBoardInfo then
9+
return nil
10+
else
11+
return "CONFIRM/pwm.lua"
12+
end
13+
end
14+
15+
return precondition()

‎src/SCRIPTS/BF/pages.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if apiVersion >= 1.42 then
3737
end
3838

3939
if apiVersion >= 1.16 then
40-
PageFiles[#PageFiles + 1] = { title = "System / Motor", script = "pwm.lua" }
40+
PageFiles[#PageFiles + 1] = { title = "System / Motor", script = "pwm.lua", init="PAGES/INIT/pwm.lua" }
4141
end
4242

4343
if apiVersion >= 1.16 then

‎src/SCRIPTS/BF/ui.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ local function createPopupMenu()
9494
if apiVersion >= 1.42 then
9595
popupMenu[#popupMenu + 1] = { t = "vtx tables", f = function() confirm("CONFIRM/vtx_tables.lua") end }
9696
end
97+
if apiVersion >= 1.44 then
98+
popupMenu[#popupMenu + 1] = { t = "board info", f = function() confirm("CONFIRM/pwm.lua") end }
99+
end
97100
end
98101

99102
local function processMspReply(cmd,rx_buf,err)

‎src/SCRIPTS/BF/ui_init.lua

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
local apiVersionReceived = false
22
local mcuIdReceived = false
3-
local boardInfoReceived = false
43
local featuresReceived = false
5-
local getApiVersion, getMCUId, getBoardInfo, getFeaturesInfo
4+
local getApiVersion, getMCUId, getFeaturesInfo
65
local returnTable = { f = nil, t = "" }
76

87
local function init()
@@ -24,14 +23,6 @@ local function init()
2423
getMCUId = nil
2524
collectgarbage()
2625
end
27-
elseif not boardInfoReceived and apiVersion >= 1.44 then
28-
getBoardInfo = getBoardInfo or assert(loadScript("board_info.lua"))()
29-
returnTable.t = getBoardInfo.t
30-
boardInfoReceived = getBoardInfo.f()
31-
if boardInfoReceived then
32-
getBoardInfo = nil
33-
collectgarbage()
34-
end
3526
elseif not featuresReceived and apiVersion >= 1.41 then
3627
getFeaturesInfo = getFeaturesInfo or assert(loadScript("features_info.lua"))()
3728
returnTable.t = getFeaturesInfo.t
@@ -43,7 +34,7 @@ local function init()
4334
else
4435
return true
4536
end
46-
return apiVersionReceived and vtxTablesReceivedandmcuIdandboardInfoReceived and featuresReceived
37+
return apiVersionReceived and mcuId and featuresReceived
4738
end
4839

4940
returnTable.f = init

0 commit comments

Comments
(0)

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