mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-17 05:15:20 +03:00
Refactor how port names as derived
This commit is contained in:
parent
9f065fc1a6
commit
a0af3d998b
3 changed files with 21 additions and 17 deletions
|
@ -133,6 +133,20 @@ helper.serialPortHelper = (function () {
|
|||
'MSP_DISPLAYPORT': 25,
|
||||
};
|
||||
|
||||
privateScope.identifierToName = {
|
||||
0: 'UART1',
|
||||
1: 'UART2',
|
||||
2: 'UART3',
|
||||
3: 'UART4',
|
||||
4: 'UART5',
|
||||
5: 'UART6',
|
||||
6: 'UART7',
|
||||
7: 'UART8',
|
||||
20: 'USB VCP',
|
||||
30: 'SOFTSERIAL1',
|
||||
31: 'SOFTSERIAL2'
|
||||
};
|
||||
|
||||
privateScope.generateNames = function () {
|
||||
if (privateScope.namesGenerated) {
|
||||
return;
|
||||
|
@ -187,5 +201,9 @@ helper.serialPortHelper = (function () {
|
|||
return functions;
|
||||
};
|
||||
|
||||
publicScope.getPortName = function (identifier) {
|
||||
return privateScope.identifierToName[identifier];
|
||||
};
|
||||
|
||||
return publicScope;
|
||||
})();
|
|
@ -33,12 +33,11 @@ TABS.gps.initialize = function (callback) {
|
|||
19: 'adsb_12.png', // ADSB_EMITTER_TYPE_POINT_OBSTACLE
|
||||
};
|
||||
|
||||
|
||||
|
||||
var loadChainer = new MSPChainerClass();
|
||||
|
||||
var loadChain = [
|
||||
mspHelper.loadFeatures,
|
||||
mspHelper.loadSerialPorts,
|
||||
mspHelper.loadMiscV2
|
||||
];
|
||||
|
||||
|
@ -50,6 +49,7 @@ TABS.gps.initialize = function (callback) {
|
|||
|
||||
var saveChain = [
|
||||
mspHelper.saveMiscV2,
|
||||
mspHelper.saveSerialPorts,
|
||||
saveSettings,
|
||||
mspHelper.saveToEeprom
|
||||
];
|
||||
|
|
|
@ -57,20 +57,6 @@ TABS.ports.initialize = function (callback) {
|
|||
|
||||
$(".tab-ports").addClass("supported");
|
||||
|
||||
var portIdentifierToNameMapping = {
|
||||
0: 'UART1',
|
||||
1: 'UART2',
|
||||
2: 'UART3',
|
||||
3: 'UART4',
|
||||
4: 'UART5',
|
||||
5: 'UART6',
|
||||
6: 'UART7',
|
||||
7: 'UART8',
|
||||
20: 'USB VCP',
|
||||
30: 'SOFTSERIAL1',
|
||||
31: 'SOFTSERIAL2'
|
||||
};
|
||||
|
||||
var i,
|
||||
$elements;
|
||||
|
||||
|
@ -111,7 +97,7 @@ TABS.ports.initialize = function (callback) {
|
|||
port_configuration_e.find('select.sensors_baudrate').val(serialPort.sensors_baudrate);
|
||||
port_configuration_e.find('select.peripherals_baudrate').val(serialPort.peripherals_baudrate);
|
||||
|
||||
port_configuration_e.find('.identifier').text(portIdentifierToNameMapping[serialPort.identifier]);
|
||||
port_configuration_e.find('.identifier').text(helper.serialPortHelper.getPortName(serialPort.identifier));
|
||||
if (serialPort.identifier >= 30) {
|
||||
port_configuration_e.find('.softSerialWarning').css("display", "inline")
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue