Skip to content

Commit

Permalink
VTX memory savings
Browse files Browse the repository at this point in the history
Have vtx_defaults return it's tables to vtx instead of loading them as globals.
  • Loading branch information
klutvott123 committed Nov 12, 2019
1 parent be4fc28 commit f2d46e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
20 changes: 10 additions & 10 deletions src/BF/VTX/vtx_defaults.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
frequencyTable = {
{ 5865, 5845, 5825, 5805, 5785, 5765, 5745, 5725 }, -- Boscam A
{ 5733, 5752, 5771, 5790, 5809, 5828, 5847, 5866 }, -- Boscam B
{ 5705, 5685, 5665, 5645, 5885, 5905, 5925, 5945 }, -- Boscam E
{ 5740, 5760, 5780, 5800, 5820, 5840, 5860, 5880 }, -- FatShark
{ 5658, 5695, 5732, 5769, 5806, 5843, 5880, 5917 }, -- RaceBand
return {
frequencyTable = {
{ 5865, 5845, 5825, 5805, 5785, 5765, 5745, 5725 }, -- Boscam A
{ 5733, 5752, 5771, 5790, 5809, 5828, 5847, 5866 }, -- Boscam B
{ 5705, 5685, 5665, 5645, 5885, 5905, 5925, 5945 }, -- Boscam E
{ 5740, 5760, 5780, 5800, 5820, 5840, 5860, 5880 }, -- FatShark
{ 5658, 5695, 5732, 5769, 5806, 5843, 5880, 5917 }, -- RaceBand
},
frequenciesPerBand = 8,
bandTable = { [0]="U", "A", "B", "E", "F", "R" },
}
frequenciesPerBand = 8
bandTable = { [0]="U", "A", "B", "E", "F", "R" }
deviceTable = { [1]="6705", [3]="SA", [4]="Tramp", [255]="None" }
pitModeTable = { [0]="OFF", "ON" }
23 changes: 13 additions & 10 deletions src/SCRIPTS/BF/PAGES/vtx.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
local display = assert(loadScript(radio.templateHome.."vtx.lua"))()
assert(loadScript("/BF/VTX/vtx_defaults.lua"))()
local md = model.getInfo();
vtx_tables = loadScript("/BF/VTX/"..md.name..".lua")
if (vtx_tables ~= nil) then
vtx_tables()
local vtx_tables = loadScript("/BF/VTX/"..md.name..".lua")
if vtx_tables then
vtx_tables = vtx_tables()
else
vtx_tables = assert(loadScript("/BF/VTX/vtx_defaults.lua"))()
end
local deviceTable = { [1]="6705", [3]="SA", [4]="Tramp", [255]="None" }
local pitModeTable = { [0]="OFF", "ON" }

-- Vals Fields
-- 1 Device Type Band
Expand All @@ -29,14 +32,14 @@ return {
labels = display.labels,
fieldLayout = display.fieldLayout,
fields = {
{ min=0, max=#(bandTable), vals = { 2 }, table = bandTable, upd = function(self) self.handleBandChanUpdate(self) end },
{ min=1, max=frequenciesPerBand, vals = { 3 }, upd = function(self) self.handleBandChanUpdate(self) end },
{ min=0, max=#(vtx_tables.bandTable), vals = { 2 }, table = vtx_tables.bandTable, upd = function(self) self.handleBandChanUpdate(self) end },
{ min=1, max=vtx_tables.frequenciesPerBand, vals = { 3 }, upd = function(self) self.handleBandChanUpdate(self) end },
{ min=1, vals = { 4 }, upd = function(self) self.updatePowerTable(self) end },
{ min=0, max=#(pitModeTable), vals = { 5 }, table = pitModeTable },
{ vals = { 1 }, write = false, ro = true, table = deviceTable },
{ min = 5000, max = 5999, vals = { 6 }, upd = function(self) self.handleFreqValUpdate(self) end },
},
freqLookup = frequencyTable,
freqLookup = vtx_tables.frequencyTable,
postLoad = function (self)
if (self.values[2] or 0) < 0 or (self.values[3] or 0) == 0 or (self.values[4] or 0) == 0 then
self.values = {}
Expand Down Expand Up @@ -180,9 +183,9 @@ return {
end,
updatePowerTable = function(self)
if self.values and not self.fields[3].table then
if powerTable then
self.fields[3].table = powerTable
self.fields[3].max = #(powerTable)
if vtx_tables.powerTable then
self.fields[3].table = vtx_tables.powerTable
self.fields[3].max = #(vtx_tables.powerTable)
else
if self.values[1] == 1 then -- RTC6705
self.fields[3].table = { 25, 200 }
Expand Down

0 comments on commit f2d46e3

Please sign in to comment.