Skip to content

VTX tables #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/BF/VTX/vtx_defaults.lua
Original file line number Diff line number Diff line change
@@ -0,0 +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
}
frequenciesPerBand = 8
bandTable = { [0]="U", "A", "B", "E", "F", "R" }
deviceTable = { [1]="6705", [3]="SA", [4]="Tramp", [255]="None" }
pitModeTable = { [0]="OFF", "ON" }
Comment on lines +10 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if these need to be part of the 'defaults'. But then, on the other hand, it makes sense to have them in one centralised file instead of having them included the file for each TX type - we currently do too much of this anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeller I already have a plan to refactor the scripts into unified logic, and just load the "layout" for the screens from files based on the screen dimensions, rather than the radio type, as all else seems to be the same - which should make maintenance much easier. I also noticed that the rx.lua script is missing from the X7 folder - do you know if this is deliberate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re missing rx.lua file, I suspect that this is just a consequence of the copy / paste way that multi TX support is done at the moment.

72 changes: 43 additions & 29 deletions src/SCRIPTS/BF/PAGES/vtx.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
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()
end

-- Vals Fields
-- 1 Device Type Band
-- 2 Band Channel
-- 3 Channel Power
-- 4 Power Pit
-- 5 Pit Device Type
-- 6 Freq Frequency

return {
read = 88, -- MSP_VTX_CONFIG
write = 89, -- MSP_VTX_SET_CONFIG
Expand All @@ -14,20 +29,14 @@ return {
labels = display.labels,
fieldLayout = display.fieldLayout,
fields = {
{ min=0, max=5, vals = { 2 }, table = { [0]="U", "A", "B", "E", "F", "R" }, upd = function(self) self.handleBandChanUpdate(self) end },
{ min=1, max=8, vals = { 3 }, upd = function(self) self.handleBandChanUpdate(self) end },
{ 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=1, vals = { 4 }, upd = function(self) self.updatePowerTable(self) end },
{ min=0, max=1, vals = { 5 }, table = { [0]="OFF", "ON" } },
{ vals = { 1 }, write = false, ro = true, table = { [1]="RTC6705",[3]="SmartAudio",[4]="Tramp",[255]="None"} },
{ 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 = {
{ 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
},
freqLookup = 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 @@ -171,23 +180,28 @@ return {
end,
updatePowerTable = function(self)
if self.values and not self.fields[3].table then
if self.values[1] == 1 then -- RTC6705
self.fields[3].table = { 25, 200 }
self.fields[3].max = 2
self.fields[4].t = nil -- don't display Pit field
self.fields[4].table = { [0]="", "" }
elseif self.values[1] == 3 then -- SmartAudio
self.fields[3].table = { 25, 200, 500, 800 }
self.fields[3].max = 4
elseif self.values[1] == 4 then -- Tramp
self.fields[3].table = { 25, 100, 200, 400, 600 }
self.fields[3].max = 5
elseif self.values[1] == 255 then -- None/Unknown
self.fields[3].t = nil -- don't display Power field
self.fields[3].max = 1
self.fields[3].table = { [1]="" }
self.fields[4].t = nil -- don't display Pit field
self.fields[4].table = { [0]="", "" }
if powerTable then
self.fields[3].table = powerTable
self.fields[3].max = #(powerTable)
else
if self.values[1] == 1 then -- RTC6705
self.fields[3].table = { 25, 200 }
self.fields[3].max = 2
self.fields[4].t = nil -- don't display Pit field
self.fields[4].table = { [0]="", "" }
elseif self.values[1] == 3 then -- SmartAudio
self.fields[3].table = { 25, 200, 500, 800 }
self.fields[3].max = 4
elseif self.values[1] == 4 then -- Tramp
self.fields[3].table = { 25, 100, 200, 400, 600 }
self.fields[3].max = 5
elseif self.values[1] == 255 then -- None/Unknown
self.fields[3].t = nil -- don't display Power field
self.fields[3].max = 1
self.fields[3].table = { [1]="" }
self.fields[4].t = nil -- don't display Pit field
self.fields[4].table = { [0]="", "" }
end
end
end
end,
Expand Down Expand Up @@ -246,4 +260,4 @@ return {
end
end
end
}
}