mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-17 05:15:20 +03:00
Store bindings
This commit is contained in:
parent
c7dfab991d
commit
497d0aa674
5 changed files with 144 additions and 16 deletions
|
@ -2,11 +2,68 @@
|
|||
|
||||
const mspHelper = require('./msp/MSPHelper');
|
||||
const serialPortHelper = require('./serialPortHelper');
|
||||
const FC = require('./fc');
|
||||
|
||||
const wizardUiBindings = (function () {
|
||||
|
||||
let self = {};
|
||||
|
||||
self.gps = function ($context) {
|
||||
mspHelper.loadFeatures(mspHelper.loadSerialPorts(function () {
|
||||
|
||||
let $port = $('#wizard-gps-port');
|
||||
let $baud = $('#wizard-gps-baud');
|
||||
let $protocol = $('#wizard-gps-protocol');
|
||||
|
||||
let ports = serialPortHelper.getPortIdentifiersForFunction('GPS');
|
||||
|
||||
let currentPort = null;
|
||||
|
||||
if (ports.length == 1) {
|
||||
currentPort = ports[0];
|
||||
}
|
||||
|
||||
let availablePorts = serialPortHelper.getPortList();
|
||||
$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>');
|
||||
}
|
||||
|
||||
serialPortHelper.getBauds('SENSOR').forEach(function (baud) {
|
||||
$baud.append('<option value="' + baud + '">' + baud + '</option>');
|
||||
});
|
||||
|
||||
let gpsProtocols = FC.getGpsProtocols();
|
||||
for (let i = 0; i < gpsProtocols.length; i++) {
|
||||
$protocol.append('<option value="' + i + '">' + gpsProtocols[i] + '</option>');
|
||||
}
|
||||
|
||||
if (currentPort !== null) {
|
||||
$port.val(currentPort);
|
||||
} else {
|
||||
$port.val(-1);
|
||||
}
|
||||
|
||||
$port.on('change', function () {
|
||||
let port = $(this).val();
|
||||
|
||||
let portConfig = serialPortHelper.getPortByIdentifier(currentPort);
|
||||
$baud.val(portConfig.sensors_baudrate);
|
||||
if (port == -1) {
|
||||
$('#wizard-gps-baud-container').hide();
|
||||
$('#wizard-gps-protocol-container').hide();
|
||||
$baud.val(serialPortHelper.getRuleByName('GPS').defaultBaud);
|
||||
} else {
|
||||
$('#wizard-gps-baud-container').show();
|
||||
$('#wizard-gps-protocol-container').show();
|
||||
}
|
||||
}).trigger('change');
|
||||
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
self.receiver = function ($content) {
|
||||
|
||||
mspHelper.loadSerialPorts(function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue