Skip to content

Commit

Permalink
Create empty vtx table if not available
Browse files Browse the repository at this point in the history
  • Loading branch information
klutvott123 committed Mar 13, 2023
1 parent 3ea553e commit 61d3029
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/SCRIPTS/BF/PAGES/vtx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ local labels = {}
local fields = {}

local vtx_tables
local f = loadScript("VTX_TABLES/"..mcuId..".lua")
if apiVersion >= 1.42 and f then
vtx_tables = f()
if apiVersion >= 1.42 then
vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"))()
else
vtx_tables = assert(loadScript("VTX_TABLES/vtx_defaults.lua"))()
end
Expand Down
14 changes: 10 additions & 4 deletions src/SCRIPTS/BF/vtx_tables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ local MSP_VTX_CONFIG = 88
local MSP_VTXTABLE_BAND = 137
local MSP_VTXTABLE_POWERLEVEL = 138

local vtxAvailable = true
local vtxTableAvailable = false
local vtxConfigReceived = false
local vtxFrequencyTableReceived = false
Expand All @@ -12,7 +11,6 @@ local requestedBand = 1
local requestedPowerLevel = 1
local vtxTableConfig = {}
local frequencyTable = {}
local frequenciesPerBand = 0
local bandTable = {}
local powerTable = {}

Expand All @@ -22,7 +20,15 @@ local INTERVAL = 100
local function processMspReply(cmd, payload, err)
if cmd == MSP_VTX_CONFIG then
if err then
vtxAvailable = false
-- Vtx not available. Create empty vtx table to skip future download attempts
frequencyTable[1] = {}
vtxTableConfig.channels = 0
bandTable = { [0] = "U", "1" }
powerTable = { "LV0" }
vtxConfigReceived = true
vtxTableAvailable = true
vtxFrequencyTableReceived = true
vtxPowerTableReceived = true
return
end
vtxConfigReceived = true
Expand Down Expand Up @@ -118,7 +124,7 @@ local function getVtxTables()
end
mspProcessTxQ()
processMspReply(mspPollReply())
return vtxTablesReceived or not vtxAvailable
return vtxTablesReceived
end

return { f = getVtxTables, t = "Downloading VTX tables" }

0 comments on commit 61d3029

Please sign in to comment.