Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add vtx tables download to popup menu
Deletes the contents of the .lua file containing vtx tables for the selected model and downloads them again. The menu item is only available for firmwares supporting vtx tables.
  • Loading branch information
klutvott123 committed Mar 1, 2020
commit 405926484ebdd8ebc27e1f6354bf0baddca7a4eb
28 changes: 21 additions & 7 deletions src/SCRIPTS/BF/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local popupMenuActive = 1
local killEnterBreak = 0
local pageScrollY = 0
local mainMenuScrollY = 0
local PageFiles, Page, init
local PageFiles, Page, init, popupMenuList

local backgroundFill = TEXT_BGCOLOR or ERASE
local foregroundColor = LINE_COLOR or SOLID
Expand Down Expand Up @@ -72,11 +72,24 @@ local function eepromWrite()
protocol.mspRead(uiMsp.eepromWrite)
end

local popupMenuList = {
{ t = "save page", f = saveSettings },
{ t = "reload", f = invalidatePages },
{ t = "reboot", f = rebootFc },
}
local function getVtxTables()
uiState = uiStatus.init
PageFiles = nil
invalidatePages()
io.close(io.open("/BF/VTX/"..model.getInfo().name..".lua", 'w'))
return 0
end

local function createPopupMenu()
popupMenuList = {
{ t = "save page", f = saveSettings },
{ t = "reload", f = invalidatePages },
{ t = "reboot", f = rebootFc },
}
if apiVersion >= 1.042 then
popupMenuList[#popupMenuList + 1] = { t = "vtx tables", f = getVtxTables }
end
end

local function processMspReply(cmd,rx_buf)
if not Page or not rx_buf then
Expand Down Expand Up @@ -254,6 +267,7 @@ local function run_ui(event)
return 0
end
init = nil
createPopupMenu()
PageFiles = assert(loadScript("pages.lua"))()
invalidatePages()
uiState = uiStatus.mainMenu
Expand Down Expand Up @@ -312,7 +326,7 @@ local function run_ui(event)
killEnterBreak = 0
else
pageState = pageStatus.display
popupMenuList[popupMenuActive].f()
return popupMenuList[popupMenuActive].f() or 0
end
end
elseif pageState == pageStatus.display then
Expand Down
9 changes: 8 additions & 1 deletion src/SCRIPTS/BF/ui_init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
local apiVersionReceived = false
local vtxTablesReceived = loadScript("/BF/VTX/"..model.getInfo().name..".lua")
local vtxTablesReceived = false
local data_init, getVtxTables
local vtxTables = loadScript("/BF/VTX/"..model.getInfo().name..".lua")

if vtxTables and vtxTables() then
vtxTablesReceived = true
vtxTables = nil
collectgarbage()
end

local function init()
if apiVersion == 0 then
Expand Down