Skip to content

Commit 8e9d1b8

Browse files
authored
Merge pull request #318 from klutvott123/vtx-tables-reload
Add vtx tables download to popup menu
2 parents a397f0b + 4059264 commit 8e9d1b8

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

src/SCRIPTS/BF/ui.lua

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ local popupMenuActive = 1
3232
local killEnterBreak = 0
3333
local pageScrollY = 0
3434
local mainMenuScrollY = 0
35-
local PageFiles, Page, init
35+
local PageFiles, Page, init, popupMenuList
3636

3737
local backgroundFill = TEXT_BGCOLOR or ERASE
3838
local foregroundColor = LINE_COLOR or SOLID
@@ -72,11 +72,24 @@ local function eepromWrite()
7272
protocol.mspRead(uiMsp.eepromWrite)
7373
end
7474

75-
local popupMenuList = {
76-
{ t = "save page", f = saveSettings },
77-
{ t = "reload", f = invalidatePages },
78-
{ t = "reboot", f = rebootFc },
79-
}
75+
local function getVtxTables()
76+
uiState = uiStatus.init
77+
PageFiles = nil
78+
invalidatePages()
79+
io.close(io.open("/BF/VTX/"..model.getInfo().name..".lua", 'w'))
80+
return 0
81+
end
82+
83+
local function createPopupMenu()
84+
popupMenuList = {
85+
{ t = "save page", f = saveSettings },
86+
{ t = "reload", f = invalidatePages },
87+
{ t = "reboot", f = rebootFc },
88+
}
89+
if apiVersion >= 1.042 then
90+
popupMenuList[#popupMenuList + 1] = { t = "vtx tables", f = getVtxTables }
91+
end
92+
end
8093

8194
local function processMspReply(cmd,rx_buf)
8295
if not Page or not rx_buf then
@@ -254,6 +267,7 @@ local function run_ui(event)
254267
return 0
255268
end
256269
init = nil
270+
createPopupMenu()
257271
PageFiles = assert(loadScript("pages.lua"))()
258272
invalidatePages()
259273
uiState = uiStatus.mainMenu
@@ -312,7 +326,7 @@ local function run_ui(event)
312326
killEnterBreak = 0
313327
else
314328
pageState = pageStatus.display
315-
popupMenuList[popupMenuActive].f()
329+
return popupMenuList[popupMenuActive].f() or 0
316330
end
317331
end
318332
elseif pageState == pageStatus.display then

src/SCRIPTS/BF/ui_init.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
local apiVersionReceived = false
2-
local vtxTablesReceived = loadScript("/BF/VTX/"..model.getInfo().name..".lua")
2+
local vtxTablesReceived = false
33
local data_init, getVtxTables
4+
local vtxTables = loadScript("/BF/VTX/"..model.getInfo().name..".lua")
5+
6+
if vtxTables and vtxTables() then
7+
vtxTablesReceived = true
8+
vtxTables = nil
9+
collectgarbage()
10+
end
411

512
local function init()
613
if apiVersion == 0 then

0 commit comments

Comments
 (0)