mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-17 05:15:21 +03:00
Remove tabs and some trailing spaces
This commit is contained in:
parent
55df431247
commit
09e2f6d231
9 changed files with 384 additions and 393 deletions
|
@ -16,7 +16,7 @@ function configuration_backup(callback) {
|
|||
'apiVersion': CONFIG.apiVersion,
|
||||
'profiles': [],
|
||||
};
|
||||
|
||||
|
||||
var profileSpecificData = [
|
||||
MSPCodes.MSP_PID_CONTROLLER,
|
||||
MSPCodes.MSP_PID,
|
||||
|
@ -35,7 +35,7 @@ function configuration_backup(callback) {
|
|||
profileSpecificData.push(MSPCodes.MSP_RC_DEADBAND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
update_profile_specific_data_list();
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function () {
|
||||
|
@ -127,12 +127,12 @@ function configuration_backup(callback) {
|
|||
uniqueData.push(MSPCodes.MSP_MODE_RANGES_EXTRA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
update_unique_data_list();
|
||||
|
||||
function fetch_unique_data() {
|
||||
var codeKey = 0;
|
||||
|
||||
|
||||
function fetch_unique_data_item() {
|
||||
if (codeKey < uniqueData.length) {
|
||||
MSP.send_message(uniqueData[codeKey], false, false, function () {
|
||||
|
@ -168,7 +168,7 @@ function configuration_backup(callback) {
|
|||
configuration.RXFAIL_CONFIG = jQuery.extend(true, [], RXFAIL_CONFIG);
|
||||
}
|
||||
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
|
||||
configuration.RSSI_CONFIG = jQuery.extend(true, {}, RSSI_CONFIG);
|
||||
configuration.RSSI_CONFIG = jQuery.extend(true, {}, RSSI_CONFIG);
|
||||
configuration.FEATURE_CONFIG = jQuery.extend(true, {}, FEATURE_CONFIG);
|
||||
configuration.MOTOR_CONFIG = jQuery.extend(true, {}, MOTOR_CONFIG);
|
||||
configuration.GPS_CONFIG = jQuery.extend(true, {}, GPS_CONFIG);
|
||||
|
@ -280,7 +280,7 @@ function configuration_backup(callback) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function configuration_restore(callback) {
|
||||
var chosenFileEntry = null;
|
||||
|
||||
|
@ -334,7 +334,7 @@ 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;
|
||||
|
@ -364,38 +364,38 @@ function configuration_restore(callback) {
|
|||
}
|
||||
return semver.gte(generated, required);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function migrate(configuration) {
|
||||
var appliedMigrationsCount = 0;
|
||||
var migratedVersion = configuration.generatedBy;
|
||||
GUI.log(i18n.getMessage('configMigrationFrom', [migratedVersion]));
|
||||
|
||||
|
||||
if (!compareVersions(migratedVersion, '0.59.1')) {
|
||||
|
||||
|
||||
// variable was renamed
|
||||
configuration.RSSI_CONFIG.channel = configuration.MISC.rssi_aux_channel;
|
||||
configuration.MISC.rssi_aux_channel = undefined;
|
||||
|
||||
|
||||
migratedVersion = '0.59.1';
|
||||
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
|
||||
appliedMigrationsCount++;
|
||||
}
|
||||
|
||||
|
||||
if (!compareVersions(migratedVersion, '0.60.1')) {
|
||||
|
||||
|
||||
// LED_STRIP support was added.
|
||||
if (!configuration.LED_STRIP) {
|
||||
configuration.LED_STRIP = [];
|
||||
}
|
||||
|
||||
|
||||
migratedVersion = '0.60.1';
|
||||
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
|
||||
appliedMigrationsCount++;
|
||||
}
|
||||
|
||||
|
||||
if (!compareVersions(migratedVersion, '0.61.0')) {
|
||||
|
||||
|
||||
// Changing PID controller via UI was added.
|
||||
if (!configuration.PIDs && configuration.PID) {
|
||||
configuration.PIDs = configuration.PID;
|
||||
|
@ -403,14 +403,14 @@ function configuration_restore(callback) {
|
|||
controller: 0 // assume pid controller 0 was used.
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
migratedVersion = '0.61.0';
|
||||
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
|
||||
appliedMigrationsCount++;
|
||||
}
|
||||
|
||||
if (!compareVersions(migratedVersion, '0.63.0')) {
|
||||
|
||||
|
||||
// LED Strip was saved as object instead of array.
|
||||
if (typeof(configuration.LED_STRIP) == 'object') {
|
||||
var fixed_led_strip = [];
|
||||
|
@ -422,19 +422,18 @@ function configuration_restore(callback) {
|
|||
configuration.LED_STRIP = fixed_led_strip;
|
||||
}
|
||||
|
||||
|
||||
for (var profileIndex = 0; profileIndex < 3; profileIndex++) {
|
||||
var RC = configuration.profiles[profileIndex].RC;
|
||||
// TPA breakpoint was added
|
||||
if (!RC.dynamic_THR_breakpoint) {
|
||||
RC.dynamic_THR_breakpoint = 1500; // firmware default
|
||||
}
|
||||
|
||||
|
||||
// Roll and pitch rates were split
|
||||
RC.roll_rate = RC.roll_pitch_rate;
|
||||
RC.pitch_rate = RC.roll_pitch_rate;
|
||||
}
|
||||
|
||||
|
||||
migratedVersion = '0.63.0';
|
||||
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
|
||||
appliedMigrationsCount++;
|
||||
|
@ -464,17 +463,17 @@ function configuration_restore(callback) {
|
|||
telemetry_baudrate: 'AUTO',
|
||||
blackbox_baudrate: '115200',
|
||||
};
|
||||
|
||||
|
||||
switch(oldPort.scenario) {
|
||||
case 1: // MSP, CLI, TELEMETRY, SMARTPORT TELEMETRY, GPS-PASSTHROUGH
|
||||
case 5: // MSP, CLI, GPS-PASSTHROUGH
|
||||
case 8: // MSP ONLY
|
||||
newPort.functions.push('MSP');
|
||||
break;
|
||||
case 2: // GPS
|
||||
case 2: // GPS
|
||||
newPort.functions.push('GPS');
|
||||
break;
|
||||
case 3: // RX_SERIAL
|
||||
case 3: // RX_SERIAL
|
||||
newPort.functions.push('RX_SERIAL');
|
||||
break;
|
||||
case 10: // BLACKBOX ONLY
|
||||
|
@ -485,20 +484,20 @@ function configuration_restore(callback) {
|
|||
newPort.functions.push('BLACKBOX');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
ports.push(newPort);
|
||||
}
|
||||
configuration.SERIAL_CONFIG = {
|
||||
ports: ports
|
||||
configuration.SERIAL_CONFIG = {
|
||||
ports: ports
|
||||
};
|
||||
|
||||
|
||||
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
|
||||
appliedMigrationsCount++;
|
||||
}
|
||||
|
||||
|
||||
if (compareVersions(migratedVersion, '0.63.0') && !compareVersions(configuration.apiVersion, '1.8.0')) {
|
||||
// api 1.8 exposes looptime and arming config
|
||||
|
||||
|
||||
if (configuration.FC_CONFIG == undefined) {
|
||||
configuration.FC_CONFIG = {
|
||||
loopTime: 3500
|
||||
|
@ -515,7 +514,7 @@ function configuration_restore(callback) {
|
|||
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
|
||||
appliedMigrationsCount++;
|
||||
}
|
||||
|
||||
|
||||
if (compareVersions(migratedVersion, '0.63.0')) {
|
||||
// backups created with 0.63.0 for firmwares with api < 1.8 were saved with incorrect looptime
|
||||
if (configuration.FC_CONFIG.loopTime == 0) {
|
||||
|
@ -523,25 +522,25 @@ function configuration_restore(callback) {
|
|||
configuration.FC_CONFIG.loopTime = 3500;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (semver.lt(migratedVersion, '0.66.0')) {
|
||||
// api 1.12 updated servo configuration protocol and added servo mixer rules
|
||||
for (var profileIndex = 0; profileIndex < configuration.profiles.length; profileIndex++) {
|
||||
|
||||
|
||||
if (semver.eq(configuration.apiVersion, '1.10.0')) {
|
||||
// drop two unused servo configurations
|
||||
while (configuration.profiles[profileIndex].ServoConfig.length > 8) {
|
||||
configuration.profiles[profileIndex].ServoConfig.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < configuration.profiles[profileIndex].ServoConfig.length; i++) {
|
||||
var servoConfig = profiles[profileIndex].ServoConfig;
|
||||
|
||||
|
||||
servoConfig[i].angleAtMin = 45;
|
||||
servoConfig[i].angleAtMax = 45;
|
||||
servoConfig[i].reversedInputSources = 0;
|
||||
|
||||
|
||||
// set the rate to 0 if an invalid value is detected.
|
||||
if (servoConfig[i].rate < -100 || servoConfig[i].rate > 100) {
|
||||
servoConfig[i].rate = 0;
|
||||
|
@ -550,21 +549,21 @@ function configuration_restore(callback) {
|
|||
|
||||
configuration.profiles[profileIndex].ServoRules = [];
|
||||
}
|
||||
|
||||
|
||||
migratedVersion = '0.66.0';
|
||||
|
||||
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
|
||||
appliedMigrationsCount++;
|
||||
}
|
||||
|
||||
|
||||
if (semver.lt(configuration.apiVersion, '1.14.0') && semver.gte(CONFIG.apiVersion, "1.14.0")) {
|
||||
// api 1.14 removed old pid controllers
|
||||
for (var profileIndex = 0; profileIndex < configuration.profiles.length; profileIndex++) {
|
||||
var newPidControllerIndex = configuration.profiles[profileIndex].PID.controller;
|
||||
switch (newPidControllerIndex) {
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
newPidControllerIndex = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -574,11 +573,11 @@ function configuration_restore(callback) {
|
|||
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
|
||||
appliedMigrationsCount++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (compareVersions(migratedVersion, '0.66.0') && !compareVersions(configuration.apiVersion, '1.14.0')) {
|
||||
// api 1.14 exposes 3D configuration
|
||||
|
||||
|
||||
if (configuration.MOTOR_3D_CONFIG == undefined) {
|
||||
configuration.MOTOR_3D_CONFIG = {
|
||||
deadband3d_low: 1406,
|
||||
|
@ -591,19 +590,18 @@ function configuration_restore(callback) {
|
|||
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
|
||||
appliedMigrationsCount++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (compareVersions(migratedVersion, '0.66.0') && !compareVersions(configuration.apiVersion, '1.15.0')) {
|
||||
// api 1.15 exposes RCdeadband and sensor alignment
|
||||
|
||||
|
||||
for (var profileIndex = 0; profileIndex < configuration.profiles.length; profileIndex++) {
|
||||
if (configuration.profiles[profileIndex].RCdeadband == undefined) {
|
||||
configuration.profiles[profileIndex].RCdeadband = {
|
||||
deadband: 0,
|
||||
yaw_deadband: 0,
|
||||
alt_hold_deadband: 40,
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
if (configuration.SENSOR_ALIGNMENT == undefined) {
|
||||
|
@ -611,9 +609,9 @@ function configuration_restore(callback) {
|
|||
align_gyro: 0,
|
||||
align_acc: 0,
|
||||
align_mag: 0
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// api 1.15 exposes RX_CONFIG, FAILSAFE_CONFIG and RXFAIL_CONFIG configuration
|
||||
|
||||
if (configuration.RX_CONFIG == undefined) {
|
||||
|
@ -672,7 +670,7 @@ function configuration_restore(callback) {
|
|||
}
|
||||
|
||||
if (compareVersions(migratedVersion, '1.3.1')) {
|
||||
|
||||
|
||||
// LED_COLORS & LED_MODE_COLORS support was added.
|
||||
if (!configuration.LED_COLORS) {
|
||||
configuration.LED_COLORS = [];
|
||||
|
@ -689,10 +687,10 @@ function configuration_restore(callback) {
|
|||
|
||||
if (appliedMigrationsCount > 0) {
|
||||
GUI.log(i18n.getMessage('configMigrationSuccessful', [appliedMigrationsCount]));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function configuration_upload(configuration, callback) {
|
||||
function upload() {
|
||||
var activeProfile = null;
|
||||
|
@ -787,10 +785,10 @@ function configuration_restore(callback) {
|
|||
MODE_RANGES_EXTRA = configuration.MODE_RANGES_EXTRA;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mspHelper.sendModeRanges(upload_adjustment_ranges);
|
||||
}
|
||||
|
||||
|
||||
function upload_adjustment_ranges() {
|
||||
mspHelper.sendAdjustmentRanges(upload_using_specific_commands);
|
||||
}
|
||||
|
@ -806,7 +804,7 @@ function configuration_restore(callback) {
|
|||
MSPCodes.MSP_SET_RX_MAP,
|
||||
MSPCodes.MSP_SET_CF_SERIAL_CONFIG
|
||||
];
|
||||
|
||||
|
||||
function update_unique_data_list() {
|
||||
uniqueData.push(MSPCodes.MSP_SET_NAME);
|
||||
uniqueData.push(MSPCodes.MSP_SET_SENSOR_CONFIG);
|
||||
|
@ -828,14 +826,14 @@ function configuration_restore(callback) {
|
|||
uniqueData.push(MSPCodes.MSP_SET_FAILSAFE_CONFIG);
|
||||
}
|
||||
if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
|
||||
uniqueData.push(MSPCodes.MSP_SET_FEATURE_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_MOTOR_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_FEATURE_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_MOTOR_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_GPS_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_COMPASS_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_RSSI_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function load_objects() {
|
||||
MISC = configuration.MISC;
|
||||
RC_MAP = configuration.RCMAP;
|
||||
|
@ -902,7 +900,7 @@ function configuration_restore(callback) {
|
|||
else
|
||||
send_rxfail_config();
|
||||
}
|
||||
|
||||
|
||||
function send_rxfail_config() {
|
||||
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
|
||||
mspHelper.sendRxFailConfig(save_to_eeprom);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue