1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-16 04:45:18 +03:00

Allow default baud rates on ports page

This PR allows default baud rates to be set, per function, on the ports page. For example, SmartPort should run at 57600 baud. But, when the option is selected currently, the baud rate stays at 115200. This PR corrects that.
This commit is contained in:
Darren Lines 2022-12-25 20:28:02 +00:00
parent 3843582887
commit f0c593859c
4 changed files with 65 additions and 36 deletions

View file

@ -1167,7 +1167,7 @@
"message": "DJI FPV VTX" "message": "DJI FPV VTX"
}, },
"portsFunction_MSP_DISPLAYPORT": { "portsFunction_MSP_DISPLAYPORT": {
"message": "MSP Displayport" "message": "MSP DisplayPort"
}, },
"pidTuning_ShowAllPIDs": { "pidTuning_ShowAllPIDs": {
"message": "Show all PIDs" "message": "Show all PIDs"

View file

@ -807,7 +807,7 @@ var mspHelper = (function (gui) {
msp_baudrate: BAUD_RATES[data.getUint8(offset + 5)], msp_baudrate: BAUD_RATES[data.getUint8(offset + 5)],
sensors_baudrate: BAUD_RATES[data.getUint8(offset + 6)], sensors_baudrate: BAUD_RATES[data.getUint8(offset + 6)],
telemetry_baudrate: BAUD_RATES[data.getUint8(offset + 7)], telemetry_baudrate: BAUD_RATES[data.getUint8(offset + 7)],
blackbox_baudrate: BAUD_RATES[data.getUint8(offset + 8)] peripherals_baudrate: BAUD_RATES[data.getUint8(offset + 8)]
}; };
offset += bytesPerPort; offset += bytesPerPort;
@ -1782,7 +1782,7 @@ var mspHelper = (function (gui) {
buffer.push(BAUD_RATES.indexOf(serialPort.msp_baudrate)); buffer.push(BAUD_RATES.indexOf(serialPort.msp_baudrate));
buffer.push(BAUD_RATES.indexOf(serialPort.sensors_baudrate)); buffer.push(BAUD_RATES.indexOf(serialPort.sensors_baudrate));
buffer.push(BAUD_RATES.indexOf(serialPort.telemetry_baudrate)); buffer.push(BAUD_RATES.indexOf(serialPort.telemetry_baudrate));
buffer.push(BAUD_RATES.indexOf(serialPort.blackbox_baudrate)); buffer.push(BAUD_RATES.indexOf(serialPort.peripherals_baudrate));
} }
break; break;

View file

@ -49,14 +49,14 @@
<td class="functionsCell-data"><select class="msp_baudrate"> <td class="functionsCell-data"><select class="msp_baudrate">
<!-- list generated here --> <!-- list generated here -->
</select></td> </select></td>
<td class="functionsCell-telemetry"><select class="telemetry_baudrate"> <td class="functionsCell-telemetry"><select class="telemetry_baudrate"">
<!-- list generated here --> <!-- list generated here -->
</select></td> </select></td>
<td class="functionsCell-rx"></td> <td class="functionsCell-rx"></td>
<td class="functionsCell-sensors"><select class="sensors_baudrate"> <td class="functionsCell-sensors"><select class="sensors_baudrate">
<!-- list generated here --> <!-- list generated here -->
</select></td> </select></td>
<td class="functionsCell-peripherals"><select class="blackbox_baudrate"> <td class="functionsCell-peripherals"><select class="peripherals_baudrate">
<!-- list generated here --> <!-- list generated here -->
</select></td> </select></td>
</tr> </tr>

View file

@ -2,11 +2,17 @@
TABS.ports = {}; TABS.ports = {};
var portFunctionRules;
TABS.ports.initialize = function (callback) { TABS.ports.initialize = function (callback) {
var functionRules = [ /* ** portFunctionRules Notes **
Do not set a defaultBaud for functions in the telemetry group.
These should default to AUTO, which is handled in the onchange function. The baud rate is then set by the firmware.
*/
portFunctionRules = [
{name: 'MSP', groups: ['data', 'msp'], maxPorts: 2}, {name: 'MSP', groups: ['data', 'msp'], maxPorts: 2},
{name: 'GPS', groups: ['sensors'], maxPorts: 1}, {name: 'GPS', groups: ['sensors'], maxPorts: 1, defaultBaud: 115200},
{name: 'TELEMETRY_FRSKY', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['blackbox'], maxPorts: 1}, {name: 'TELEMETRY_FRSKY', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['blackbox'], maxPorts: 1},
{name: 'TELEMETRY_HOTT', 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_SMARTPORT', groups: ['telemetry'], maxPorts: 1},
@ -15,7 +21,7 @@ TABS.ports.initialize = function (callback) {
{name: 'BLACKBOX', groups: ['peripherals'], sharableWith: ['msp'], notSharableWith: ['telemetry'], maxPorts: 1} {name: 'BLACKBOX', groups: ['peripherals'], sharableWith: ['msp'], notSharableWith: ['telemetry'], maxPorts: 1}
]; ];
functionRules.push({ portFunctionRules.push({
name: 'TELEMETRY_MAVLINK', name: 'TELEMETRY_MAVLINK',
groups: ['telemetry'], groups: ['telemetry'],
sharableWith: ['msp'], sharableWith: ['msp'],
@ -26,7 +32,7 @@ TABS.ports.initialize = function (callback) {
/* /*
* Support for FlySky iBus Telemetry * Support for FlySky iBus Telemetry
*/ */
functionRules.push({ portFunctionRules.push({
name: 'TELEMETRY_IBUS', name: 'TELEMETRY_IBUS',
groups: ['telemetry'], groups: ['telemetry'],
sharableWith: ['msp'], sharableWith: ['msp'],
@ -34,79 +40,83 @@ TABS.ports.initialize = function (callback) {
maxPorts: 1 maxPorts: 1
}); });
functionRules.push({ portFunctionRules.push({
name: 'RANGEFINDER', name: 'RANGEFINDER',
groups: ['sensors'], groups: ['sensors'],
maxPorts: 1 } maxPorts: 1 }
); );
functionRules.push({ portFunctionRules.push({
name: 'GSM_SMS', name: 'GSM_SMS',
groups: ['telemetry'], groups: ['telemetry'],
maxPorts: 1 } maxPorts: 1 }
); );
// support configure RunCam Device // support configure RunCam Device
functionRules.push({ portFunctionRules.push({
name: 'RUNCAM_DEVICE_CONTROL', name: 'RUNCAM_DEVICE_CONTROL',
groups: ['peripherals'], groups: ['peripherals'],
maxPorts: 1 } maxPorts: 1 }
); );
functionRules.push({ portFunctionRules.push({
name: 'TBS_SMARTAUDIO', name: 'TBS_SMARTAUDIO',
groups: ['peripherals'], groups: ['peripherals'],
maxPorts: 1 } maxPorts: 1 }
); );
functionRules.push({ portFunctionRules.push({
name: 'IRC_TRAMP', name: 'IRC_TRAMP',
groups: ['peripherals'], groups: ['peripherals'],
maxPorts: 1 } maxPorts: 1 }
); );
functionRules.push({ portFunctionRules.push({
name: 'VTX_FFPV', name: 'VTX_FFPV',
groups: ['peripherals'], groups: ['peripherals'],
maxPorts: 1 } maxPorts: 1 }
); );
functionRules.push({ portFunctionRules.push({
name: 'OPFLOW', name: 'OPFLOW',
groups: ['sensors'], groups: ['sensors'],
maxPorts: 1 } maxPorts: 1 }
); );
functionRules.push({ portFunctionRules.push({
name: 'ESC', name: 'ESC',
groups: ['peripherals'], groups: ['peripherals'],
maxPorts: 1 } maxPorts: 1,
defaultBaud: 115200 }
); );
functionRules.push({ portFunctionRules.push({
name: 'FRSKY_OSD', name: 'FRSKY_OSD',
groups: ['peripherals'], groups: ['peripherals'],
maxPorts: 1 } maxPorts: 1,
defaultBaud: 250000 }
); );
functionRules.push({ portFunctionRules.push({
name: 'DJI_FPV', name: 'DJI_FPV',
groups: ['peripherals'], groups: ['peripherals'],
maxPorts: 1 } maxPorts: 1,
defaultBaud: 115200 }
); );
functionRules.push({ portFunctionRules.push({
name: 'MSP_DISPLAYPORT', name: 'MSP_DISPLAYPORT',
groups: ['peripherals'], groups: ['peripherals'],
maxPorts: 1 } maxPorts: 1 }
); );
functionRules.push({ portFunctionRules.push({
name: 'SMARTPORT_MASTER', name: 'SMARTPORT_MASTER',
groups: ['peripherals'], groups: ['peripherals'],
maxPorts: 1 } maxPorts: 1,
defaultBaud: 57600 }
); );
for (var i = 0; i < functionRules.length; i++) { for (var i = 0; i < portFunctionRules.length; i++) {
functionRules[i].displayName = chrome.i18n.getMessage('portsFunction_' + functionRules[i].name); portFunctionRules[i].displayName = chrome.i18n.getMessage('portsFunction_' + portFunctionRules[i].name);
} }
var mspBaudRates = [ var mspBaudRates = [
@ -137,7 +147,7 @@ TABS.ports.initialize = function (callback) {
'115200' '115200'
]; ];
var blackboxBaudRates = [ var peripheralsBaudRates = [
'19200', '19200',
'38400', '38400',
'57600', '57600',
@ -199,9 +209,9 @@ TABS.ports.initialize = function (callback) {
$elements.append('<option value="' + telemetryBaudRates_post1_6_3[i] + '">' + telemetryBaudRates_post1_6_3[i] + '</option>'); $elements.append('<option value="' + telemetryBaudRates_post1_6_3[i] + '">' + telemetryBaudRates_post1_6_3[i] + '</option>');
} }
$elements = $('select.blackbox_baudrate'); $elements = $('select.peripherals_baudrate');
for (i = 0; i < blackboxBaudRates.length; i++) { for (i = 0; i < peripheralsBaudRates.length; i++) {
$elements.append('<option value="' + blackboxBaudRates[i] + '">' + blackboxBaudRates[i] + '</option>'); $elements.append('<option value="' + peripheralsBaudRates[i] + '">' + peripheralsBaudRates[i] + '</option>');
} }
var ports_e = $('.tab-ports .ports'); var ports_e = $('.tab-ports .ports');
@ -216,7 +226,7 @@ TABS.ports.initialize = function (callback) {
port_configuration_e.find('select.msp_baudrate').val(serialPort.msp_baudrate); port_configuration_e.find('select.msp_baudrate').val(serialPort.msp_baudrate);
port_configuration_e.find('select.telemetry_baudrate').val(serialPort.telemetry_baudrate); port_configuration_e.find('select.telemetry_baudrate').val(serialPort.telemetry_baudrate);
port_configuration_e.find('select.sensors_baudrate').val(serialPort.sensors_baudrate); port_configuration_e.find('select.sensors_baudrate').val(serialPort.sensors_baudrate);
port_configuration_e.find('select.blackbox_baudrate').val(serialPort.blackbox_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(portIdentifierToNameMapping[serialPort.identifier]);
@ -228,9 +238,11 @@ TABS.ports.initialize = function (callback) {
var column = columns[columnIndex]; var column = columns[columnIndex];
var functions_e = $(port_configuration_e).find('.functionsCell-' + column); var functions_e = $(port_configuration_e).find('.functionsCell-' + column);
let functions_e_id = "portFunc-" + column + "-" + portIndex;
functions_e.attr("id", functions_e_id);
for (i = 0; i < functionRules.length; i++) { for (i = 0; i < portFunctionRules.length; i++) {
var functionRule = functionRules[i]; var functionRule = portFunctionRules[i];
var functionName = functionRule.name; var functionName = functionRule.name;
if (functionRule.groups.indexOf(column) == -1) { if (functionRule.groups.indexOf(column) == -1) {
@ -254,7 +266,7 @@ TABS.ports.initialize = function (callback) {
select_e = functions_e.find(selectElementSelector); select_e = functions_e.find(selectElementSelector);
if (select_e.size() == 0) { if (select_e.size() == 0) {
functions_e.prepend('<span class="function"><select name="' + selectElementName + '" /></span>'); functions_e.prepend('<span class="function"><select name="' + selectElementName + '" class="' + selectElementName + '" onchange="updateDefaultBaud(\'' + functions_e_id + '\', \'' + column + '\')" /></span>');
select_e = functions_e.find(selectElementSelector); select_e = functions_e.find(selectElementSelector);
var disabledText = chrome.i18n.getMessage('portsTelemetryDisabled'); var disabledText = chrome.i18n.getMessage('portsTelemetryDisabled');
select_e.append('<option value="">' + disabledText + '</option>'); select_e.append('<option value="">' + disabledText + '</option>');
@ -322,7 +334,7 @@ TABS.ports.initialize = function (callback) {
msp_baudrate: $(portConfiguration_e).find('.msp_baudrate').val(), msp_baudrate: $(portConfiguration_e).find('.msp_baudrate').val(),
telemetry_baudrate: $(portConfiguration_e).find('.telemetry_baudrate').val(), telemetry_baudrate: $(portConfiguration_e).find('.telemetry_baudrate').val(),
sensors_baudrate: $(portConfiguration_e).find('.sensors_baudrate').val(), sensors_baudrate: $(portConfiguration_e).find('.sensors_baudrate').val(),
blackbox_baudrate: $(portConfiguration_e).find('.blackbox_baudrate').val(), peripherals_baudrate: $(portConfiguration_e).find('.peripherals_baudrate').val(),
identifier: oldSerialPort.identifier identifier: oldSerialPort.identifier
}; };
SERIAL_CONFIG.ports.push(serialPort); SERIAL_CONFIG.ports.push(serialPort);
@ -349,6 +361,23 @@ TABS.ports.initialize = function (callback) {
} }
}; };
function updateDefaultBaud(baudSelect, column) {
let section = $("#" + baudSelect);
let portName = section.find('.function-' + column).val();
let baudRate = (column === 'telemetry') ? "AUTO" : 115200;;
for (i = 0; i < portFunctionRules.length; i++) {
if (portFunctionRules[i].name === portName) {
if (typeof portFunctionRules[i].defaultBaud !== 'undefined') {
baudRate = portFunctionRules[i].defaultBaud;
}
break;
}
}
section.find("." + column + "_baudrate").children('[value=' + baudRate + ']').prop('selected', true);
}
TABS.ports.cleanup = function (callback) { TABS.ports.cleanup = function (callback) {
if (callback) callback(); if (callback) callback();
}; };