mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-25 17:25:16 +03:00
Merge pull request #1083 from smoriarty21/configuration_load_save
Restore dosen't work #1016
This commit is contained in:
commit
1a2fe994fd
4 changed files with 51 additions and 11 deletions
|
@ -141,6 +141,11 @@ function configuration_backup(callback) {
|
||||||
configuration.SERIAL_CONFIG = jQuery.extend(true, {}, SERIAL_CONFIG);
|
configuration.SERIAL_CONFIG = jQuery.extend(true, {}, SERIAL_CONFIG);
|
||||||
configuration.LED_STRIP = jQuery.extend(true, [], LED_STRIP);
|
configuration.LED_STRIP = jQuery.extend(true, [], LED_STRIP);
|
||||||
configuration.LED_COLORS = jQuery.extend(true, [], LED_COLORS);
|
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")) {
|
if (semver.gte(CONFIG.apiVersion, "1.19.0")) {
|
||||||
configuration.LED_MODE_COLORS = jQuery.extend(true, [], LED_MODE_COLORS);
|
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.GPS_CONFIG = jQuery.extend(true, {}, GPS_CONFIG);
|
||||||
configuration.COMPASS_CONFIG = jQuery.extend(true, {}, COMPASS_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();
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// start fetching
|
if (GUI.configuration_loaded === true) {
|
||||||
fetch_unique_data_item();
|
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() {
|
function save() {
|
||||||
|
@ -303,13 +326,11 @@ function configuration_restore(callback) {
|
||||||
|
|
||||||
|
|
||||||
// validate
|
// 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)) {
|
if (!compareVersions(configuration.generatedBy, "1.14.0") && !migrate(configuration)) {
|
||||||
GUI.log(i18n.getMessage('backupFileUnmigratable'));
|
GUI.log(i18n.getMessage('backupFileUnmigratable'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configuration.FEATURE_CONFIG.features._featureMask) {
|
if (configuration.FEATURE_CONFIG.features._featureMask) {
|
||||||
var features = new Features(CONFIG);
|
var features = new Features(CONFIG);
|
||||||
features.setMask(configuration.FEATURE_CONFIG.features._featureMask);
|
features.setMask(configuration.FEATURE_CONFIG.features._featureMask);
|
||||||
|
@ -317,12 +338,9 @@ function configuration_restore(callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration_upload(configuration, callback);
|
configuration_upload(configuration, callback);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GUI.log(i18n.getMessage('backupFileIncompatible'));
|
GUI.log(i18n.getMessage('backupFileIncompatible'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -763,6 +781,13 @@ function configuration_restore(callback) {
|
||||||
];
|
];
|
||||||
|
|
||||||
function update_unique_data_list() {
|
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")) {
|
if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
|
||||||
uniqueData.push(MSPCodes.MSP_SET_LOOP_TIME);
|
uniqueData.push(MSPCodes.MSP_SET_LOOP_TIME);
|
||||||
uniqueData.push(MSPCodes.MSP_SET_ARMING_CONFIG);
|
uniqueData.push(MSPCodes.MSP_SET_ARMING_CONFIG);
|
||||||
|
@ -803,6 +828,17 @@ function configuration_restore(callback) {
|
||||||
GPS_CONFIG = configuration.GPS_CONFIG;
|
GPS_CONFIG = configuration.GPS_CONFIG;
|
||||||
COMPASS_CONFIG = configuration.COMPASS_CONFIG;
|
COMPASS_CONFIG = configuration.COMPASS_CONFIG;
|
||||||
RSSI_CONFIG = configuration.RSSI_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() {
|
function send_unique_data_item() {
|
||||||
|
|
|
@ -1109,7 +1109,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
||||||
case MSPCodes.MSP_SET_ADJUSTMENT_RANGE:
|
case MSPCodes.MSP_SET_ADJUSTMENT_RANGE:
|
||||||
console.log('Adjustment range saved');
|
console.log('Adjustment range saved');
|
||||||
break;
|
break;
|
||||||
|
case MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG:
|
||||||
|
console.log('Board alignment saved');
|
||||||
|
break;
|
||||||
case MSPCodes.MSP_PID_CONTROLLER:
|
case MSPCodes.MSP_PID_CONTROLLER:
|
||||||
PID.controller = data.readU8();
|
PID.controller = data.readU8();
|
||||||
break;
|
break;
|
||||||
|
@ -1875,7 +1877,6 @@ MspHelper.prototype.sendCurrentConfig = function(onCompleteCallback) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
|
MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
|
||||||
|
|
||||||
var nextFunction = send_next_led_strip_config;
|
var nextFunction = send_next_led_strip_config;
|
||||||
|
|
|
@ -43,6 +43,8 @@ function initializeSerialBackend() {
|
||||||
thisElement.data("clicks", !clicks);
|
thisElement.data("clicks", !clicks);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GUI.configuration_loaded = false;
|
||||||
|
|
||||||
var selected_baud = parseInt($('div#port-picker #baud').val());
|
var selected_baud = parseInt($('div#port-picker #baud').val());
|
||||||
var selected_port = $('div#port-picker #port option:selected').data().isManual ?
|
var selected_port = $('div#port-picker #port option:selected').data().isManual ?
|
||||||
$('#port-override').val() :
|
$('#port-override').val() :
|
||||||
|
|
|
@ -10,6 +10,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
||||||
|
|
||||||
if (GUI.active_tab != 'configuration') {
|
if (GUI.active_tab != 'configuration') {
|
||||||
GUI.active_tab = 'configuration';
|
GUI.active_tab = 'configuration';
|
||||||
|
GUI.configuration_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
|
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue