mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
Merge pull request #2006 from iNavFlight/dzikuvx-ports-tab-improvements
Port tab improvements
This commit is contained in:
commit
db954f8b8e
2 changed files with 93 additions and 39 deletions
|
@ -11,96 +11,113 @@ helper.serialPortHelper = (function () {
|
|||
|
||||
// This is a list of all the rules for the serial ports as well as their names
|
||||
privateScope.rules = [
|
||||
{ name: 'MSP', groups: ['data', 'msp'], maxPorts: 2 },
|
||||
{ name: 'GPS', groups: ['sensors'], maxPorts: 1, defaultBaud: 115200 },
|
||||
{ name: 'TELEMETRY_FRSKY', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['blackbox'], maxPorts: 1 },
|
||||
{ name: 'TELEMETRY_HOTT', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['blackbox'], maxPorts: 1 },
|
||||
{ name: 'TELEMETRY_SMARTPORT', groups: ['telemetry'], maxPorts: 1 },
|
||||
{ name: 'TELEMETRY_LTM', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['blackbox'], maxPorts: 1 },
|
||||
{ name: 'RX_SERIAL', groups: ['rx'], maxPorts: 1 },
|
||||
{ name: 'BLACKBOX', groups: ['peripherals'], sharableWith: ['msp'], notSharableWith: ['telemetry'], maxPorts: 1 },
|
||||
{
|
||||
name: 'MSP',
|
||||
groups: ['data']
|
||||
},
|
||||
{
|
||||
name: 'GPS',
|
||||
groups: ['sensors'],
|
||||
defaultBaud: 115200,
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_FRSKY',
|
||||
groups: ['telemetry']
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_HOTT',
|
||||
groups: ['telemetry']
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_SMARTPORT',
|
||||
groups: ['telemetry']
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_LTM',
|
||||
groups: ['telemetry']
|
||||
},
|
||||
{
|
||||
name: 'RX_SERIAL',
|
||||
groups: ['rx'],
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'BLACKBOX',
|
||||
groups: ['peripherals']
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_MAVLINK',
|
||||
groups: ['telemetry'],
|
||||
sharableWith: ['msp'],
|
||||
notSharableWith: ['blackbox'],
|
||||
maxPorts: 1
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_IBUS',
|
||||
groups: ['telemetry'],
|
||||
sharableWith: ['msp'],
|
||||
notSharableWith: ['blackbox'],
|
||||
maxPorts: 1
|
||||
},
|
||||
{
|
||||
name: 'RANGEFINDER',
|
||||
groups: ['sensors'],
|
||||
maxPorts: 1
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'GSM_SMS',
|
||||
groups: ['telemetry'],
|
||||
maxPorts: 1
|
||||
},
|
||||
{
|
||||
name: 'RUNCAM_DEVICE_CONTROL',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1
|
||||
},
|
||||
{
|
||||
name: 'TBS_SMARTAUDIO',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'IRC_TRAMP',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'VTX_FFPV',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'ESC',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1,
|
||||
defaultBaud: 115200
|
||||
defaultBaud: 115200,
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'OPFLOW',
|
||||
groups: ['sensors'],
|
||||
maxPorts: 1
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'FRSKY_OSD',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1,
|
||||
defaultBaud: 250000
|
||||
defaultBaud: 250000,
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'DJI_FPV',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1,
|
||||
defaultBaud: 115200
|
||||
defaultBaud: 115200,
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'MSP_DISPLAYPORT',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'SMARTPORT_MASTER',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1,
|
||||
defaultBaud: 57600
|
||||
},
|
||||
{
|
||||
name: 'SBUS_OUTPUT',
|
||||
groups: ['peripherals'],
|
||||
maxPorts: 1,
|
||||
defaultBaud: 115200
|
||||
}
|
||||
];
|
||||
|
|
|
@ -101,7 +101,7 @@ TABS.ports.initialize = function (callback) {
|
|||
select_e = functions_e.find(selectElementSelector);
|
||||
|
||||
if (select_e.length == 0) {
|
||||
functions_e.prepend('<span class="function"><select name="' + selectElementName + '" class="' + selectElementName + '" onchange="updateDefaultBaud(\'' + functions_e_id + '\', \'' + column + '\')" /></span>');
|
||||
functions_e.prepend('<span class="function"><select name="' + selectElementName + '" class="function-select ' + selectElementName + '" onchange="updateDefaultBaud(\'' + functions_e_id + '\', \'' + column + '\')" /></span>');
|
||||
select_e = functions_e.find(selectElementSelector);
|
||||
var disabledText = chrome.i18n.getMessage('portsTelemetryDisabled');
|
||||
select_e.append('<option value="">' + disabledText + '</option>');
|
||||
|
@ -118,6 +118,48 @@ TABS.ports.initialize = function (callback) {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
$('table.ports tbody').on('change', 'select', onSwitchChange);
|
||||
$('table.ports tbody').on('change', 'input', onSwitchChange);
|
||||
}
|
||||
|
||||
function onSwitchChange(e) {
|
||||
let $cT = $(e.currentTarget);
|
||||
|
||||
let functionName = $cT.val();
|
||||
let rule = helper.serialPortHelper.getRuleByName($cT.val());
|
||||
|
||||
//if type is checkbox then process only if selected
|
||||
if ($cT.is('input[type="checkbox"]') && !$cT.is(':checked')) {
|
||||
return;
|
||||
}
|
||||
//if type select then process only if selected
|
||||
if ($cT.is('select') && !functionName) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rule && rule.isUnique) {
|
||||
let $selects = $cT.closest('tr').find('.function-select');
|
||||
$selects.each(function (index, element) {
|
||||
|
||||
let $element = $(element);
|
||||
|
||||
if ($element.val() != functionName) {
|
||||
$element.val('');
|
||||
}
|
||||
});
|
||||
|
||||
let $checkboxes = $cT.closest('tr').find('input[type="checkbox"]');
|
||||
$checkboxes.each(function (index, element) {
|
||||
let $element = $(element);
|
||||
|
||||
if ($element.val() != functionName) {
|
||||
$element.prop('checked', false);
|
||||
$element.trigger('change');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function on_tab_loaded_handler() {
|
||||
|
@ -206,15 +248,10 @@ function updateDefaultBaud(baudSelect, column) {
|
|||
let portName = section.find('.function-' + column).val();
|
||||
let baudRate = (column === 'telemetry') ? "AUTO" : 115200;;
|
||||
|
||||
let rules = helper.serialPortHelper.getRules();
|
||||
let rule = helper.serialPortHelper.getRuleByName(portName);
|
||||
|
||||
for (i = 0; i < rules.length; i++) {
|
||||
if (rules[i].name === portName) {
|
||||
if (typeof rules[i].defaultBaud !== 'undefined') {
|
||||
baudRate = rules[i].defaultBaud;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (rule && typeof rule.defaultBaud !== 'undefined') {
|
||||
baudRate = rule.defaultBaud;
|
||||
}
|
||||
|
||||
section.find("." + column + "_baudrate").children('[value=' + baudRate + ']').prop('selected', true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue