mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-25 17:25:14 +03:00
Generate selects for GPS ports in the GPS tab
This commit is contained in:
parent
a0af3d998b
commit
f0981959aa
5 changed files with 154 additions and 47 deletions
|
@ -2058,6 +2058,12 @@
|
||||||
"gpsSignalStr": {
|
"gpsSignalStr": {
|
||||||
"message": "Signal Strength"
|
"message": "Signal Strength"
|
||||||
},
|
},
|
||||||
|
"gpsPort": {
|
||||||
|
"message": "Serial Port"
|
||||||
|
},
|
||||||
|
"gpsBaud": {
|
||||||
|
"message": "Baud Rate"
|
||||||
|
},
|
||||||
"magnetometerHead": {
|
"magnetometerHead": {
|
||||||
"message": "Alignment tool"
|
"message": "Alignment tool"
|
||||||
},
|
},
|
||||||
|
|
|
@ -145,7 +145,44 @@ helper.serialPortHelper = (function () {
|
||||||
20: 'USB VCP',
|
20: 'USB VCP',
|
||||||
30: 'SOFTSERIAL1',
|
30: 'SOFTSERIAL1',
|
||||||
31: 'SOFTSERIAL2'
|
31: 'SOFTSERIAL2'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
privateScope.bauds = {
|
||||||
|
'SENSOR': [
|
||||||
|
'9600',
|
||||||
|
'19200',
|
||||||
|
'38400',
|
||||||
|
'57600',
|
||||||
|
'115200',
|
||||||
|
'230400'
|
||||||
|
],
|
||||||
|
'MSP': [
|
||||||
|
'9600',
|
||||||
|
'19200',
|
||||||
|
'38400',
|
||||||
|
'57600',
|
||||||
|
'115200'
|
||||||
|
],
|
||||||
|
'TELEMETRY': [
|
||||||
|
'AUTO',
|
||||||
|
'1200',
|
||||||
|
'2400',
|
||||||
|
'4800',
|
||||||
|
'9600',
|
||||||
|
'19200',
|
||||||
|
'38400',
|
||||||
|
'57600',
|
||||||
|
'115200'
|
||||||
|
],
|
||||||
|
'PERIPHERAL': [
|
||||||
|
'19200',
|
||||||
|
'38400',
|
||||||
|
'57600',
|
||||||
|
'115200',
|
||||||
|
'230400',
|
||||||
|
'250000'
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
privateScope.generateNames = function () {
|
privateScope.generateNames = function () {
|
||||||
if (privateScope.namesGenerated) {
|
if (privateScope.namesGenerated) {
|
||||||
|
@ -165,6 +202,16 @@ helper.serialPortHelper = (function () {
|
||||||
return privateScope.rules;
|
return privateScope.rules;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
publicScope.getRuleByName = function (name) {
|
||||||
|
for (var i = 0; i < privateScope.rules.length; i++) {
|
||||||
|
if (privateScope.rules[i].name === name) {
|
||||||
|
return privateScope.rules[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {array} functions
|
* @param {array} functions
|
||||||
|
@ -205,5 +252,53 @@ helper.serialPortHelper = (function () {
|
||||||
return privateScope.identifierToName[identifier];
|
return privateScope.identifierToName[identifier];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
publicScope.getPortIdentifiersForFunction = function (functionName) {
|
||||||
|
let identifiers = [];
|
||||||
|
|
||||||
|
for (let index = 0; index < SERIAL_CONFIG.ports.length; index++) {
|
||||||
|
let config = SERIAL_CONFIG.ports[index];
|
||||||
|
if (config.functions.indexOf(functionName) != -1) {
|
||||||
|
identifiers.push(config.identifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return identifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
publicScope.getPortList = function () {
|
||||||
|
|
||||||
|
let list = [];
|
||||||
|
|
||||||
|
for (let index = 0; index < SERIAL_CONFIG.ports.length; index++) {
|
||||||
|
let config = SERIAL_CONFIG.ports[index];
|
||||||
|
|
||||||
|
//exclude USB VCP port
|
||||||
|
if (config.identifier == 20) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let port = {
|
||||||
|
identifier: config.identifier,
|
||||||
|
displayName: privateScope.identifierToName[config.identifier]
|
||||||
|
};
|
||||||
|
list.push(port);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
};
|
||||||
|
|
||||||
|
publicScope.getBauds = function (functionName) {
|
||||||
|
return privateScope.bauds[functionName];
|
||||||
|
};
|
||||||
|
|
||||||
|
publicScope.getPortByIdentifier = function (identifier) {
|
||||||
|
for (let index = 0; index < SERIAL_CONFIG.ports.length; index++) {
|
||||||
|
let config = SERIAL_CONFIG.ports[index];
|
||||||
|
if (config.identifier == identifier) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
return publicScope;
|
return publicScope;
|
||||||
})();
|
})();
|
|
@ -20,6 +20,14 @@
|
||||||
<label for="feature-7"><span data-i18n="featureGPS"></span></label>
|
<label for="feature-7"><span data-i18n="featureGPS"></span></label>
|
||||||
<div for="feature-7" class="helpicon cf_tip" data-i18n_title="featureGPSTip"></div>
|
<div for="feature-7" class="helpicon cf_tip" data-i18n_title="featureGPSTip"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="select">
|
||||||
|
<select id="gps_port" class="gps_port"></select>
|
||||||
|
<label for="gps_port"><span data-i18n="gpsPort"></span></label>
|
||||||
|
</div>
|
||||||
|
<div class="select">
|
||||||
|
<select id="gps_baud" class="gps_baud"></select>
|
||||||
|
<label for="gps_baud"><span data-i18n="gpsBaud"></span></label>
|
||||||
|
</div>
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select id="gps_protocol" class="gps_protocol">
|
<select id="gps_protocol" class="gps_protocol">
|
||||||
<!-- list generated here -->
|
<!-- list generated here -->
|
||||||
|
|
36
tabs/gps.js
36
tabs/gps.js
|
@ -95,6 +95,42 @@ TABS.gps.initialize = function (callback) {
|
||||||
|
|
||||||
helper.features.updateUI($('.tab-gps'), FEATURES);
|
helper.features.updateUI($('.tab-gps'), FEATURES);
|
||||||
|
|
||||||
|
//Generate serial port options
|
||||||
|
let $port = $('#gps_port');
|
||||||
|
let $baud = $('#gps_baud');
|
||||||
|
|
||||||
|
let ports = helper.serialPortHelper.getPortIdentifiersForFunction('GPS');
|
||||||
|
|
||||||
|
let currentPort = null;
|
||||||
|
|
||||||
|
if (ports.length == 1) {
|
||||||
|
currentPort = ports[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
let availablePorts = helper.serialPortHelper.getPortList();
|
||||||
|
|
||||||
|
//Generate port select
|
||||||
|
$port.append('<option value="-1">NONE</option>');
|
||||||
|
for (let i = 0; i < availablePorts.length; i++) {
|
||||||
|
let port = availablePorts[i];
|
||||||
|
$port.append('<option value="' + port.identifier + '">' + port.displayName + '</option>');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Generate baud select
|
||||||
|
helper.serialPortHelper.getBauds('SENSOR').forEach(function (baud) {
|
||||||
|
$baud.append('<option value="' + baud + '">' + baud + '</option>');
|
||||||
|
});
|
||||||
|
|
||||||
|
//Select defaults
|
||||||
|
if (currentPort !== null) {
|
||||||
|
$port.val(currentPort);
|
||||||
|
let portConfig = helper.serialPortHelper.getPortByIdentifier(currentPort);
|
||||||
|
$baud.val(portConfig.sensors_baudrate);
|
||||||
|
} else {
|
||||||
|
$port.val(-1);
|
||||||
|
$baud.val(helper.serialPortHelper.getRuleByName('GPS').defaultBaud);
|
||||||
|
}
|
||||||
|
|
||||||
// generate GPS
|
// generate GPS
|
||||||
var gpsProtocols = FC.getGpsProtocols();
|
var gpsProtocols = FC.getGpsProtocols();
|
||||||
var gpsSbas = FC.getGpsSbasProviders();
|
var gpsSbas = FC.getGpsSbasProviders();
|
||||||
|
|
|
@ -4,44 +4,6 @@ TABS.ports = {};
|
||||||
|
|
||||||
TABS.ports.initialize = function (callback) {
|
TABS.ports.initialize = function (callback) {
|
||||||
|
|
||||||
var mspBaudRates = [
|
|
||||||
'9600',
|
|
||||||
'19200',
|
|
||||||
'38400',
|
|
||||||
'57600',
|
|
||||||
'115200'
|
|
||||||
];
|
|
||||||
|
|
||||||
var gpsBaudRates = [
|
|
||||||
'9600',
|
|
||||||
'19200',
|
|
||||||
'38400',
|
|
||||||
'57600',
|
|
||||||
'115200',
|
|
||||||
'230400'
|
|
||||||
];
|
|
||||||
|
|
||||||
var telemetryBaudRates_post1_6_3 = [
|
|
||||||
'AUTO',
|
|
||||||
'1200',
|
|
||||||
'2400',
|
|
||||||
'4800',
|
|
||||||
'9600',
|
|
||||||
'19200',
|
|
||||||
'38400',
|
|
||||||
'57600',
|
|
||||||
'115200'
|
|
||||||
];
|
|
||||||
|
|
||||||
var peripheralsBaudRates = [
|
|
||||||
'19200',
|
|
||||||
'38400',
|
|
||||||
'57600',
|
|
||||||
'115200',
|
|
||||||
'230400',
|
|
||||||
'250000'
|
|
||||||
];
|
|
||||||
|
|
||||||
var columns = ['data', 'logging', 'sensors', 'telemetry', 'rx', 'peripherals'];
|
var columns = ['data', 'logging', 'sensors', 'telemetry', 'rx', 'peripherals'];
|
||||||
|
|
||||||
if (GUI.active_tab != 'ports') {
|
if (GUI.active_tab != 'ports') {
|
||||||
|
@ -61,23 +23,23 @@ TABS.ports.initialize = function (callback) {
|
||||||
$elements;
|
$elements;
|
||||||
|
|
||||||
$elements = $('select.sensors_baudrate');
|
$elements = $('select.sensors_baudrate');
|
||||||
for (i = 0; i < gpsBaudRates.length; i++) {
|
for (i = 0; i < helper.serialPortHelper.getBauds('SENSOR').length; i++) {
|
||||||
$elements.append('<option value="' + gpsBaudRates[i] + '">' + gpsBaudRates[i] + '</option>');
|
$elements.append('<option value="' + helper.serialPortHelper.getBauds('SENSOR')[i] + '">' + helper.serialPortHelper.getBauds('SENSOR')[i] + '</option>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$elements = $('select.msp_baudrate');
|
$elements = $('select.msp_baudrate');
|
||||||
for (i = 0; i < mspBaudRates.length; i++) {
|
for (i = 0; i < helper.serialPortHelper.getBauds('MSP').length; i++) {
|
||||||
$elements.append('<option value="' + mspBaudRates[i] + '">' + mspBaudRates[i] + '</option>');
|
$elements.append('<option value="' + helper.serialPortHelper.getBauds('MSP')[i] + '">' + helper.serialPortHelper.getBauds('MSP')[i] + '</option>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$elements = $('select.telemetry_baudrate');
|
$elements = $('select.telemetry_baudrate');
|
||||||
for (i = 0; i < telemetryBaudRates_post1_6_3.length; i++) {
|
for (i = 0; i < helper.serialPortHelper.getBauds('TELEMETRY').length; i++) {
|
||||||
$elements.append('<option value="' + telemetryBaudRates_post1_6_3[i] + '">' + telemetryBaudRates_post1_6_3[i] + '</option>');
|
$elements.append('<option value="' + helper.serialPortHelper.getBauds('TELEMETRY')[i] + '">' + helper.serialPortHelper.getBauds('TELEMETRY')[i] + '</option>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$elements = $('select.peripherals_baudrate');
|
$elements = $('select.peripherals_baudrate');
|
||||||
for (i = 0; i < peripheralsBaudRates.length; i++) {
|
for (i = 0; i < helper.serialPortHelper.getBauds('PERIPHERAL').length; i++) {
|
||||||
$elements.append('<option value="' + peripheralsBaudRates[i] + '">' + peripheralsBaudRates[i] + '</option>');
|
$elements.append('<option value="' + helper.serialPortHelper.getBauds('PERIPHERAL')[i] + '">' + helper.serialPortHelper.getBauds('PERIPHERAL')[i] + '</option>');
|
||||||
}
|
}
|
||||||
|
|
||||||
var ports_e = $('.tab-ports .ports');
|
var ports_e = $('.tab-ports .ports');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue