1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Merge pull request #1083 from smoriarty21/configuration_load_save

Restore dosen't work #1016
This commit is contained in:
Michael Keller 2018-07-17 21:08:16 +12:00 committed by GitHub
commit 1a2fe994fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 11 deletions

View file

@ -141,6 +141,11 @@ function configuration_backup(callback) {
configuration.SERIAL_CONFIG = jQuery.extend(true, {}, SERIAL_CONFIG);
configuration.LED_STRIP = jQuery.extend(true, [], LED_STRIP);
configuration.LED_COLORS = jQuery.extend(true, [], LED_COLORS);
configuration.BOARD_ALIGNMENT_CONFIG = jQuery.extend(true, {}, BOARD_ALIGNMENT_CONFIG);
configuration.CRAFT_NAME = CONFIG.name;
configuration.MIXER_CONFIG = jQuery.extend(true, {}, MIXER_CONFIG);
configuration.SENSOR_CONFIG = jQuery.extend(true, {}, SENSOR_CONFIG);
configuration.PID_ADVANCED_CONFIG = jQuery.extend(true, {}, PID_ADVANCED_CONFIG);
if (semver.gte(CONFIG.apiVersion, "1.19.0")) {
configuration.LED_MODE_COLORS = jQuery.extend(true, [], LED_MODE_COLORS);
@ -165,13 +170,31 @@ function configuration_backup(callback) {
configuration.GPS_CONFIG = jQuery.extend(true, {}, GPS_CONFIG);
configuration.COMPASS_CONFIG = jQuery.extend(true, {}, COMPASS_CONFIG);
}
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
configuration.BEEPER_CONFIG = jQuery.extend(true, {}, BEEPER_CONFIG);
}
save();
}
}
// start fetching
fetch_unique_data_item();
if (GUI.configuration_loaded === true) {
return fetch_unique_data_item();
}
MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG).then(function() {
return MSP.promise(MSPCodes.MSP_SENSOR_CONFIG);
}).then(function() {
return MSP.promise(MSPCodes.MSP_NAME);
}).then(function() {
return MSP.promise(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG);
}).then(function() {
return MSP.promise(MSPCodes.MSP_MIXER_CONFIG);
}).then(function() {
return MSP.promise(MSPCodes.MSP_BEEPER_CONFIG);
}).then(function() {
return fetch_unique_data_item();
});
}
function save() {
@ -303,13 +326,11 @@ function configuration_restore(callback) {
// validate
if (typeof configuration.generatedBy !== 'undefined' && compareVersions(configuration.generatedBy, CONFIGURATOR.backupFileMinVersionAccepted)) {
if (typeof configuration.generatedBy !== 'undefined' && compareVersions(configuration.generatedBy, CONFIGURATOR.backupFileMinVersionAccepted)) {
if (!compareVersions(configuration.generatedBy, "1.14.0") && !migrate(configuration)) {
GUI.log(i18n.getMessage('backupFileUnmigratable'));
return;
}
if (configuration.FEATURE_CONFIG.features._featureMask) {
var features = new Features(CONFIG);
features.setMask(configuration.FEATURE_CONFIG.features._featureMask);
@ -317,12 +338,9 @@ function configuration_restore(callback) {
}
configuration_upload(configuration, callback);
} else {
GUI.log(i18n.getMessage('backupFileIncompatible'));
}
}
};
@ -763,6 +781,13 @@ function configuration_restore(callback) {
];
function update_unique_data_list() {
uniqueData.push(MSPCodes.MSP_SET_NAME);
uniqueData.push(MSPCodes.MSP_SET_SENSOR_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_MIXER_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_BEEPER_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_ADVANCED_CONFIG);
if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
uniqueData.push(MSPCodes.MSP_SET_LOOP_TIME);
uniqueData.push(MSPCodes.MSP_SET_ARMING_CONFIG);
@ -803,6 +828,17 @@ function configuration_restore(callback) {
GPS_CONFIG = configuration.GPS_CONFIG;
COMPASS_CONFIG = configuration.COMPASS_CONFIG;
RSSI_CONFIG = configuration.RSSI_CONFIG;
BOARD_ALIGNMENT_CONFIG = configuration.BOARD_ALIGNMENT_CONFIG;
CONFIG.name = configuration.CRAFT_NAME;
MIXER_CONFIG = configuration.MIXER_CONFIG;
SENSOR_CONFIG = configuration.SENSOR_CONFIG;
PID_ADVANCED_CONFIG = configuration.PID_ADVANCED_CONFIG;
BEEPER_CONFIG.beepers = new Beepers(CONFIG);
BEEPER_CONFIG.beepers.setMask(configuration.BEEPER_CONFIG.beepers._beeperMask);
BEEPER_CONFIG.dshotBeaconTone = configuration.BEEPER_CONFIG.dshotBeaconTone;
BEEPER_CONFIG.dshotBeaconConditions = new Beepers(CONFIG, [ "RX_LOST", "RX_SET" ]);
BEEPER_CONFIG.dshotBeaconConditions.setMask(configuration.BEEPER_CONFIG.dshotBeaconConditions._beeperMask);
}
function send_unique_data_item() {

View file

@ -1109,7 +1109,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_ADJUSTMENT_RANGE:
console.log('Adjustment range saved');
break;
case MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG:
console.log('Board alignment saved');
break;
case MSPCodes.MSP_PID_CONTROLLER:
PID.controller = data.readU8();
break;
@ -1875,7 +1877,6 @@ MspHelper.prototype.sendCurrentConfig = function(onCompleteCallback) {
}
MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
var nextFunction = send_next_led_strip_config;

View file

@ -43,6 +43,8 @@ function initializeSerialBackend() {
thisElement.data("clicks", !clicks);
};
GUI.configuration_loaded = false;
var selected_baud = parseInt($('div#port-picker #baud').val());
var selected_port = $('div#port-picker #port option:selected').data().isManual ?
$('#port-override').val() :

View file

@ -10,6 +10,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
if (GUI.active_tab != 'configuration') {
GUI.active_tab = 'configuration';
GUI.configuration_loaded = true;
}
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {