mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-19 06:15:11 +03:00
Store receiver port in wizard
This commit is contained in:
parent
4fe7728d46
commit
6a514920fa
4 changed files with 79 additions and 9 deletions
51
js/wizard_save_framework.js
Normal file
51
js/wizard_save_framework.js
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue