Store receiver port in wizard

pull/1537/head
Pawel Spychalski (DzikuVx) 4 months ago
parent 4fe7728d46
commit 6a514920fa

@ -13,8 +13,8 @@ const jBox = require('./libraries/jBox/jBox.min');
const i18n = require('./localization');
const defaultsDialogData = require('./defaults_dialog_entries.js');
const Settings = require('./settings.js');
const serialPortHelper = require('./serialPortHelper');
const wizardUiBindings = require('./wizard_ui_bindings');
const wizardSaveFramework = require('./wizard_save_framework');
var savingDefaultsModal;
@ -25,7 +25,7 @@ var defaultsDialog = (function () {
let $container;
privateScope.wizardSettings = {};
privateScope.wizardSettings = [];
publicScope.init = function () {
mspHelper.getSetting("applied_defaults").then(privateScope.onInitSettingReturned);
@ -62,10 +62,16 @@ var defaultsDialog = (function () {
let receiverPort = $receiverPort.val();
if (receiverPort != "-1") {
privateScope.wizardSettings['receiverPort'] = receiverPort;
privateScope.wizardSettings.push({
name: "receiverPort",
value: receiverPort
});
}
privateScope.wizardSettings['receiverProcol'] = $container.find('#wizard-receiver-protocol').val();
privateScope.wizardSettings.push({
name: "receiverProtocol",
value: $container.find('#wizard-receiver-protocol').val()
});
}
privateScope.wizard(selectedDefaultPreset, wizardStep + 1);
@ -77,12 +83,19 @@ var defaultsDialog = (function () {
const stepsCount = selectedDefaultPreset.wizardPages.length;
const stepName = steps[wizardStep];
console.log(steps[wizardStep], wizardStep, stepsCount);
if (wizardStep >= stepsCount) {
//This is the last step, time to finalize
$container.hide();
privateScope.saveAndReboot();
wizardSaveFramework.persist(privateScope.wizardSettings, function () {
mspHelper.saveToEeprom(function () {
//noinspection JSUnresolvedVariable
GUI.log(i18n.getMessage('configurationEepromSaved'));
if (selectedDefaultPreset.reboot) {
privateScope.reboot();
}
});
});
} else {
const $content = $container.find('.defaults-dialog__wizard');
@ -126,7 +139,7 @@ var defaultsDialog = (function () {
};
privateScope.saveAndReboot = function () {
privateScope.reboot = function () {
GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
@ -149,7 +162,7 @@ var defaultsDialog = (function () {
//noinspection JSUnresolvedVariable
GUI.log(i18n.getMessage('configurationEepromSaved'));
if (selectedDefaultPreset.reboot) {
privateScope.saveAndReboot();
privateScope.reboot();
}
});
}

@ -1847,6 +1847,7 @@ var mspHelper = (function () {
break;
case MSPCodes.MSP2_SET_CF_SERIAL_CONFIG:
console.log('will crunch', FC.SERIAL_CONFIG);
for (let i = 0; i < FC.SERIAL_CONFIG.ports.length; i++) {
var serialPort = FC.SERIAL_CONFIG.ports[i];

@ -332,9 +332,14 @@ const serialPortHelper = (function () {
publicScope.set = function(port, functionName, baudrate) {
console.log('Start', FC.SERIAL_CONFIG);
publicScope.clearByFunction(functionName);
let config = publicScope.getPortByIdentifier(port);
console.log('Config to change', config);
if (config) {
config.functions = [functionName];

@ -0,0 +1,51 @@
'use strict';
const mspHelper = require('./msp/MSPHelper');
const serialPortHelper = require('./serialPortHelper');
const FC = require('./fc');
var wizardSaveFramework = (function () {
let self = {};
self.saveSetting = function (config, callback) {
switch (config.name) {
case 'receiverPort':
serialPortHelper.set(config.value, 'RX_SERIAL', null);
mspHelper.saveSerialPorts(callback);
break;
default:
callback();
break;
}
};
self.handleSetting = function (configs, finalCallback) {
if (configs.length > 0) {
let setting = configs.shift();
self.saveSetting(setting, function () {
self.handleSetting(configs, finalCallback);
});
} else {
console.log('Nothing to save');
finalCallback();
}
};
self.persist = function (config, finalCallback) {
if (config === null || config === undefined || config.length === 0) {
finalCallback();
return;
}
let configCopy = Array.from(config);
self.handleSetting(configCopy, finalCallback);
}
return self;
})();
module.exports = wizardSaveFramework;
Loading…
Cancel
Save