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

FIX: RC controls is profile dependent, now this saving for every profile

This commit is contained in:
NightHawk32 2015-12-12 14:41:32 -05:00
parent 136d2edd44
commit 6d7c6a4576

View file

@ -11,20 +11,7 @@ function configuration_backup(callback) {
'apiVersion': CONFIG.apiVersion, 'apiVersion': CONFIG.apiVersion,
'profiles': [], 'profiles': [],
}; };
MSP.send_message(MSP_codes.MSP_STATUS, false, false, function () {
activeProfile = CONFIG.profile;
select_profile();
});
function select_profile() {
if (activeProfile > 0) {
MSP.send_message(MSP_codes.MSP_SELECT_SETTING, [0], false, fetch_specific_data);
} else {
fetch_specific_data();
}
}
var profileSpecificData = [ var profileSpecificData = [
MSP_codes.MSP_PID_CONTROLLER, MSP_codes.MSP_PID_CONTROLLER,
MSP_codes.MSP_PID, MSP_codes.MSP_PID,
@ -41,10 +28,26 @@ function configuration_backup(callback) {
} else { } else {
profileSpecificData.push(MSP_codes.MSP_SERVO_MIX_RULES); profileSpecificData.push(MSP_codes.MSP_SERVO_MIX_RULES);
} }
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
profileSpecificData.push(MSP_codes.MSP_RC_CONTROLS);
}
} }
update_profile_specific_data_list(); update_profile_specific_data_list();
MSP.send_message(MSP_codes.MSP_STATUS, false, false, function () {
activeProfile = CONFIG.profile;
select_profile();
});
function select_profile() {
if (activeProfile > 0) {
MSP.send_message(MSP_codes.MSP_SELECT_SETTING, [0], false, fetch_specific_data);
} else {
fetch_specific_data();
}
}
function fetch_specific_data() { function fetch_specific_data() {
var fetchingProfile = 0, var fetchingProfile = 0,
codeKey = 0; codeKey = 0;
@ -68,6 +71,9 @@ function configuration_backup(callback) {
'AdjustmentRanges': jQuery.extend(true, [], ADJUSTMENT_RANGES) 'AdjustmentRanges': jQuery.extend(true, [], ADJUSTMENT_RANGES)
}); });
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
configuration.profiles[fetchingProfile].RCcontrols = jQuery.extend(true, {}, RC_controls);
}
codeKey = 0; codeKey = 0;
fetchingProfile++; fetchingProfile++;
@ -99,9 +105,6 @@ function configuration_backup(callback) {
if (semver.gte(CONFIG.apiVersion, "1.14.0")) { if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
uniqueData.push(MSP_codes.MSP_3D); uniqueData.push(MSP_codes.MSP_3D);
} }
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
uniqueData.push(MSP_codes.MSP_RC_CONTROLS);
}
} }
update_unique_data_list(); update_unique_data_list();
@ -129,9 +132,6 @@ function configuration_backup(callback) {
if (semver.gte(CONFIG.apiVersion, "1.14.0")) { if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
configuration._3D = jQuery.extend(true, {}, _3D); configuration._3D = jQuery.extend(true, {}, _3D);
} }
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
configuration.RC_controls = jQuery.extend(true, {}, RC_controls);
}
save(); save();
} }
@ -515,14 +515,17 @@ function configuration_restore(callback) {
if (compareVersions(migratedVersion, '0.66.0') && !compareVersions(configuration.apiVersion, '1.15.0')) { if (compareVersions(migratedVersion, '0.66.0') && !compareVersions(configuration.apiVersion, '1.15.0')) {
// api 1.14 exposes deadband and yaw_deadband // api 1.14 exposes deadband and yaw_deadband
if (configuration.RC_controls == undefined) { for (var profileIndex = 0; profileIndex < configuration.profiles.length; profileIndex++) {
configuration.RC_controls = { if (configuration.profile[profileIndex].RCcontrols == undefined) {
configuration.profile[profileIndex].RCcontrols = {
deadband: 0, deadband: 0,
yaw_deadband: 0, yaw_deadband: 0,
alt_hold_deadband: 40, alt_hold_deadband: 40,
alt_hold_fast_change: 1 alt_hold_fast_change: 1
}; };
}
} }
appliedMigrationsCount++; appliedMigrationsCount++;
} }
@ -546,6 +549,10 @@ function configuration_restore(callback) {
MSP_codes.MSP_SET_ACC_TRIM MSP_codes.MSP_SET_ACC_TRIM
]; ];
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
profileSpecificData.push(MSP_codes.MSP_SET_RC_CONTROLS);
}
MSP.send_message(MSP_codes.MSP_STATUS, false, false, function () { MSP.send_message(MSP_codes.MSP_STATUS, false, false, function () {
activeProfile = CONFIG.profile; activeProfile = CONFIG.profile;
select_profile(); select_profile();
@ -572,6 +579,7 @@ function configuration_restore(callback) {
SERVO_RULES = configuration.profiles[profile].ServoRules; SERVO_RULES = configuration.profiles[profile].ServoRules;
MODE_RANGES = configuration.profiles[profile].ModeRanges; MODE_RANGES = configuration.profiles[profile].ModeRanges;
ADJUSTMENT_RANGES = configuration.profiles[profile].AdjustmentRanges; ADJUSTMENT_RANGES = configuration.profiles[profile].AdjustmentRanges;
RC_controls = configuration.profiles[profile].RCcontrols;
} }
function upload_using_specific_commands() { function upload_using_specific_commands() {
@ -637,9 +645,6 @@ function configuration_restore(callback) {
if (semver.gte(CONFIG.apiVersion, "1.14.0")) { if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
uniqueData.push(MSP_codes.MSP_SET_3D); uniqueData.push(MSP_codes.MSP_SET_3D);
} }
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
uniqueData.push(MSP_codes.MSP_SET_RC_CONTROLS);
}
} }
function load_objects() { function load_objects() {
@ -651,7 +656,6 @@ function configuration_restore(callback) {
ARMING_CONFIG = configuration.ARMING_CONFIG; ARMING_CONFIG = configuration.ARMING_CONFIG;
FC_CONFIG = configuration.FC_CONFIG; FC_CONFIG = configuration.FC_CONFIG;
_3D = configuration._3D; _3D = configuration._3D;
RC_controls = configuration.RC_controls;
} }
function send_unique_data_item() { function send_unique_data_item() {