Skip to content

Commit

Permalink
vtx: fetch powerlevel count from fc
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Oct 1, 2024
1 parent ea40239 commit 20c4812
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
3 changes: 3 additions & 0 deletions js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ var FC = {
power: 0,
pitmode: 0,
low_power_disarm: 0,
band_count: 0,
channel_count: 0,
power_count: 0,
};

this.ADVANCED_CONFIG = {
Expand Down
5 changes: 5 additions & 0 deletions js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,11 @@ var mspHelper = (function () {
// Ignore wether the VTX is ready for now
offset++;
FC.VTX_CONFIG.low_power_disarm = data.getUint8(offset++);
// Assume we got a vtx table
offset++;
FC.VTX_CONFIG.band_count = data.getUint8(offset++);
FC.VTX_CONFIG.channel_count = data.getUint8(offset++);
FC.VTX_CONFIG.power_count = data.getUint8(offset++);
}
break;
case MSPCodes.MSP_ADVANCED_CONFIG:
Expand Down
12 changes: 1 addition & 11 deletions js/vtx.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,7 @@ var VTX = (function() {

self.CHANNEL_MIN = 1;
self.CHANNEL_MAX = 8;

self.getMinPower = function(vtxDev) {
return 1;
}

self.getMaxPower = function(vtxDev) {
if ((vtxDev == self.DEV_SMARTAUDIO) || (vtxDev == self.DEV_TRAMP)) {
return 5;
}
return 3;
}
self.POWER_MIN = 1;

self.LOW_POWER_DISARM_MIN = 0;
self.LOW_POWER_DISARM_MAX = 2;
Expand Down
4 changes: 1 addition & 3 deletions tabs/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {

var vtx_power = $('#vtx_power');
vtx_power.empty();
var minPower = VTX.getMinPower(FC.VTX_CONFIG.device_type);
var maxPower = VTX.getMaxPower(FC.VTX_CONFIG.device_type);
for (var ii = minPower; ii <= maxPower; ii++) {
for (var ii = VTX.POWER_MIN; ii <= FC.VTX_CONFIG.power_count; ii++) {
var option = $('<option value="' + ii + '">' + ii + '</option>');
if (ii == FC.VTX_CONFIG.power) {
option.prop('selected', true);
Expand Down

0 comments on commit 20c4812

Please sign in to comment.