|
| 1 | + |
| 2 | +return { |
| 3 | + read = 88, -- MSP_VTX_CONFIG |
| 4 | + write = 89, -- MSP_VTX_SET_CONFIG |
| 5 | + eepromWrite = true, |
| 6 | + reboot = false, |
| 7 | + saveMaxRetries = 2, |
| 8 | + saveTimeout = 300, -- 3s |
| 9 | + title = "VTX", |
| 10 | + minBytes = 5, |
| 11 | + text= { |
| 12 | + { t = "Band", x = 50, y = 50 }, |
| 13 | + { t = "Channel", x = 50, y = 100 }, |
| 14 | + { t = "Power", x = 50, y = 150 }, |
| 15 | + { t = "Pit", x = 50, y = 200 }, |
| 16 | + { t = "Proto", x = 240, y = 50 }, |
| 17 | + { t = "Freq", x = 240, y = 100 }, |
| 18 | + }, |
| 19 | + fields = { |
| 20 | + { x = 152, y = 50, min=1, max=5, vals = { 2 }, |
| 21 | + table = { "A", "B", "E", "F", "R" }, |
| 22 | + upd = function(self) self.updateVTXFreq(self) end }, |
| 23 | + { x = 152, y = 100, min=1, max=8, vals = { 3 }, |
| 24 | + upd = function(self) self.updateVTXFreq(self) end }, |
| 25 | + { x = 152, y = 150, min=1, vals = { 4 }, |
| 26 | + upd = function(self) self.updatePowerTable(self) end }, |
| 27 | + { x = 152, y = 200, min=0, max=1, vals = { 5 }, |
| 28 | + table = { [0]="OFF", "ON" } }, |
| 29 | + { x = 332, y = 50, write = false, ro = true, vals = { 1 }, |
| 30 | + table = {[3]="SmartAudio",[4]="Tramp",[255]="None"} }, |
| 31 | + { x = 332, y = 100, min=5000, max=6000, ro=true }, |
| 32 | + }, |
| 33 | + freqLookup = { |
| 34 | + { 5865, 5845, 5825, 5805, 5785, 5765, 5745, 5725 }, -- Boscam A |
| 35 | + { 5733, 5752, 5771, 5790, 5809, 5828, 5847, 5866 }, -- Boscam B |
| 36 | + { 5705, 5685, 5665, 5645, 5885, 5905, 5925, 5945 }, -- Boscam E |
| 37 | + { 5740, 5760, 5780, 5800, 5820, 5840, 5860, 5880 }, -- FatShark |
| 38 | + { 5658, 5695, 5732, 5769, 5806, 5843, 5880, 5917 }, -- RaceBand |
| 39 | + }, |
| 40 | + postLoad = function (self) |
| 41 | + if self.values[2] == 0 or self.values[3] == 0 or self.values[4] == 0 then |
| 42 | + self.values = {} |
| 43 | + end |
| 44 | + end, |
| 45 | + preSave = function(self) |
| 46 | + local valsTemp = {} |
| 47 | + local channel = (self.values[2]-1)*8 + self.values[3]-1 |
| 48 | + valsTemp[1] = bit32.band(channel,0xFF) |
| 49 | + valsTemp[2] = bit32.rshift(channel,8) |
| 50 | + valsTemp[3] = self.values[4] |
| 51 | + valsTemp[4] = self.values[5] |
| 52 | + return valsTemp |
| 53 | + end, |
| 54 | + updatePowerTable = function(self) |
| 55 | + if self.values and not self.fields[3].table then |
| 56 | + if self.values[1] == 3 then |
| 57 | + self.fields[3].table = { 25, 200, 500, 800 } |
| 58 | + self.fields[3].max = 4 |
| 59 | + elseif self.values[1] == 4 then |
| 60 | + self.fields[3].table = { 25, 100, 200, 400, 600 } |
| 61 | + self.fields[3].max = 5 |
| 62 | + end |
| 63 | + end |
| 64 | + end, |
| 65 | + updateVTXFreq = function(self) |
| 66 | + if (#(self.values) or 0) >= self.minBytes then |
| 67 | + if (self.fields[2].value or 0) > 0 and (self.fields[3].value or 0) > 0 then |
| 68 | + self.fields[6].value = self.freqLookup[self.values[2]][self.values[3]] |
| 69 | + end |
| 70 | + end |
| 71 | + end |
| 72 | +} |
0 commit comments