mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-12 19:10:21 +03:00
Store bindings
This commit is contained in:
parent
c7dfab991d
commit
497d0aa674
5 changed files with 144 additions and 16 deletions
|
@ -72,6 +72,30 @@ var defaultsDialog = (function () {
|
|||
name: "receiverProtocol",
|
||||
value: $container.find('#wizard-receiver-protocol option:selected').text()
|
||||
});
|
||||
} else if (stepName == "gps") {
|
||||
let port = $container.find('#wizard-gps-port').val();
|
||||
let baud = $container.find('#wizard-gps-baud').val();
|
||||
let protocol = $container.find('#wizard-gps-protocol option:selected').text();
|
||||
|
||||
privateScope.wizardSettings.push({
|
||||
name: "gpsPort",
|
||||
value: port
|
||||
});
|
||||
|
||||
privateScope.wizardSettings.push({
|
||||
name: "gpsBaud",
|
||||
value: baud
|
||||
});
|
||||
|
||||
privateScope.wizardSettings.push({
|
||||
name: "gpsProtocol",
|
||||
value: protocol
|
||||
});
|
||||
|
||||
// privateScope.wizardSettings.push({
|
||||
// });
|
||||
|
||||
// let gpsBit = FC.getFeatures().find( feature => feature.name === 'GPS' ).bit;
|
||||
}
|
||||
|
||||
privateScope.wizard(selectedDefaultPreset, wizardStep + 1);
|
||||
|
@ -88,13 +112,13 @@ var defaultsDialog = (function () {
|
|||
$container.hide();
|
||||
|
||||
wizardSaveFramework.persist(privateScope.wizardSettings, function () {
|
||||
mspHelper.saveToEeprom(function () {
|
||||
//noinspection JSUnresolvedVariable
|
||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||
if (selectedDefaultPreset.reboot) {
|
||||
privateScope.reboot();
|
||||
}
|
||||
});
|
||||
// mspHelper.saveToEeprom(function () {
|
||||
// //noinspection JSUnresolvedVariable
|
||||
// GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||
// if (selectedDefaultPreset.reboot) {
|
||||
// privateScope.reboot();
|
||||
// }
|
||||
// });
|
||||
});
|
||||
} else {
|
||||
const $content = $container.find('.defaults-dialog__wizard');
|
||||
|
@ -121,6 +145,12 @@ var defaultsDialog = (function () {
|
|||
* Bindings executed when the receiver wizard tab is loaded
|
||||
*/
|
||||
wizardUiBindings.receiver($content);
|
||||
} else if (stepName == "gps") {
|
||||
/**
|
||||
* Bindings executed when the GPS wizard tab is loaded
|
||||
*
|
||||
*/
|
||||
wizardUiBindings.gps($content);
|
||||
}
|
||||
|
||||
Settings.configureInputs().then(
|
||||
|
@ -346,9 +376,9 @@ var defaultsDialog = (function () {
|
|||
|
||||
privateScope.onInitSettingReturned = function (promise) {
|
||||
|
||||
if (promise.value > 0) {
|
||||
return; //Defaults were applied, we can just ignore
|
||||
}
|
||||
// if (promise.value > 0) {
|
||||
// return; //Defaults were applied, we can just ignore
|
||||
// }
|
||||
|
||||
privateScope.render();
|
||||
$container.show();
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
var defaultsDialogData = [
|
||||
{
|
||||
"title": 'Wizard',
|
||||
"id": 63,
|
||||
"notRecommended": false,
|
||||
"reboot": false,
|
||||
"mixerToApply": 3,
|
||||
"wizardPages": ['receiver', 'gps'],
|
||||
"settings": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": 'Mini Quad with 3" propellers',
|
||||
"id": 6,
|
||||
"notRecommended": false,
|
||||
"reboot": true,
|
||||
"mixerToApply": 3,
|
||||
"wizardPages": ['receiver'],
|
||||
"wizardPages": ['receiver', 'gps'],
|
||||
"settings": [
|
||||
{
|
||||
key: "model_preview_type",
|
||||
|
|
|
@ -3,16 +3,13 @@
|
|||
const mspHelper = require('./msp/MSPHelper');
|
||||
const serialPortHelper = require('./serialPortHelper');
|
||||
const FC = require('./fc');
|
||||
const features = require('./feature_framework');
|
||||
|
||||
var wizardSaveFramework = (function () {
|
||||
|
||||
let self = {};
|
||||
|
||||
self.saveSetting = function (config, callback) {
|
||||
/*
|
||||
serialrx_provider to 2
|
||||
serialrx_provider to 6
|
||||
*/
|
||||
|
||||
switch (config.name) {
|
||||
case 'receiverPort':
|
||||
|
@ -22,6 +19,27 @@ var wizardSaveFramework = (function () {
|
|||
case 'receiverProtocol':
|
||||
mspHelper.setSetting('serialrx_provider', config.value, callback);
|
||||
break;
|
||||
case 'gpsPort':
|
||||
console.log(config);
|
||||
|
||||
let gpsBit = FC.getFeatures().find( feature => feature.name === 'GPS' ).bit;
|
||||
|
||||
if (config.value == '-1') {
|
||||
features.unset(gpsBit);
|
||||
|
||||
console.log('Unset GPS');
|
||||
|
||||
} else {
|
||||
features.set(gpsBit);
|
||||
console.log('Set GPS');
|
||||
}
|
||||
break;
|
||||
case 'gpsBaud':
|
||||
console.log(config);
|
||||
break;
|
||||
case 'gpsProtocol':
|
||||
console.log(config);
|
||||
break;
|
||||
default:
|
||||
callback();
|
||||
break;
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -1 +1,14 @@
|
|||
<h2>GPS wizard</h2>
|
||||
<h2>GPS wizard</h2>
|
||||
<p>
|
||||
Configure GPS and port. If you unsure about serial port or protocol, click `Skip` to go to the next page.
|
||||
You can change those settings later with the configurator UI. If no GPS installed, choose <b>None</b>.
|
||||
</p>
|
||||
<div>
|
||||
<label for="wizard-gps-port">GPS Serial Port</label><select id="wizard-gps-port"></select>
|
||||
</div>
|
||||
<div style="display: none;" id="wizard-gps-baud-container">
|
||||
<label for="wizard-gps-baud">GPS Baud Rate</label><select id="wizard-gps-baud"></select>
|
||||
</div>
|
||||
<div style="display: none;" id="wizard-gps-protocol-container">
|
||||
<label for="wizard-gps-protocol">GPS Protocol</label><select id="wizard-gps-protocol"></select>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue