1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-16 12:55:14 +03:00

Bump API_VERSION_ACCEPTED and semver cleanup (#3104)

Firmware flasher: build config help icons style fix (#3092)

Co-authored-by: Ivan Efimov <gendalf44@yandex.ru>
This commit is contained in:
haslinghuis 2022-12-11 04:55:14 +01:00 committed by GitHub
parent 7df8d627e9
commit 867b59d204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 1702 additions and 4113 deletions

View file

@ -276,25 +276,6 @@
"deviceReady": {
"message": "Device - <span class=\"message-positive\">Ready</span>"
},
"backupFileIncompatible": {
"message": "Backup file provided was generated for previous version of the configurator and is incompatible with this version of configurator. Sorry"
},
"backupFileUnmigratable": {
"message": "Backup file provided was generated by a previous version of the configurator and is not migratable. Sorry."
},
"configMigrationFrom": {
"message": "Migrating configuration file generated by configurator: $1"
},
"configMigratedTo": {
"message": "Migrated configuration to configurator: $1"
},
"configMigrationSuccessful": {
"message": "Configuration migration complete, migrations applied: $1"
},
"tabFirmwareFlasher": {
"message": "Firmware Flasher"
},
@ -768,10 +749,6 @@
"defaultSupport5": {
"message": "<a href=\"https://slack.betaflight.com\" target=\"_blank\" rel=\"noopener noreferrer\">Betaflight devs on slack</a>"
},
"initialSetupBackupAndRestoreApiVersion": {
"message": "<span class=\"message-negative\">Backup and restore functionality disabled.</span> You have firmware with API version <span class=\"message-negative\">$1</span>, backup and restore requires <span class=\"message-positive\">$2</span>. Please backup your settings via the CLI, see Betaflight documentation for procedure."
},
"initialSetupButtonCalibrateAccel": {
"message": "Calibrate Accelerometer"
},
@ -793,30 +770,12 @@
"initialSetupResetText": {
"message": "Restore settings to <strong>default</strong>"
},
"initialSetupButtonBackup": {
"message": "Backup JSON"
},
"initialSetupButtonRestore": {
"message": "Restore JSON"
},
"initialSetupButtonRebootBootloader": {
"message": "Activate Boot Loader / DFU"
},
"initialSetupBackupRestoreHeader": {
"message": "Experimental Backup and Restore"
},
"initialSetupBackupRestoreText": {
"message": "<strong>Backup</strong> your configuration in case of an accident, <strong>CLI</strong> settings are <span class=\"message-negative\">not</span> included - use the command 'diff all' in CLI for this."
},
"initialSetupRebootBootloaderText": {
"message": "Reboot into <strong>boot loader / DFU</strong> mode."
},
"initialSetupBackupSuccess": {
"message": "Backup saved <span class=\"message-positive\">successfully</span>"
},
"initialSetupRestoreSuccess": {
"message": "Configuration restored <span class=\"message-positive\">successfully</span>"
},
"initialSetupButtonResetZaxis": {
"message": "Reset Z axis, offset: 0 deg"
},

View file

@ -171,9 +171,6 @@
float: left;
}
}
.backupRestore {
margin-bottom: 0;
}
.block.info {
.fields {
padding: 5px 5px 3px 5px;

View file

@ -24,21 +24,11 @@ class Beepers {
{ bit: 16, name: 'SYSTEM_INIT', visible: true },
{ bit: 17, name: 'USB', visible: true },
{ bit: 18, name: 'BLACKBOX_ERASE', visible: true },
];
if (semver.gte(config.apiVersion, API_VERSION_1_37)) {
beepers.push(
{ bit: 19, name: 'CRASH_FLIP', visible: true },
{ bit: 20, name: 'CAM_CONNECTION_OPEN', visible: true },
{ bit: 21, name: 'CAM_CONNECTION_CLOSE', visible: true },
);
}
if (semver.gte(config.apiVersion, API_VERSION_1_39)) {
beepers.push(
{ bit: 22, name: 'RC_SMOOTHING_INIT_FAIL', visible: true },
);
}
];
if (supportedConditions) {
self._beepers = [];

View file

@ -532,7 +532,6 @@ CliAutoComplete._initTextcomplete = function() {
}),
]);
if (semver.gte(FC.CONFIG.flightControllerVersion, "4.0.0")) {
$textarea.textcomplete('register', [
strategy({ // "resource show all", from BF 4.0.0 onwards
match: /^(\s*resource\s+show\s+)(\w*)$/i,
@ -543,23 +542,15 @@ CliAutoComplete._initTextcomplete = function() {
template: highlighterPrefix,
}),
]);
}
// diff command
const diffArgs1 = ["master", "profile", "rates", "all"];
const diffArgs2 = [];
if (semver.lt(FC.CONFIG.flightControllerVersion, "3.4.0")) {
diffArgs2.push("showdefaults");
} else {
// above 3.4.0
diffArgs2.push("defaults");
if (semver.gte(FC.CONFIG.flightControllerVersion, "4.0.0")) {
diffArgs1.push("hardware");
diffArgs2.push("bare");
}
}
diffArgs1.sort();
diffArgs2.sort();

View file

@ -5,6 +5,7 @@ const Features = function (config) {
const features = [
{bit: 0, group: 'rxMode', mode: 'select', name: 'RX_PPM'},
{bit: 1, group: 'batteryVoltage', name: 'VBAT'},
{bit: 2, group: 'other', name: 'INFLIGHT_ACC_CAL'},
{bit: 3, group: 'rxMode', mode: 'select', name: 'RX_SERIAL'},
{bit: 4, group: 'escMotorStop', name: 'MOTOR_STOP'},
@ -13,93 +14,28 @@ const Features = function (config) {
{bit: 7, group: 'gps', name: 'GPS', haveTip: true},
{bit: 9, group: 'other', name: 'SONAR'},
{bit: 10, group: 'telemetry', name: 'TELEMETRY'},
{bit: 11, group: 'batteryCurrent', name: 'CURRENT_METER'},
{bit: 12, group: '3D', name: '3D'},
{bit: 13, group: 'rxMode', mode: 'select', name: 'RX_PARALLEL_PWM'},
{bit: 14, group: 'rxMode', mode: 'select', name: 'RX_MSP'},
{bit: 15, group: 'rssi', name: 'RSSI_ADC'},
{bit: 16, group: 'other', name: 'LED_STRIP'},
{bit: 17, group: 'other', name: 'DISPLAY', haveTip: true},
];
if (!semver.gte(config.apiVersion, API_VERSION_1_33)) {
features.push(
{bit: 19, group: 'other', name: 'BLACKBOX', haveTip: true},
);
}
if (semver.gte(config.apiVersion, "1.12.0")) {
features.push(
{bit: 20, group: 'other', name: 'CHANNEL_FORWARDING'},
);
}
if (semver.gte(config.apiVersion, "1.15.0") && !semver.gte(config.apiVersion, API_VERSION_1_36)) {
features.push(
{bit: 8, group: 'rxFailsafe', name: 'FAILSAFE', haveTip: true},
);
}
if (semver.gte(config.apiVersion, "1.16.0")) {
features.push(
{bit: 21, group: 'other', name: 'TRANSPONDER', haveTip: true},
);
}
if (config.flightControllerVersion !== '') {
if (semver.gte(config.apiVersion, "1.16.0")) {
features.push(
{bit: 22, group: 'other', name: 'AIRMODE'},
);
}
if (semver.gte(config.apiVersion, "1.16.0")) {
if (semver.lt(config.apiVersion, "1.20.0")) {
features.push(
{bit: 23, group: 'superexpoRates', name: 'SUPEREXPO_RATES'},
);
} else if (!semver.gte(config.apiVersion, API_VERSION_1_33)) {
features.push(
{bit: 23, group: 'other', name: 'SDCARD'},
);
}
}
if (semver.gte(config.apiVersion, "1.20.0")) {
features.push(
{bit: 18, group: 'other', name: 'OSD'},
);
if (!semver.gte(config.apiVersion, API_VERSION_1_35)) {
features.push(
{bit: 24, group: 'other', name: 'VTX'},
);
}
}
if (semver.gte(config.apiVersion, API_VERSION_1_31)) {
features.push(
{bit: 19, group: 'other', name: 'BLACKBOX', haveTip: true},
{bit: 20, group: 'other', name: 'CHANNEL_FORWARDING'},
{bit: 21, group: 'other', name: 'TRANSPONDER', haveTip: true},
{bit: 22, group: 'other', name: 'AIRMODE'},
{bit: 25, group: 'rxMode', mode: 'select', name: 'RX_SPI'},
{bit: 27, group: 'escSensor', name: 'ESC_SENSOR'},
);
}
if (semver.gte(config.apiVersion, API_VERSION_1_36)) {
features.push(
{bit: 28, group: 'antiGravity', name: 'ANTI_GRAVITY', haveTip: true, hideName: true},
);
];
if (semver.lt(config.apiVersion, API_VERSION_1_44)) { // DYNAMIC_FILTER got removed from FEATURES in BF 4.3 / API 1.44
features.push(
{bit: 29, group: 'other', name: 'DYNAMIC_FILTER'},
);
}
}
if (!semver.gte(config.apiVersion, API_VERSION_1_36)) {
features.push(
{bit: 1, group: 'batteryVoltage', name: 'VBAT'},
{bit: 11, group: 'batteryCurrent', name: 'CURRENT_METER'},
);
}
}
self._features = features;
self._featureMask = 0;

View file

@ -87,13 +87,8 @@ const RateCurve = function (useLegacyCurve) {
let expoPower;
let rcRateConstant;
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
expoPower = 3;
rcRateConstant = 200;
} else {
expoPower = 2;
rcRateConstant = 205.85;
}
if (rcExpo > 0) {
rcCommandf = rcCommandf * Math.pow(rcCommandfAbs, expoPower) * rcExpo + rcCommandf * (1-rcExpo);
@ -169,23 +164,7 @@ const RateCurve = function (useLegacyCurve) {
yaw_rate_limit: FC.RC_TUNING.yaw_rate_limit,
};
if (semver.lt(FC.CONFIG.apiVersion, "1.7.0")) {
currentRates.roll_rate = FC.RC_TUNING.roll_pitch_rate;
currentRates.pitch_rate = FC.RC_TUNING.roll_pitch_rate;
}
if (semver.lt(FC.CONFIG.apiVersion, "1.16.0")) {
currentRates.rc_rate_yaw = currentRates.rc_rate;
}
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
currentRates.superexpo = true;
}
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
currentRates.rc_rate_pitch = currentRates.rc_rate;
currentRates.rc_expo_pitch = currentRates.rc_expo;
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
switch (FC.RC_TUNING.rates_type) {

View file

@ -1,956 +0,0 @@
'use strict';
// code below is highly experimental, although it runs fine on latest firmware
// the data inside nested objects needs to be verified if deep copy works properly
function configuration_backup(callback) {
let activeProfile = null;
let version = CONFIGURATOR.version;
if (version.indexOf(".") === -1) {
version = `${version}.0.0`;
}
const configuration = {
'generatedBy': version,
'apiVersion': FC.CONFIG.apiVersion,
'profiles': [],
};
const profileSpecificData = [
MSPCodes.MSP_PID_CONTROLLER,
MSPCodes.MSP_PID,
MSPCodes.MSP_RC_TUNING,
MSPCodes.MSP_ACC_TRIM,
MSPCodes.MSP_SERVO_CONFIGURATIONS,
MSPCodes.MSP_MODE_RANGES,
MSPCodes.MSP_ADJUSTMENT_RANGES,
];
function update_profile_specific_data_list() {
if (semver.gt(FC.CONFIG.apiVersion, "1.12.0")) {
profileSpecificData.push(MSPCodes.MSP_SERVO_MIX_RULES);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
profileSpecificData.push(MSPCodes.MSP_RC_DEADBAND);
}
}
update_profile_specific_data_list();
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function () {
activeProfile = FC.CONFIG.profile;
select_profile();
});
function select_profile() {
if (activeProfile > 0) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [0], false, fetch_specific_data);
} else {
fetch_specific_data();
}
}
function fetch_specific_data() {
let fetchingProfile = 0;
let codeKey = 0;
function fetch_specific_data_item() {
if (fetchingProfile < FC.CONFIG.numProfiles) {
MSP.send_message(profileSpecificData[codeKey], false, false, function () {
codeKey++;
if (codeKey < profileSpecificData.length) {
fetch_specific_data_item();
} else {
configuration.profiles.push({
'PID': jQuery.extend(true, {}, FC.PID),
'PIDs': jQuery.extend(true, [], FC.PIDS),
'RC': jQuery.extend(true, {}, FC.RC_TUNING),
'AccTrim': jQuery.extend(true, [], FC.CONFIG.accelerometerTrims),
'ServoConfig': jQuery.extend(true, [], FC.SERVO_CONFIG),
'ServoRules': jQuery.extend(true, [], FC.SERVO_RULES),
'ModeRanges': jQuery.extend(true, [], FC.MODE_RANGES),
'AdjustmentRanges': jQuery.extend(true, [], FC.ADJUSTMENT_RANGES),
});
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
configuration.profiles[fetchingProfile].RCdeadband = jQuery.extend(true, {}, FC.RC_DEADBAND_CONFIG);
}
codeKey = 0;
fetchingProfile++;
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [fetchingProfile], false, fetch_specific_data_item);
}
});
} else {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [activeProfile], false, fetch_unique_data);
}
}
// start fetching
fetch_specific_data_item();
}
const uniqueData = [
MSPCodes.MSP_RX_MAP,
MSPCodes.MSP_CF_SERIAL_CONFIG,
MSPCodes.MSP_LED_STRIP_CONFIG,
MSPCodes.MSP_LED_COLORS,
];
function update_unique_data_list() {
if (semver.gte(FC.CONFIG.apiVersion, "1.8.0")) {
uniqueData.push(MSPCodes.MSP_LOOP_TIME);
uniqueData.push(MSPCodes.MSP_ARMING_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.14.0")) {
uniqueData.push(MSPCodes.MSP_MOTOR_3D_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
uniqueData.push(MSPCodes.MSP_SENSOR_ALIGNMENT);
uniqueData.push(MSPCodes.MSP_RX_CONFIG);
uniqueData.push(MSPCodes.MSP_FAILSAFE_CONFIG);
uniqueData.push(MSPCodes.MSP_RXFAIL_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.19.0")) {
uniqueData.push(MSPCodes.MSP_LED_STRIP_MODECOLOR);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
uniqueData.push(MSPCodes.MSP_MOTOR_CONFIG);
uniqueData.push(MSPCodes.MSP_RSSI_CONFIG);
uniqueData.push(MSPCodes.MSP_GPS_CONFIG);
uniqueData.push(MSPCodes.MSP_FEATURE_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
uniqueData.push(MSPCodes.MSP_MODE_RANGES_EXTRA);
}
}
update_unique_data_list();
function fetch_unique_data() {
let codeKey = 0;
function fetch_unique_data_item() {
if (codeKey < uniqueData.length) {
MSP.send_message(uniqueData[codeKey], false, false, function () {
codeKey++;
fetch_unique_data_item();
});
} else {
configuration.RCMAP = jQuery.extend(true, [], FC.RC_MAP);
configuration.SERIAL_CONFIG = jQuery.extend(true, {}, FC.SERIAL_CONFIG);
configuration.LED_STRIP = jQuery.extend(true, [], FC.LED_STRIP);
configuration.LED_COLORS = jQuery.extend(true, [], FC.LED_COLORS);
configuration.BOARD_ALIGNMENT_CONFIG = jQuery.extend(true, {}, FC.BOARD_ALIGNMENT_CONFIG);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
configuration.CRAFT_NAME = FC.CONFIG.craftName;
configuration.PILOT_NAME = FC.CONFIG.pilotName;
} else {
configuration.CRAFT_NAME = FC.CONFIG.name;
configuration.DISPLAY_NAME = FC.CONFIG.displayName;
}
configuration.MIXER_CONFIG = jQuery.extend(true, {}, FC.MIXER_CONFIG);
configuration.SENSOR_CONFIG = jQuery.extend(true, {}, FC.SENSOR_CONFIG);
configuration.PID_ADVANCED_CONFIG = jQuery.extend(true, {}, FC.PID_ADVANCED_CONFIG);
if (semver.gte(FC.CONFIG.apiVersion, "1.19.0")) {
configuration.LED_MODE_COLORS = jQuery.extend(true, [], FC.LED_MODE_COLORS);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.8.0")) {
configuration.FC_CONFIG = jQuery.extend(true, {}, FC.FC_CONFIG);
configuration.ARMING_CONFIG = jQuery.extend(true, {}, FC.ARMING_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.14.0")) {
configuration.MOTOR_3D_CONFIG = jQuery.extend(true, {}, FC.MOTOR_3D_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
configuration.SENSOR_ALIGNMENT = jQuery.extend(true, {}, FC.SENSOR_ALIGNMENT);
configuration.RX_CONFIG = jQuery.extend(true, {}, FC.RX_CONFIG);
configuration.FAILSAFE_CONFIG = jQuery.extend(true, {}, FC.FAILSAFE_CONFIG);
configuration.RXFAIL_CONFIG = jQuery.extend(true, [], FC.RXFAIL_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
configuration.RSSI_CONFIG = jQuery.extend(true, {}, FC.RSSI_CONFIG);
configuration.FEATURE_CONFIG = jQuery.extend(true, {}, FC.FEATURE_CONFIG);
configuration.MOTOR_CONFIG = jQuery.extend(true, {}, FC.MOTOR_CONFIG);
configuration.GPS_CONFIG = jQuery.extend(true, {}, FC.GPS_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
configuration.BEEPER_CONFIG = jQuery.extend(true, {}, FC.BEEPER_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
configuration.MODE_RANGES_EXTRA = jQuery.extend(true, [], FC.MODE_RANGES_EXTRA);
}
save();
}
}
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 semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME))
: MSP.promise(MSPCodes.MSP_NAME);
}).then(function() {
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.PILOT_NAME)) : Promise.resolve(true);
}).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() {
let chosenFileEntry = null;
const prefix = 'backup';
const suffix = 'json';
const filename = generateFilename(prefix, suffix);
const accepts = [{
description: `${suffix.toUpperCase()} files`, extensions: [suffix],
}];
// create or load the file
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: filename, accepts: accepts}, function (fileEntry) {
if (checkChromeRuntimeError()) {
return;
}
if (!fileEntry) {
console.log('No file selected, backup aborted.');
return;
}
chosenFileEntry = fileEntry;
// echo/console log path specified
chrome.fileSystem.getDisplayPath(chosenFileEntry, function (path) {
console.log(`Backup file path: ${path}`);
});
// change file entry from read only to read/write
chrome.fileSystem.getWritableEntry(chosenFileEntry, function (fileEntryWritable) {
// check if file is writable
chrome.fileSystem.isWritableEntry(fileEntryWritable, function (isWritable) {
if (isWritable) {
chosenFileEntry = fileEntryWritable;
// crunch the config object
const serializedConfigObject = JSON.stringify(configuration, null, '\t');
const blob = new Blob([serializedConfigObject], {type: 'text/plain'}); // first parameter for Blob needs to be an array
chosenFileEntry.createWriter(function (writer) {
writer.onerror = function (e) {
console.error(e);
};
let truncated = false;
writer.onwriteend = function () {
if (!truncated) {
// onwriteend will be fired again when truncation is finished
truncated = true;
writer.truncate(blob.size);
return;
}
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'Backup');
console.log('Write SUCCESSFUL');
if (callback) callback();
};
writer.write(blob);
}, function (e) {
console.error(e);
});
} else {
// Something went wrong or file is set to read only and cannot be changed
console.log('File appears to be read only, sorry.');
}
});
});
});
}
}
function configuration_restore(callback) {
let chosenFileEntry = null;
const accepts = [{
description: 'JSON files', extensions: ['json'],
}];
// load up the file
chrome.fileSystem.chooseEntry({type: 'openFile', accepts: accepts}, function (fileEntry) {
if (checkChromeRuntimeError()) {
return;
}
if (!fileEntry) {
console.log('No file selected, restore aborted.');
return;
}
chosenFileEntry = fileEntry;
// echo/console log path specified
chrome.fileSystem.getDisplayPath(chosenFileEntry, function (path) {
console.log(`Restore file path: ${path}`);
});
// read contents into variable
chosenFileEntry.file(function (file) {
const reader = new FileReader();
reader.onprogress = function (e) {
if (e.total > 1048576) { // 1 MB
// dont allow reading files bigger then 1 MB
console.log('File limit (1 MB) exceeded, aborting');
reader.abort();
}
};
reader.onloadend = function (e) {
if ((e.total != 0 && e.total == e.loaded) || GUI.isCordova()) {
// Cordova: Ignore verification : seem to have a bug with progressEvent returned
console.log('Read SUCCESSFUL');
let configuration;
try { // check if string provided is a valid JSON
configuration = JSON.parse(e.target.result);
} catch (err) {
// data provided != valid json object
console.log(`Data provided != valid JSON string, restore aborted: ${err}`);
return;
}
// validate
if (typeof configuration.generatedBy !== 'undefined' && compareVersions(configuration.generatedBy, CONFIGURATOR.BACKUP_FILE_VERSION_MIN_SUPPORTED)) {
if (!compareVersions(configuration.generatedBy, "1.14.0") && !migrate(configuration)) {
GUI.log(i18n.getMessage('backupFileUnmigratable'));
return;
}
if (configuration.FEATURE_CONFIG.features._featureMask) {
const features = new Features(FC.CONFIG);
features.setMask(configuration.FEATURE_CONFIG.features._featureMask);
configuration.FEATURE_CONFIG.features = features;
}
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'Restore');
configuration_upload(configuration, callback);
} else {
GUI.log(i18n.getMessage('backupFileIncompatible'));
}
}
};
reader.readAsText(file);
});
});
function compareVersions(generated, required) {
if (generated == undefined) {
return false;
}
return semver.gte(generated, required);
}
function migrate(configuration) {
let appliedMigrationsCount = 0;
let 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;
configuration.PID = {
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') {
const fixedLedStrip = [];
let index = 0;
while (configuration.LED_STRIP[index]) {
fixedLedStrip.push(configuration.LED_STRIP[index++]);
}
configuration.LED_STRIP = fixedLedStrip;
}
for (let profileIndex = 0; profileIndex < 3; profileIndex++) {
const 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++;
}
if (configuration.apiVersion == undefined) {
configuration.apiVersion = "1.0.0"; // a guess that will satisfy the rest of the code
}
// apiVersion previously stored without patchlevel
if (!semver.parse(configuration.apiVersion)) {
configuration.apiVersion += ".0";
if (!semver.parse(configuration.apiVersion)) {
return false;
}
}
if (compareVersions(migratedVersion, '0.63.0') && !compareVersions(configuration.apiVersion, '1.7.0')) {
// Serial configuation redesigned, 0.63.0 saves old and new configurations.
const ports = [];
for (const port of configuration.SERIAL_CONFIG.ports) {
const oldPort = port;
const newPort = {
identifier: oldPort.identifier,
functions: [],
msp_baudrate: String(configuration.SERIAL_CONFIG.mspBaudRate),
gps_baudrate: String(configuration.SERIAL_CONFIG.gpsBaudRate),
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
newPort.functions.push('GPS');
break;
case 3: // RX_SERIAL
newPort.functions.push('RX_SERIAL');
break;
case 10: // BLACKBOX ONLY
newPort.functions.push('BLACKBOX');
break;
case 11: // MSP, CLI, BLACKBOX, GPS-PASSTHROUGH
newPort.functions.push('MSP');
newPort.functions.push('BLACKBOX');
break;
}
ports.push(newPort);
}
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,
};
}
if (configuration.ARMING_CONFIG == undefined) {
configuration.ARMING_CONFIG = {
auto_disarm_delay: 5,
disarm_kill_switch: 1,
};
}
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) {
//reset it to the default
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 (let 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 (let i = 0; i < configuration.profiles[profileIndex].ServoConfig.length; i++) {
const 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;
}
}
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(FC.CONFIG.apiVersion, "1.14.0")) {
// api 1.14 removed old pid controllers
for (let profileIndex = 0; profileIndex < configuration.profiles.length; profileIndex++) {
let newPidControllerIndex = configuration.profiles[profileIndex].PID.controller;
switch (newPidControllerIndex) {
case 3:
case 4:
case 5:
newPidControllerIndex = 0;
break;
}
configuration.profiles[profileIndex].PID.controller = newPidControllerIndex;
}
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,
deadband3d_high: 1514,
neutral: 1460,
deadband3d_throttle: 50,
};
}
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 (let 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) {
configuration.SENSOR_ALIGNMENT = {
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) {
configuration.RX_CONFIG = {
serialrx_provider: 0,
spektrum_sat_bind: 0,
stick_center: 1500,
stick_min: 1100,
stick_max: 1900,
rx_min_usec: 885,
rx_max_usec: 2115,
};
}
if (configuration.FAILSAFE_CONFIG == undefined) {
configuration.FAILSAFE_CONFIG = {
failsafe_delay: 10,
failsafe_off_delay: 200,
failsafe_throttle: 1000,
failsafe_switch_mode: 0,
failsafe_throttle_low_delay: 100,
failsafe_procedure: 0,
};
}
if (configuration.RXFAIL_CONFIG == undefined) {
configuration.RXFAIL_CONFIG = [
{mode: 0, value: 1500},
{mode: 0, value: 1500},
{mode: 0, value: 1500},
{mode: 0, value: 875},
];
for (let i = 0; i < 14; i++) {
const rxfailChannel = {
mode: 1,
value: 1500,
};
configuration.RXFAIL_CONFIG.push(rxfailChannel);
}
}
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
appliedMigrationsCount++;
}
if (compareVersions(migratedVersion, '1.2.0')) {
// old version of the configurator incorrectly had a 'disabled' option for GPS SBAS mode.
if (FC.GPS_CONFIG.ublox_sbas < 0) {
FC.GPS_CONFIG.ublox_sbas = 0;
}
migratedVersion = '1.2.0';
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
appliedMigrationsCount++;
}
if (compareVersions(migratedVersion, '1.3.1')) {
// LED_COLORS & LED_MODE_COLORS support was added.
if (!configuration.LED_COLORS) {
configuration.LED_COLORS = [];
}
if (!configuration.LED_MODE_COLORS) {
configuration.LED_MODE_COLORS = [];
}
migratedVersion = '1.3.1';
GUI.log(i18n.getMessage('configMigratedTo', [migratedVersion]));
appliedMigrationsCount++;
}
if (appliedMigrationsCount > 0) {
GUI.log(i18n.getMessage('configMigrationSuccessful', [appliedMigrationsCount]));
}
return true;
}
function configuration_upload(configuration, _callback) {
function upload() {
let activeProfile = null;
let numProfiles = FC.CONFIG.numProfiles;
if (configuration.profiles.length < numProfiles) {
numProfiles = configuration.profiles.length;
}
const profileSpecificData = [
MSPCodes.MSP_SET_PID_CONTROLLER,
MSPCodes.MSP_SET_PID,
MSPCodes.MSP_SET_RC_TUNING,
MSPCodes.MSP_SET_ACC_TRIM,
];
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
profileSpecificData.push(MSPCodes.MSP_SET_RC_DEADBAND);
}
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function () {
activeProfile = FC.CONFIG.profile;
select_profile();
});
function select_profile() {
if (activeProfile > 0) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [0], false, upload_specific_data);
} else {
upload_specific_data();
}
}
function upload_specific_data() {
let savingProfile = 0;
let codeKey = 0;
function load_objects(profile) {
FC.PID = configuration.profiles[profile].PID;
FC.PIDS = configuration.profiles[profile].PIDs;
FC.RC_TUNING = configuration.profiles[profile].RC;
FC.CONFIG.accelerometerTrims = configuration.profiles[profile].AccTrim;
FC.SERVO_CONFIG = configuration.profiles[profile].ServoConfig;
FC.SERVO_RULES = configuration.profiles[profile].ServoRules;
FC.MODE_RANGES = configuration.profiles[profile].ModeRanges;
FC.ADJUSTMENT_RANGES = configuration.profiles[profile].AdjustmentRanges;
FC.RC_DEADBAND_CONFIG = configuration.profiles[profile].RCdeadband;
}
function upload_using_specific_commands() {
MSP.send_message(profileSpecificData[codeKey], mspHelper.crunch(profileSpecificData[codeKey]), false, function () {
codeKey++;
if (codeKey < profileSpecificData.length) {
upload_using_specific_commands();
} else {
codeKey = 0;
savingProfile++;
if (savingProfile < numProfiles) {
load_objects(savingProfile);
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [savingProfile], false, upload_using_specific_commands);
});
} else {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [activeProfile], false, upload_unique_data);
});
}
}
});
}
function upload_servo_configuration() {
mspHelper.sendServoConfigurations(upload_mode_ranges);
}
function upload_mode_ranges() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
if (configuration.MODE_RANGES_EXTRA == undefined) {
FC.MODE_RANGES_EXTRA = [];
for (let modeIndex = 0; modeIndex < FC.MODE_RANGES.length; modeIndex++) {
const defaultModeRangeExtra = {
modeId: FC.MODE_RANGES[modeIndex].modeId,
modeLogic: 0,
linkedTo: 0,
};
FC.MODE_RANGES_EXTRA.push(defaultModeRangeExtra);
}
} else {
FC.MODE_RANGES_EXTRA = configuration.MODE_RANGES_EXTRA;
}
}
mspHelper.sendModeRanges(upload_adjustment_ranges);
}
function upload_adjustment_ranges() {
mspHelper.sendAdjustmentRanges(upload_using_specific_commands);
}
// start uploading
load_objects(0);
upload_servo_configuration();
}
function upload_unique_data() {
let codeKey = 0;
const uniqueData = [
MSPCodes.MSP_SET_RX_MAP,
MSPCodes.MSP_SET_CF_SERIAL_CONFIG,
];
function update_unique_data_list() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
uniqueData.push([MSPCodes.MSP2_SET_TEXT, MSPCodes.CRAFT_NAME]);
uniqueData.push([MSPCodes.MSP2_SET_TEXT, MSPCodes.PILOT_NAME]);
} else {
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(FC.CONFIG.apiVersion, "1.8.0")) {
uniqueData.push(MSPCodes.MSP_SET_LOOP_TIME);
uniqueData.push(MSPCodes.MSP_SET_ARMING_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.14.0")) {
uniqueData.push(MSPCodes.MSP_SET_MOTOR_3D_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
uniqueData.push(MSPCodes.MSP_SET_SENSOR_ALIGNMENT);
uniqueData.push(MSPCodes.MSP_SET_RX_CONFIG);
uniqueData.push(MSPCodes.MSP_SET_FAILSAFE_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
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_RSSI_CONFIG);
}
}
function load_objects() {
FC.MISC = configuration.MISC;
FC.RC_MAP = configuration.RCMAP;
FC.SERIAL_CONFIG = configuration.SERIAL_CONFIG;
FC.LED_STRIP = configuration.LED_STRIP;
FC.LED_COLORS = configuration.LED_COLORS;
FC.LED_MODE_COLORS = configuration.LED_MODE_COLORS;
FC.ARMING_CONFIG = configuration.ARMING_CONFIG;
FC.FC_CONFIG = configuration.FC_CONFIG;
FC.MOTOR_3D_CONFIG = configuration.MOTOR_3D_CONFIG;
FC.SENSOR_ALIGNMENT = configuration.SENSOR_ALIGNMENT;
FC.RX_CONFIG = configuration.RX_CONFIG;
FC.FAILSAFE_CONFIG = configuration.FAILSAFE_CONFIG;
FC.RXFAIL_CONFIG = configuration.RXFAIL_CONFIG;
FC.FEATURE_CONFIG = configuration.FEATURE_CONFIG;
FC.MOTOR_CONFIG = configuration.MOTOR_CONFIG;
FC.GPS_CONFIG = configuration.GPS_CONFIG;
FC.RSSI_CONFIG = configuration.RSSI_CONFIG;
FC.BOARD_ALIGNMENT_CONFIG = configuration.BOARD_ALIGNMENT_CONFIG;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
FC.CONFIG.craftName = configuration.CRAFT_NAME;
FC.CONFIG.pilotName = configuration.PILOT_NAME;
} else {
FC.CONFIG.name = configuration.CRAFT_NAME;
FC.CONFIG.displayName = configuration.DISPLAY_NAME;
}
FC.MIXER_CONFIG = configuration.MIXER_CONFIG;
FC.SENSOR_CONFIG = configuration.SENSOR_CONFIG;
FC.PID_ADVANCED_CONFIG = configuration.PID_ADVANCED_CONFIG;
FC.BEEPER_CONFIG.beepers = new Beepers(FC.CONFIG);
FC.BEEPER_CONFIG.beepers.setDisabledMask(configuration.BEEPER_CONFIG.beepers._beeperDisabledMask);
FC.BEEPER_CONFIG.dshotBeaconTone = configuration.BEEPER_CONFIG.dshotBeaconTone;
FC.BEEPER_CONFIG.dshotBeaconConditions = new Beepers(FC.CONFIG, [ "RX_LOST", "RX_SET" ]);
FC.BEEPER_CONFIG.dshotBeaconConditions.setDisabledMask(configuration.BEEPER_CONFIG.dshotBeaconConditions._beeperDisabledMask);
}
function send_unique_data_item() {
if (codeKey < uniqueData.length) {
const callback = () => {
codeKey++;
send_unique_data_item();
};
if (Array.isArray(uniqueData[codeKey])) {
MSP.send_message(uniqueData[codeKey][0], mspHelper.crunch(...uniqueData[codeKey]), false, callback);
} else {
MSP.send_message(uniqueData[codeKey], mspHelper.crunch(uniqueData[codeKey]), false, callback);
}
} else {
send_led_strip_config();
}
}
load_objects();
update_unique_data_list();
// start uploading
send_unique_data_item();
}
function send_led_strip_config() {
mspHelper.sendLedStripConfig(send_led_strip_colors);
}
function send_led_strip_colors() {
mspHelper.sendLedStripColors(send_led_strip_mode_colors);
}
function send_led_strip_mode_colors() {
if (semver.gte(FC.CONFIG.apiVersion, "1.19.0")) {
mspHelper.sendLedStripModeColors(send_rxfail_config);
} else {
send_rxfail_config();
}
}
function send_rxfail_config() {
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
mspHelper.sendRxFailConfig(save_to_eeprom);
} else {
save_to_eeprom();
}
}
function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, reboot);
}
function reboot() {
GUI.log(i18n.getMessage('eeprom_saved_ok'));
GUI.tab_switch_cleanup(function() {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(_callback));
});
}
}
if (CONFIGURATOR.virtualMode) {
FC.resetState();
FC.CONFIG.apiVersion = CONFIGURATOR.virtualApiVersion;
sensor_status(FC.CONFIG.activeSensors);
update_dataflash_global();
}
upload();
}
}

View file

@ -18,10 +18,7 @@ const API_VERSION_1_45 = '1.45.0';
const CONFIGURATOR = {
// all versions are specified and compared using semantic versioning http://semver.org/
API_VERSION_ACCEPTED: '1.2.1',
API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE: '1.5.0',
API_VERSION_MIN_SUPPORTED_PID_CONTROLLER_CHANGE: '1.5.0',
BACKUP_FILE_VERSION_MIN_SUPPORTED: '0.55.0', // chrome.runtime.getManifest().version is stored as string, so does this one
API_VERSION_ACCEPTED: API_VERSION_1_41,
API_VERSION_MAX_SUPPORTED: API_VERSION_1_45,
connectionValid: false,

View file

@ -643,7 +643,7 @@ const FC = {
dterm_lowpass_dyn_max_hz: 250,
dyn_lpf_curve_expo: 5,
dterm_lowpass_type: this.FILTER_TYPE_FLAGS.PT1,
dterm_lowpass2_hz: 150,
dterm_lowpass2_hz: 200,
dterm_lowpass2_type: this.FILTER_TYPE_FLAGS.BIQUAD,
dterm_notch_cutoff: 160,
dterm_notch_hz: 260,
@ -712,8 +712,6 @@ const FC = {
getSerialRxTypes: () => {
const apiVersion = FC.CONFIG.apiVersion;
const flightControllerIdentifier = FC.CONFIG.flightControllerIdentifier;
const flightControllerVersion = FC.CONFIG.flightControllerVersion;
// defaults
const serialRxTypes = [
@ -724,33 +722,14 @@ const FC = {
'SUMH',
'XBUS_MODE_B',
'XBUS_MODE_B_RJ01',
'IBUS',
'CRSF',
'JETIEXBUS',
'SPEKTRUM2048/SRXL',
'TARGET_CUSTOM',
'FrSky FPort',
];
if (semver.gte(apiVersion, "1.15.0")) {
serialRxTypes.push('IBUS');
}
if ((flightControllerIdentifier === 'BTFL' && semver.gte(flightControllerVersion, "2.6.0")) ||
(flightControllerIdentifier === 'CLFL' && semver.gte(apiVersion, API_VERSION_1_31))) {
serialRxTypes.push('JETIEXBUS');
}
if (semver.gte(apiVersion, API_VERSION_1_31)) {
serialRxTypes.push('CRSF');
}
if (semver.gte(apiVersion, "1.24.0")) {
serialRxTypes.push('SPEKTRUM2048/SRXL');
}
if (semver.gte(apiVersion, API_VERSION_1_35)) {
serialRxTypes.push('TARGET_CUSTOM');
}
if (semver.gte(apiVersion, API_VERSION_1_37)) {
serialRxTypes.push('FrSky FPort');
}
if (semver.gte(apiVersion, API_VERSION_1_42)) {
serialRxTypes.push('SPEKTRUM SRXL2');
}
@ -822,14 +801,7 @@ const FC = {
},
boardHasVcp() {
let hasVcp = false;
if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_37)) {
hasVcp = bit_check(this.CONFIG.targetCapabilities, this.TARGET_CAPABILITIES_FLAGS.HAS_VCP);
} else {
hasVcp = BOARD.find_board_definition(this.CONFIG.boardIdentifier).vcp;
}
return hasVcp;
return bit_check(this.CONFIG.targetCapabilities, this.TARGET_CAPABILITIES_FLAGS.HAS_VCP);
},
boardHasFlashBootloader() {
@ -849,9 +821,6 @@ const FC = {
getFilterDefaults() {
const versionFilterDefaults = this.DEFAULT;
// Change filter defaults depending on API version here
if (semver.eq(this.CONFIG.apiVersion, API_VERSION_1_40)) {
versionFilterDefaults.dterm_lowpass2_hz = 200;
} else if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_41)) {
versionFilterDefaults.gyro_lowpass_hz = 150;
versionFilterDefaults.gyro_lowpass_type = this.FILTER_TYPE_FLAGS.BIQUAD;
versionFilterDefaults.gyro_lowpass2_hz = 0;
@ -860,6 +829,7 @@ const FC = {
versionFilterDefaults.dterm_lowpass_type = this.FILTER_TYPE_FLAGS.BIQUAD;
versionFilterDefaults.dterm_lowpass2_hz = 150;
versionFilterDefaults.dterm_lowpass2_type = this.FILTER_TYPE_FLAGS.BIQUAD;
if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_42)) {
versionFilterDefaults.gyro_lowpass_hz = 200;
versionFilterDefaults.gyro_lowpass_dyn_min_hz = 200;
@ -874,6 +844,7 @@ const FC = {
versionFilterDefaults.dterm_lowpass2_hz = 150;
versionFilterDefaults.dterm_lowpass2_type = this.FILTER_TYPE_FLAGS.PT1;
}
if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_44)) {
versionFilterDefaults.dyn_notch_q = 300;
versionFilterDefaults.gyro_lowpass_hz = 250;
@ -883,10 +854,11 @@ const FC = {
versionFilterDefaults.dterm_lowpass_dyn_min_hz = 75;
versionFilterDefaults.dterm_lowpass_dyn_max_hz = 150;
}
if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_45)) {
versionFilterDefaults.dyn_notch_min_hz = 100;
}
}
return versionFilterDefaults;
},

View file

@ -730,11 +730,7 @@ function updateTabList(features) {
$('#tabs ul.mode-connected li.tab_osd').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
$('#tabs ul.mode-connected li.tab_power').show();
} else {
$('#tabs ul.mode-connected li.tab_power').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
$('#tabs ul.mode-connected li.tab_vtx').show();

File diff suppressed because it is too large Load diff

View file

@ -445,11 +445,7 @@ function processUid() {
connectionTimestamp = Date.now();
GUI.log(i18n.getMessage('uniqueDeviceIdReceived', [uniqueDeviceIdentifier]));
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
processCraftName();
} else {
setRtc();
}
});
}
@ -471,19 +467,12 @@ async function processCraftName() {
}
function setRtc() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
MSP.send_message(MSPCodes.MSP_SET_RTC, mspHelper.crunch(MSPCodes.MSP_SET_RTC), false, finishOpen);
} else {
finishOpen();
}
}
function finishOpen() {
CONFIGURATOR.connectionValid = true;
GUI.allowedTabs = GUI.defaultAllowedFCTabsWhenConnected.slice();
if (semver.lt(FC.CONFIG.apiVersion, "1.4.0")) {
GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('led_strip'), 1);
}
if (GUI.isCordova()) {
UI_PHONES.reset();
@ -689,11 +678,7 @@ function have_sensor(sensors_detected, sensor_code) {
case 'sonar':
return bit_check(sensors_detected, 4);
case 'gyro':
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
return bit_check(sensors_detected, 5);
} else {
return true;
}
}
return false;
}
@ -704,11 +689,7 @@ function startLiveDataRefreshTimer() {
}
async function getStatus() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_32)) {
return MSP.promise(MSPCodes.MSP_STATUS_EX);
} else {
return MSP.promise(MSPCodes.MSP_STATUS);
}
}
async function update_live_status() {

View file

@ -289,26 +289,13 @@ adjustments.cleanup = function (callback) {
adjustments.adjust_template = function () {
const selectFunction = $('#functionSelectionSelect');
let elementsNumber;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
elementsNumber = 31; // OSD Profile Select & LED Profile Select
} else if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
elementsNumber = 29; // PID Audio
} else if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
elementsNumber = 26; // PID Audio
} else if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
elementsNumber = 25; // Horizon Strength
} else {
elementsNumber = 24; // Setpoint transition
}
const elementsNumber = 31; // OSD Profile Select & LED Profile Select
for (let i = 0; i < elementsNumber; i++) {
selectFunction.append(new Option(i18n.getMessage(`adjustmentsFunction${i}`), i));
}
// For 1.40, the D Setpoint has been replaced, so we replace it with the correct values
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
const element22 = selectFunction.find("option[value='22']");
const element23 = selectFunction.find("option[value='23']");
@ -320,7 +307,6 @@ adjustments.adjust_template = function () {
// Reorder, we insert it with the other FF elements to be coherent...
element22.insertAfter(selectFunction.find("option[value='25']"));
element23.insertAfter(selectFunction.find("option[value='28']"));
}
};
window.TABS.adjustments = adjustments;

View file

@ -8,8 +8,7 @@ auxiliary.initialize = function (callback) {
let prevChannelsValues = null;
function get_mode_ranges() {
MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false,
semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41) ? get_mode_ranges_extra : get_box_ids);
MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_mode_ranges_extra);
}
function get_mode_ranges_extra() {
@ -57,7 +56,7 @@ auxiliary.initialize = function (callback) {
$(newMode).find('a.addLink').data('modeElement', newMode);
// hide link button for ARM
if (modeId == 0 || semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
if (modeId == 0) {
$(newMode).find('.addLink').hide();
}
@ -75,12 +74,11 @@ auxiliary.initialize = function (callback) {
logicOption.val(0);
logicList.append(logicOption);
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)){
logicOption = logicOptionTemplate.clone();
logicOption.text(i18n.getMessage('auxiliaryModeLogicAND'));
logicOption.val(1);
logicList.append(logicOption);
}
logicOptionTemplate.val(0);
}
@ -265,15 +263,7 @@ auxiliary.initialize = function (callback) {
// skip linked modes for now
for (let modeRangeIndex = 0; modeRangeIndex < FC.MODE_RANGES.length; modeRangeIndex++) {
const modeRange = FC.MODE_RANGES[modeRangeIndex];
let modeRangeExtra = {
id: modeRange.id,
modeLogic: 0,
linkedTo: 0,
};
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
modeRangeExtra = FC.MODE_RANGES_EXTRA[modeRangeIndex];
}
const modeRangeExtra = FC.MODE_RANGES_EXTRA[modeRangeIndex];
if (modeRange.id != modeId || modeRangeExtra.id != modeId) {
continue;
@ -454,7 +444,6 @@ auxiliary.initialize = function (callback) {
if (i == 0) {
let armSwitchActive = false;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
if (FC.CONFIG.armingDisableCount > 0) {
// check the highest bit of the armingDisableFlags. This will be the ARMING_DISABLED_ARMSWITCH flag.
const armSwitchMask = 1 << (FC.CONFIG.armingDisableCount - 1);
@ -462,7 +451,6 @@ auxiliary.initialize = function (callback) {
armSwitchActive = true;
}
}
}
// If the ARMING_DISABLED_ARMSWITCH flag is set then that means that arming is disabled
// and the arm switch is in a valid arming range. Highlight the mode in red to indicate

View file

@ -20,27 +20,26 @@ configuration.initialize = function (callback) {
function load_config() {
Promise
.resolve(true)
.then(() => { return MSP.promise(MSPCodes.MSP_FEATURE_CONFIG); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36) ? MSP.promise(MSPCodes.MSP_BEEPER_CONFIG) : true; })
.then(() => { return MSP.promise(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33) ? MSP.promise(MSPCodes.MSP_GPS_CONFIG) : true; })
.then(() => { return MSP.promise(MSPCodes.MSP_ACC_TRIM); })
.then(() => { return semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_33) ? MSP.promise(MSPCodes.MSP_MISC) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.8.0") ? MSP.promise(MSPCodes.MSP_ARMING_CONFIG) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.17.0") ? MSP.promise(MSPCodes.MSP_RC_DEADBAND) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.16.0") ? MSP.promise(MSPCodes.MSP_SENSOR_CONFIG) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.15.0") ? MSP.promise(MSPCodes.MSP_SENSOR_ALIGNMENT) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.20.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)
.then(() => MSP.promise(MSPCodes.MSP_FEATURE_CONFIG))
.then(() => MSP.promise(MSPCodes.MSP_BEEPER_CONFIG))
.then(() => MSP.promise(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG))
.then(() => MSP.promise(MSPCodes.MSP_GPS_CONFIG))
.then(() => MSP.promise(MSPCodes.MSP_ACC_TRIM))
.then(() => MSP.promise(MSPCodes.MSP_ARMING_CONFIG))
.then(() => MSP.promise(MSPCodes.MSP_RC_DEADBAND))
.then(() => MSP.promise(MSPCodes.MSP_SENSOR_CONFIG))
.then(() => MSP.promise(MSPCodes.MSP_SENSOR_ALIGNMENT))
.then(() => semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP_NAME)
: Promise.resolve(true); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
: Promise.resolve(true))
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME))
: Promise.resolve(true); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31) ? MSP.promise(MSPCodes.MSP_RX_CONFIG) : true; })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.PILOT_NAME)) : Promise.resolve(true); })
.then(() => { return MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG); })
.then(() => { load_html(); });
: Promise.resolve(true))
.then(() => MSP.promise(MSPCodes.MSP_RX_CONFIG))
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.PILOT_NAME)) : Promise.resolve(true))
.then(() => MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG))
.then(() => load_html());
}
function load_html() {
@ -58,20 +57,14 @@ configuration.initialize = function (callback) {
// Dshot Beeper
const dshotBeeper_e = $('.tab-configuration .dshotbeeper');
const dshotBeacon_e = $('.tab-configuration .dshotbeacon');
const dshotBeeperSwitch = $('#dshotBeeperSwitch');
const dshotBeeperBeaconTone = $('select.dshotBeeperBeaconTone');
const dshotBeaconCondition_e = $('tbody.dshotBeaconConditions');
const dshotBeaconSwitch_e = $('tr.dshotBeaconSwitch');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
for (let i = 1; i <= 5; i++) {
dshotBeeperBeaconTone.append(`<option value="${(i)}">${(i)}</option>`);
}
dshotBeeper_e.show();
} else {
dshotBeeper_e.hide();
}
dshotBeeperBeaconTone.change(function() {
FC.BEEPER_CONFIG.dshotBeaconTone = dshotBeeperBeaconTone.val();
@ -80,7 +73,6 @@ configuration.initialize = function (callback) {
dshotBeeperBeaconTone.val(FC.BEEPER_CONFIG.dshotBeaconTone);
const template = $('.beepers .beeper-template');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
dshotBeaconSwitch_e.hide();
FC.BEEPER_CONFIG.dshotBeaconConditions.generateElements(template, dshotBeaconCondition_e);
@ -88,33 +80,12 @@ configuration.initialize = function (callback) {
const element = $(this);
FC.BEEPER_CONFIG.dshotBeaconConditions.updateData(element);
});
} else {
dshotBeaconCondition_e.hide();
dshotBeeperSwitch.change(function() {
if ($(this).is(':checked')) {
dshotBeacon_e.show();
if (dshotBeeperBeaconTone.val() == 0) {
dshotBeeperBeaconTone.val(1).change();
}
} else {
dshotBeeperBeaconTone.val(0).change();
dshotBeacon_e.hide();
}
});
dshotBeeperSwitch.prop('checked', FC.BEEPER_CONFIG.dshotBeaconTone !== 0).change();
}
// Analog Beeper
const destination = $('.beepers .beeper-configuration');
const beeper_e = $('.tab-configuration .beepers');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
FC.BEEPER_CONFIG.beepers.generateElements(template, destination);
} else {
beeper_e.hide();
}
// translate to user-selected language
i18n.localizePage();
@ -147,10 +118,6 @@ configuration.initialize = function (callback) {
const orientation_gyro_2_align_e = $('select.gyro_2_align');
gyro_align_content_e.hide(); // default value
if (semver.lt(FC.CONFIG.apiVersion, "1.15.0")) {
$('.tab-configuration .sensoralignment').hide();
} else {
for (let i = 0; i < alignments.length; i++) {
orientation_gyro_e.append(`<option value="${(i+1)}">${alignments[i]}</option>`);
orientation_acc_e.append(`<option value="${(i+1)}">${alignments[i]}</option>`);
@ -198,7 +165,6 @@ configuration.initialize = function (callback) {
});
// Multi gyro config
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
gyro_align_content_e.show();
legacy_gyro_alignment_e.hide();
@ -261,11 +227,8 @@ configuration.initialize = function (callback) {
FC.SENSOR_ALIGNMENT.gyro_2_align = value;
});
}
}
// Gyro and PID update
const gyroUse32kHzElement = $('input[id="gyroUse32kHz"]');
const gyroTextElement = $('input.gyroFrequency');
const gyroSelectElement = $('select.gyroSyncDenom');
const pidSelectElement = $('select.pidProcessDenom');
@ -288,7 +251,7 @@ configuration.initialize = function (callback) {
gyroSelectElement.empty();
const MAX_DENOM = semver.gte(FC.CONFIG.apiVersion, "1.25.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41) ? 32 : 8;
const MAX_DENOM = 8;
for (let denom = 1; denom <= MAX_DENOM; denom++) {
addDenomOption(gyroSelectElement, denom, gyroBaseFreq);
@ -311,17 +274,6 @@ configuration.initialize = function (callback) {
gyroTextElement.val(gyroContent);
};
if (semver.gte(FC.CONFIG.apiVersion, "1.25.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
gyroUse32kHzElement.prop('checked', FC.PID_ADVANCED_CONFIG.gyroUse32kHz !== 0);
gyroUse32kHzElement.change(function () {
const gyroBaseFreq = ($(this).is(':checked'))? 32 : 8;
updateGyroDenom(gyroBaseFreq);
}).change();
} else {
$('div.gyroUse32kHz').hide();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
@ -329,7 +281,6 @@ configuration.initialize = function (callback) {
} else {
updateGyroDenom(8);
}
}
gyroSelectElement.val(FC.PID_ADVANCED_CONFIG.gyro_sync_denom);
@ -343,15 +294,12 @@ configuration.initialize = function (callback) {
pidBaseFreq = FC.CONFIG.sampleRateHz / 1000;
} else {
pidBaseFreq = 8;
if (semver.gte(FC.CONFIG.apiVersion, "1.25.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41) && gyroUse32kHzElement.is(':checked')) {
pidBaseFreq = 32;
}
pidBaseFreq = pidBaseFreq / parseInt($(this).val());
pidBaseFreq /= parseInt($(this).val());
}
pidSelectElement.empty();
const MAX_DENOM = semver.gte(FC.CONFIG.apiVersion, "1.24.0") ? 16 : 8;
const MAX_DENOM = 8;
for (let denom = 1; denom <= MAX_DENOM; denom++) {
addDenomOption(pidSelectElement, denom, pidBaseFreq);
@ -367,14 +315,6 @@ configuration.initialize = function (callback) {
$('input[id="magHardwareSwitch"]').prop('checked', FC.SENSOR_CONFIG.mag_hardware !== 1);
// Only show these sections for supported FW
if (semver.lt(FC.CONFIG.apiVersion, "1.16.0")) {
$('.selectPidProcessDenom').hide();
}
if (semver.lt(FC.CONFIG.apiVersion, "1.16.0")) {
$('.hardwareSelection').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
$('input[name="craftName"]').val(FC.CONFIG.craftName);
$('input[name="pilotName"]').val(FC.CONFIG.pilotName);
@ -383,27 +323,15 @@ configuration.initialize = function (callback) {
$('.pilotName').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
$('input[name="fpvCamAngleDegrees"]').val(FC.RX_CONFIG.fpvCamAngleDegrees);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
$('input[name="fpvCamAngleDegrees"]').attr("max", 90);
}
} else {
$('div.fpvCamAngleDegrees').hide();
}
if (semver.lt(FC.CONFIG.apiVersion, "1.20.0")) {
$('.miscSettings').hide();
}
// generate GPS
const gpsProtocols = [
'NMEA',
'UBLOX',
'MSP',
];
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
gpsProtocols.push('MSP');
}
const gpsBaudRates = [
'115200',
@ -464,13 +392,8 @@ configuration.initialize = function (callback) {
}).prop('checked', FC.GPS_CONFIG.auto_config === 1).change();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_34)) {
gpsAutoBaudGroup.show();
gpsAutoConfigGroup.show();
} else {
gpsAutoBaudGroup.hide();
gpsAutoConfigGroup.hide();
}
gpsUbloxGalileoElement.change(function() {
FC.GPS_CONFIG.ublox_use_galileo = $(this).is(':checked') ? 1 : 0;
@ -493,15 +416,8 @@ configuration.initialize = function (callback) {
gpsBaudrateElement.append(`<option value="${gpsBaudRates[baudRateIndex]}">${gpsBaudRates[baudRateIndex]}</option>`);
}
if (semver.lt(FC.CONFIG.apiVersion, "1.6.0")) {
gpsBaudrateElement.change(function () {
FC.SERIAL_CONFIG.gpsBaudRate = parseInt($(this).val());
});
gpsBaudrateElement.val(FC.SERIAL_CONFIG.gpsBaudRate);
} else {
gpsBaudrateElement.prop("disabled", true);
gpsBaudrateElement.parent().hide();
}
// fill board alignment
$('input[name="board_align_roll"]').val(FC.BOARD_ALIGNMENT_CONFIG.roll);
@ -512,10 +428,8 @@ configuration.initialize = function (callback) {
$('input[name="roll"]').val(FC.CONFIG.accelerometerTrims[1]);
$('input[name="pitch"]').val(FC.CONFIG.accelerometerTrims[0]);
$('._smallAngle').toggle(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37));
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
$('._smallAngle').show();
$('input[id="configurationSmallAngle"]').val(FC.ARMING_CONFIG.small_angle);
}
// UI hooks
@ -539,10 +453,8 @@ configuration.initialize = function (callback) {
});
$('input[id="accHardwareSwitch"]').change(function() {
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
const checked = $(this).is(':checked');
$('.accelNeeded').toggle(checked);
}
}).change();
$(features_e).filter('select').change(function () {
@ -569,13 +481,9 @@ configuration.initialize = function (callback) {
FC.CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val());
// small angle configuration
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
FC.ARMING_CONFIG.small_angle = parseInt($('input[id="configurationSmallAngle"]').val());
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
FC.SENSOR_ALIGNMENT.gyro_to_use = parseInt(orientation_gyro_to_use_e.val());
}
FC.PID_ADVANCED_CONFIG.gyro_sync_denom = parseInt(gyroSelectElement.val());
@ -589,9 +497,6 @@ configuration.initialize = function (callback) {
}
FC.PID_ADVANCED_CONFIG.pid_process_denom = value;
if (semver.gte(FC.CONFIG.apiVersion, "1.25.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
FC.PID_ADVANCED_CONFIG.gyroUse32kHz = $('input[id="gyroUse32kHz"]').is(':checked') ? 1 : 0;
}
FC.RX_CONFIG.fpvCamAngleDegrees = parseInt($('input[name="fpvCamAngleDegrees"]').val());
@ -599,10 +504,8 @@ configuration.initialize = function (callback) {
self.analyticsChanges = {};
// fill some data
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_34)) {
FC.GPS_CONFIG.auto_baud = $('input[name="gps_auto_baud"]').is(':checked') ? 1 : 0;
FC.GPS_CONFIG.auto_config = $('input[name="gps_auto_config"]').is(':checked') ? 1 : 0;
}
FC.SENSOR_CONFIG.acc_hardware = $('input[id="accHardwareSwitch"]').is(':checked') ? 0 : 1;
FC.SENSOR_CONFIG.baro_hardware = $('input[id="baroHardwareSwitch"]').is(':checked') ? 0 : 1;
@ -621,28 +524,24 @@ configuration.initialize = function (callback) {
function save_config() {
Promise
.resolve(true)
.then(() => { return MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG)); })
.then(() => { return (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) ?
MSP.promise(MSPCodes.MSP_SET_BEEPER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BEEPER_CONFIG)) : true; })
.then(() => { return (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_33)) ?
MSP.promise(MSPCodes.MSP_SET_MISC, mspHelper.crunch(MSPCodes.MSP_SET_MISC)) : true; })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG)); })
.then(() => { return (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) ?
MSP.promise(MSPCodes.MSP_SET_GPS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_GPS_CONFIG)) : true; })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND)); })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT)); })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG)); })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM)); })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_ARMING_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ARMING_CONFIG)); })
.then(() => { return MSP.promise(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG)); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
.then(() => MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG)))
.then(() => MSP.promise(MSPCodes.MSP_SET_BEEPER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BEEPER_CONFIG)))
.then(() => MSP.promise(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG)))
.then(() => MSP.promise(MSPCodes.MSP_SET_GPS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_GPS_CONFIG)))
.then(() => MSP.promise(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND)))
.then(() => MSP.promise(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT)))
.then(() => MSP.promise(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG)))
.then(() => MSP.promise(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM)))
.then(() => MSP.promise(MSPCodes.MSP_SET_ARMING_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ARMING_CONFIG)))
.then(() => MSP.promise(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG)))
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)
? MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.CRAFT_NAME))
: MSP.promise(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME)); })
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ?
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.PILOT_NAME)) : Promise.resolve(true); })
.then(() => { return (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) ? MSP.promise(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG)) : true; })
.then(() => { return MSP.promise(MSPCodes.MSP_EEPROM_WRITE); })
.then(() => { reboot(); });
: MSP.promise(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME)))
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ?
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.PILOT_NAME)) : Promise.resolve(true))
.then(() => MSP.promise(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG)))
.then(() => MSP.promise(MSPCodes.MSP_EEPROM_WRITE))
.then(() => reboot());
}
function reboot() {

View file

@ -17,8 +17,7 @@ failsafe.initialize = function (callback) {
}
function load_rxfail_config() {
MSP.send_message(MSPCodes.MSP_RXFAIL_CONFIG, false, false,
semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41) ? load_gps_rescue : get_box_names);
MSP.send_message(MSPCodes.MSP_RXFAIL_CONFIG, false, false, load_gps_rescue);
}
function load_gps_rescue() {
@ -134,21 +133,6 @@ failsafe.initialize = function (callback) {
for (let i = 0; i < FC.RXFAIL_CONFIG.length; i++) {
if (i < channelNames.length) {
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
fullChannels_e.append(`\
<div class="number">\
<div class="channelprimary">\
<span>${channelNames[i]}</span>\
</div>\
<div class="cf_tip channelsetting" title="${i18n.getMessage("failsafeChannelFallbackSettingsAuto")}">\
<select class="aux_set" id="${i}">\
<option value="0">Auto</option>\
<option value="1">Hold</option>\
</select>\
</div>\
</div>\
`);
} else {
fullChannels_e.append(`\
<div class="number">\
<div class="channelprimary">\
@ -164,7 +148,6 @@ failsafe.initialize = function (callback) {
<div class="auxiliary"><input type="number" name="aux_value" min="750" max="2250" step="25" id="${i}"/></div>\
</div>\
`);
}
} else {
const messageKey = `controlAxisAux${aux_index++}`;
fullChannels_e.append(`\
@ -231,16 +214,8 @@ failsafe.initialize = function (callback) {
FC.FEATURE_CONFIG.features.generateElements($('.tab-failsafe .featuresNew'));
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
$('tbody.rxFailsafe').hide();
toggleStage2(true);
} else {
const failsafeFeature = $('input[name="FAILSAFE"]');
failsafeFeature.change(function () {
toggleStage2($(this).is(':checked'));
});
toggleStage2(FC.FEATURE_CONFIG.features.isEnabled('FAILSAFE'));
}
$('input[name="failsafe_throttle"]').val(FC.FAILSAFE_CONFIG.failsafe_throttle);
$('input[name="failsafe_off_delay"]').val((FC.FAILSAFE_CONFIG.failsafe_off_delay / 10.0).toFixed(1));
@ -273,21 +248,13 @@ failsafe.initialize = function (callback) {
break;
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
// `failsafe_kill_switch` has been renamed to `failsafe_switch_mode`.
// It is backwards compatible with `failsafe_kill_switch`
$('select[name="failsafe_switch_mode"]').val(FC.FAILSAFE_CONFIG.failsafe_switch_mode);
$('div.kill_switch').hide();
}
else {
$('input[name="failsafe_kill_switch"]').prop('checked', FC.FAILSAFE_CONFIG.failsafe_switch_mode);
$('div.failsafe_switch').hide();
}
// The GPS Rescue tab is only available for 1.40 or later, and the parameters for 1.41
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
// Load GPS Rescue parameters
$('input[name="gps_rescue_angle"]').val(FC.GPS_RESCUE.angle);
$('input[name="gps_rescue_initial_altitude"]').val(FC.GPS_RESCUE.initialAltitudeM);
@ -321,19 +288,6 @@ failsafe.initialize = function (callback) {
$('input[name="gps_rescue_min_dth"]').attr("min", 20);
}
} else {
// GPS Rescue Parameters not available
$('.pro4 > .proceduresettings').hide();
}
} else {
// GPS Rescue option not available
$('.pro4').hide();
}
$('a.save').click(function () {
// gather data that doesn't have automatic change event bound
@ -355,14 +309,8 @@ failsafe.initialize = function (callback) {
FC.FAILSAFE_CONFIG.failsafe_procedure = 2;
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
FC.FAILSAFE_CONFIG.failsafe_switch_mode = $('select[name="failsafe_switch_mode"]').val();
}
else {
FC.FAILSAFE_CONFIG.failsafe_switch_mode = $('input[name="failsafe_kill_switch"]').is(':checked') ? 1 : 0;
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
// Load GPS Rescue parameters
FC.GPS_RESCUE.angle = $('input[name="gps_rescue_angle"]').val();
FC.GPS_RESCUE.initialAltitudeM = $('input[name="gps_rescue_initial_altitude"]').val();
@ -373,7 +321,6 @@ failsafe.initialize = function (callback) {
FC.GPS_RESCUE.throttleHover = $('input[name="gps_rescue_throttle_hover"]').val();
FC.GPS_RESCUE.minSats = $('input[name="gps_rescue_min_sats"]').val();
FC.GPS_RESCUE.sanityChecks = $('select[name="gps_rescue_sanity_checks"]').val();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
FC.GPS_RESCUE.ascendRate = $('input[name="gps_rescue_ascend_rate"]').val() * 100;
@ -395,8 +342,7 @@ failsafe.initialize = function (callback) {
}
function save_feature_config() {
MSP.send_message(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG), false,
semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41) ? save_gps_rescue : save_to_eeprom);
MSP.send_message(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG), false, save_gps_rescue);
}
function save_gps_rescue() {

View file

@ -54,9 +54,6 @@ gps.initialize = function (callback) {
const usedArray = ['gnssUsedUnused', 'gnssUsedUsed'];
const healthyArray = ['gnssHealthyUnknown', 'gnssHealthyHealthy', 'gnssHealthyUnhealthy', 'gnssHealthyUnknown'];
let alt = FC.GPS_DATA.alt;
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
alt = alt / 10;
}
$('.GPS_info td.fix').html((FC.GPS_DATA.fix) ? i18n.getMessage('gpsFixTrue') : i18n.getMessage('gpsFixFalse'));
$('.GPS_info td.alt').text(`${alt} m`);

View file

@ -11,19 +11,9 @@ led_strip.initialize = function (callback, scrollPosition) {
let selectedModeColor = null;
const functionTag = '.function-';
if (semver.lt(FC.CONFIG.apiVersion, "1.20.0")) {
TABS.led_strip.functions = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b'];
TABS.led_strip.baseFuncs = ['c', 'f', 'a', 'b', 'g', 'r'];
TABS.led_strip.overlays = ['t', 's', 'i', 'w'];
} else {
TABS.led_strip.functions = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l', 'o', 'n'];
TABS.led_strip.baseFuncs = ['c', 'f', 'a', 'l', 's', 'g', 'r'];
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
TABS.led_strip.overlays = ['t', 'o', 'b', 'n', 'i', 'w'];
} else {
TABS.led_strip.overlays = ['t', 'o', 'b', 'v', 'i', 'w'];
}
}
TABS.led_strip.wireMode = false;
@ -40,10 +30,7 @@ led_strip.initialize = function (callback, scrollPosition) {
}
function load_led_mode_colors() {
if (semver.gte(FC.CONFIG.apiVersion, "1.19.0"))
MSP.send_message(MSPCodes.MSP_LED_STRIP_MODECOLOR, false, false, load_html);
else
load_html();
}
@ -73,14 +60,8 @@ led_strip.initialize = function (callback, scrollPosition) {
const theHTML = [];
let theHTMLlength = 0;
for (let i = 0; i < 256; i++) {
if (semver.lte(FC.CONFIG.apiVersion, "1.19.0")) {
theHTML[theHTMLlength++] = ('<div class="gPoint"><div class="indicators"><span class="north"></span><span class="south"></span><span class="west"></span><span class="east"></span><span class="up">U</span><span class="down">D</span></div><span class="wire"></span><span class="overlay-t"> </span><span class="overlay-s"> </span><span class="overlay-w"> </span><span class="overlay-i"> </span><span class="overlay-color"> </span></div>');
} else if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
theHTML[theHTMLlength++] = ('<div class="gPoint"><div class="indicators"><span class="north"></span><span class="south"></span><span class="west"></span><span class="east"></span><span class="up">U</span><span class="down">D</span></div><span class="wire"></span><span class="overlay-t"> </span><span class="overlay-o"> </span><span class="overlay-b"> </span><span class="overlay-n"> </span><span class="overlay-i"> </span><span class="overlay-w"> </span><span class="overlay-color"> </span></div>');
} else {
theHTML[theHTMLlength++] = ('<div class="gPoint"><div class="indicators"><span class="north"></span><span class="south"></span><span class="west"></span><span class="east"></span><span class="up">U</span><span class="down">D</span></div><span class="wire"></span><span class="overlay-t"> </span><span class="overlay-o"> </span><span class="overlay-b"> </span><span class="overlay-v"> </span><span class="overlay-i"> </span><span class="overlay-w"> </span><span class="overlay-color"> </span></div>');
}
}
$('.mainGrid').html(theHTML.join(''));
$('.tempOutput').click(function() {
@ -88,10 +69,6 @@ led_strip.initialize = function (callback, scrollPosition) {
});
// Aux channel drop-down
if (semver.lte(FC.CONFIG.apiVersion, "1.20.0")) {
$('.auxSelect').hide();
$('.labelSelect').show();
} else {
$('.auxSelect').show();
$('.labelSelect').hide();
@ -103,16 +80,9 @@ led_strip.initialize = function (callback, scrollPosition) {
$('.auxSelect').on('change', function() {
setModeColor(AuxMode, AuxDir, $('.auxSelect').val());
});
}
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
$('.vtxOverlay').hide();
$('.landingBlinkOverlay').show();
}
else {
$('.landingBlinkOverlay').css("visibility", "hidden");
$('.vtxOverlay').show();
}
// Clear button
$('.funcClear').click(function() {
@ -603,10 +573,7 @@ led_strip.initialize = function (callback, scrollPosition) {
}
function send_led_strip_mode_colors() {
if (semver.gte(FC.CONFIG.apiVersion, "1.19.0"))
mspHelper.sendLedStripModeColors(save_to_eeprom);
else
save_to_eeprom();
}
function save_to_eeprom() {
@ -727,7 +694,6 @@ led_strip.initialize = function (callback, scrollPosition) {
// refresh mode color buttons
function setModeBackgroundColor(element) {
if (semver.gte(FC.CONFIG.apiVersion, "1.19.0")) {
element.find('[class*="mode_color"]').each(function() {
let m = 0;
let d = 0;
@ -740,7 +706,6 @@ led_strip.initialize = function (callback, scrollPosition) {
}
});
}
}
function setBackgroundColor(element) {
if (element.is('[class*="color"]')) {
@ -767,17 +732,6 @@ led_strip.initialize = function (callback, scrollPosition) {
}
function areOverlaysActive(activeFunction) {
if (semver.lt(FC.CONFIG.apiVersion, "1.20.0")) {
switch (activeFunction) {
case "function-c":
case "function-a":
case "function-f":
case "function-g":
return true;
default:
break;
}
} else {
switch (activeFunction) {
case "":
case "function-c":
@ -792,12 +746,10 @@ led_strip.initialize = function (callback, scrollPosition) {
default:
break;
}
}
return false;
}
function areBlinkersActive(activeFunction) {
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
switch (activeFunction) {
case "function-c":
case "function-a":
@ -806,7 +758,6 @@ led_strip.initialize = function (callback, scrollPosition) {
default:
break;
}
}
return false;
}
@ -818,17 +769,12 @@ led_strip.initialize = function (callback, scrollPosition) {
return false;
case "function-r":
case "function-b":
if (semver.lt(FC.CONFIG.apiVersion, "1.20.0")) {
return false;
}
break;
default:
return true;
}
}
function isVtxActive(activeFunction) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
switch (activeFunction) {
case "function-v":
case "function-c":
@ -839,30 +785,18 @@ led_strip.initialize = function (callback, scrollPosition) {
return false;
}
}
}
function setOptionalGroupsVisibility() {
const activeFunction = $('select.functionSelect').val();
$('select.functionSelect').addClass(activeFunction);
if (semver.lte(FC.CONFIG.apiVersion, "1.18.0")) {
// <= 18
// Hide GPS (Func)
// Hide RSSI (O/L), Blink (Func)
// Hide Battery, RSSI (Func), Larson (O/L), Blink (O/L), Landing (O/L)
$(".extra_functions20").hide();
$(".mode_colors").hide();
} else {
// >= 20
// Show GPS (Func)
// Hide RSSI (O/L), Blink (Func)
// Show Battery, RSSI (Func), Larson (O/L), Blink (O/L), Landing (O/L)
$(".extra_functions20").show();
$(".mode_colors").show();
}
// set color modifiers (check-boxes) visibility
$('.overlays').toggle(areOverlaysActive(activeFunction));
@ -875,29 +809,13 @@ led_strip.initialize = function (callback, scrollPosition) {
$('.vtxOverlay').toggle(isVtxActive(activeFunction));
// set directions visibility
if (semver.lt(FC.CONFIG.apiVersion, "1.20.0")) {
switch (activeFunction) {
case "function-r":
$('.indicatorOverlay').hide();
$('.directions').hide();
break;
default:
$('.indicatorOverlay').show();
$('.directions').show();
break;
}
}
$('.mode_colors').hide();
if (semver.gte(FC.CONFIG.apiVersion, "1.19.0")) {
// set mode colors visibility
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
if (activeFunction === "function-f") {
$('.mode_colors').show();
}
}
// set special colors visibility
$('.special_colors').show();
@ -937,7 +855,6 @@ led_strip.initialize = function (callback, scrollPosition) {
break;
}
}
}
function applyFunctionToSelectedLeds() {
const activeFunction = $('select.functionSelect').val();
@ -966,17 +883,6 @@ led_strip.initialize = function (callback, scrollPosition) {
}
function unselectOverlays(letter) {
if (semver.lt(FC.CONFIG.apiVersion, "1.20.0")) {
if (letter == 'b' || letter == 'r') {
unselectOverlay(letter, 'i');
}
if (letter == 'b' || letter == 'r' || letter == 'l' || letter == 'g') {
unselectOverlay(letter, 'w');
unselectOverlay(letter, 'v');
unselectOverlay(letter, 't');
unselectOverlay(letter, 's');
}
} else {
// MSP 1.20
if (letter == 'r' || letter == '') {
unselectOverlay(letter, 'o');
@ -993,7 +899,6 @@ led_strip.initialize = function (callback, scrollPosition) {
unselectOverlay(letter, 'n');
}
}
}
function unselectOverlay(func, overlay) {
$(`input.function-${overlay}`).prop('checked', false);

View file

@ -76,9 +76,7 @@ motors.initialize = async function (callback) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
await MSP.promise(MSPCodes.MSP_FILTER_CONFIG);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.8.0")) {
await MSP.promise(MSPCodes.MSP_ARMING_CONFIG);
}
load_html();
@ -1128,10 +1126,6 @@ motors.initialize = async function (callback) {
FC.PID_ADVANCED_CONFIG.motor_pwm_rate = parseInt($('input[name="unsyncedpwmfreq"]').val());
FC.PID_ADVANCED_CONFIG.digitalIdlePercent = parseFloat($('input[name="digitalIdlePercent"]').val());
if (semver.gte(FC.CONFIG.apiVersion, "1.25.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
FC.PID_ADVANCED_CONFIG.gyroUse32kHz = $('input[id="gyroUse32kHz"]').is(':checked') ? 1 : 0;
}
await MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG));
await MSP.promise(MSPCodes.MSP_SET_MIXER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MIXER_CONFIG));
await MSP.promise(MSPCodes.MSP_SET_MOTOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MOTOR_CONFIG));

View file

@ -70,7 +70,7 @@ onboard_logging.initialize = function (callback) {
*
* The best we can do on those targets is check the BLACKBOX feature bit to identify support for Blackbox instead.
*/
if ((FC.BLACKBOX.supported || FC.DATAFLASH.supported) && (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33) || FC.FEATURE_CONFIG.features.isEnabled('BLACKBOX'))) {
if ((FC.BLACKBOX.supported || FC.DATAFLASH.supported) || FC.FEATURE_CONFIG.features.isEnabled('BLACKBOX')) {
blackboxSupport = 'yes';
} else {
blackboxSupport = 'no';
@ -107,12 +107,7 @@ onboard_logging.initialize = function (callback) {
$(".tab-onboard_logging a.save-settings").click(function() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
FC.BLACKBOX.blackboxSampleRate = parseInt(loggingRatesSelect.val(), 10);
} else if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
FC.BLACKBOX.blackboxPDenom = parseInt(loggingRatesSelect.val(), 10);
} else {
const rate = loggingRatesSelect.val().split('/');
FC.BLACKBOX.blackboxRateNum = parseInt(rate[0], 10);
FC.BLACKBOX.blackboxRateDenom = parseInt(rate[1], 10);
}
FC.BLACKBOX.blackboxDevice = parseInt(deviceSelect.val(), 10);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
@ -135,7 +130,6 @@ onboard_logging.initialize = function (callback) {
}
}).change();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
if ((FC.SDCARD.supported && deviceSelect.val() == 2) || (FC.DATAFLASH.supported && deviceSelect.val() == 1)) {
$(".tab-onboard_logging")
@ -145,7 +139,6 @@ onboard_logging.initialize = function (callback) {
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'RebootMsc');
const buffer = [];
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
if (GUI.operating_system === "Linux") {
// Reboot into MSC using UTC time offset instead of user timezone
// Linux seems to expect that the FAT file system timestamps are UTC based
@ -153,13 +146,9 @@ onboard_logging.initialize = function (callback) {
} else {
buffer.push(mspHelper.REBOOT_TYPES.MSC);
}
} else {
buffer.push(mspHelper.REBOOT_TYPES.MSC);
}
MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false);
});
}
}
update_html();
@ -170,7 +159,6 @@ onboard_logging.initialize = function (callback) {
function populateDevices(deviceSelect) {
deviceSelect.empty();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
deviceSelect.append(`<option value="0">${i18n.getMessage('blackboxLoggingNone')}</option>`);
if (FC.DATAFLASH.supported) {
deviceSelect.append(`<option value="1">${i18n.getMessage('blackboxLoggingFlash')}</option>`);
@ -179,15 +167,6 @@ onboard_logging.initialize = function (callback) {
deviceSelect.append(`<option value="2">${i18n.getMessage('blackboxLoggingSdCard')}</option>`);
}
deviceSelect.append(`<option value="3">${i18n.getMessage('blackboxLoggingSerial')}</option>`);
} else {
deviceSelect.append(`<option value="0">${i18n.getMessage('blackboxLoggingSerial')}</option>`);
if (FC.DATAFLASH.ready) {
deviceSelect.append(`<option value="1">${i18n.getMessage('blackboxLoggingFlash')}</option>`);
}
if (FC.SDCARD.supported) {
deviceSelect.append(`<option value="2">${i18n.getMessage('blackboxLoggingSdCard')}</option>`);
}
}
deviceSelect.val(FC.BLACKBOX.blackboxDevice);
}
@ -205,9 +184,6 @@ onboard_logging.initialize = function (callback) {
let pidRateBase = 8000;
if (semver.gte(FC.CONFIG.apiVersion, "1.25.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41) && FC.PID_ADVANCED_CONFIG.gyroUse32kHz !== 0) {
pidRateBase = 32000;
}
pidRate = pidRateBase / FC.PID_ADVANCED_CONFIG.gyro_sync_denom / FC.PID_ADVANCED_CONFIG.pid_process_denom;
}
@ -223,7 +199,7 @@ onboard_logging.initialize = function (callback) {
loggingRatesSelect.append(`<option value="${i}">1/${2**i} (${loggingFrequency}${loggingFrequencyUnit})</option>`);
}
loggingRatesSelect.val(FC.BLACKBOX.blackboxSampleRate);
} else if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
} else {
loggingRates = [
{text: "Disabled", hz: 0, p_denom: 0},
{text: "500 Hz", hz: 500, p_denom: 16},
@ -244,36 +220,6 @@ onboard_logging.initialize = function (callback) {
loggingRatesSelect.val(FC.BLACKBOX.blackboxPDenom);
}
else {
loggingRates = [
{num: 1, denom: 1},
{num: 1, denom: 2},
{num: 1, denom: 3},
{num: 1, denom: 4},
{num: 1, denom: 5},
{num: 1, denom: 6},
{num: 1, denom: 7},
{num: 1, denom: 8},
{num: 1, denom: 16},
{num: 1, denom: 32},
];
for (let i = 0; i < loggingRates.length; i++) {
let loggingRate = Math.round(pidRate / loggingRates[i].denom);
let loggingRateUnit = " Hz";
if (loggingRate !== Infinity) {
if (gcd(loggingRate, 1000) === 1000) {
loggingRate /= 1000;
loggingRateUnit = " kHz";
}
}
loggingRatesSelect.append(`<option value="${loggingRates[i].num}/${loggingRates[i].denom}">${
loggingRate}${loggingRateUnit} (${Math.round(loggingRates[i].num / loggingRates[i].denom * 100)}%)</option>`);
}
loggingRatesSelect.val(`${FC.BLACKBOX.blackboxRateNum}/${FC.BLACKBOX.blackboxRateDenom}`);
}
}
function populateDebugModes(debugModeSelect) {
@ -448,7 +394,6 @@ onboard_logging.initialize = function (callback) {
.toggleClass("sdcard-initializing", FC.SDCARD.state === MSP.SDCARD_STATE_CARD_INIT || FC.SDCARD.state === MSP.SDCARD_STATE_FS_INIT)
.toggleClass("sdcard-ready", FC.SDCARD.state === MSP.SDCARD_STATE_READY);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
const mscIsReady = dataflashPresent || (FC.SDCARD.state === MSP.SDCARD_STATE_READY);
$(".tab-onboard_logging")
.toggleClass("msc-not-ready", !mscIsReady);
@ -458,7 +403,6 @@ onboard_logging.initialize = function (callback) {
} else {
$('a.onboardLoggingRebootMsc').removeClass('disabled');
}
}
let loggingStatus;
switch (FC.SDCARD.state) {
@ -548,11 +492,7 @@ onboard_logging.initialize = function (callback) {
function flash_save_begin() {
if (GUI.connected_to) {
if (FC.boardHasVcp()) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
self.blockSize = self.VCP_BLOCK_SIZE;
} else {
self.blockSize = self.VCP_BLOCK_SIZE_3_0;
}
} else {
self.blockSize = self.BLOCK_SIZE;
}

View file

@ -40,48 +40,34 @@ pid_tuning.initialize = function (callback) {
const PID_DEFAULT = FC.getPidDefaults();
// requesting MSP_STATUS manually because it contains FC.CONFIG.profile
MSP.promise(MSPCodes.MSP_STATUS).then(function() {
if (semver.gte(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_PID_CONTROLLER_CHANGE)) {
return MSP.promise(MSPCodes.MSP_PID_CONTROLLER);
}
}).then(function() {
return MSP.promise(MSPCodes.MSP_PIDNAMES);
}).then(function() {
return MSP.promise(MSPCodes.MSP_PID);
}).then(function() {
if (semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
return MSP.promise(MSPCodes.MSP_PID_ADVANCED);
}
}).then(function() {
return MSP.promise(MSPCodes.MSP_RC_TUNING);
}).then(function() {
return MSP.promise(MSPCodes.MSP_FILTER_CONFIG);
}).then(function() {
return MSP.promise(MSPCodes.MSP_RC_DEADBAND);
}).then(function() {
return MSP.promise(MSPCodes.MSP_MOTOR_CONFIG);
}).then(function() {
MSP.promise(MSPCodes.MSP_STATUS)
.then(() => MSP.promise(MSPCodes.MSP_PID_CONTROLLER))
.then(() => MSP.promise(MSPCodes.MSP_PIDNAMES))
.then(() => MSP.promise(MSPCodes.MSP_PID))
.then(() => MSP.promise(MSPCodes.MSP_PID_ADVANCED))
.then(() => MSP.promise(MSPCodes.MSP_RC_TUNING))
.then(() => MSP.promise(MSPCodes.MSP_FILTER_CONFIG))
.then(() => MSP.promise(MSPCodes.MSP_RC_DEADBAND))
.then(() => MSP.promise(MSPCodes.MSP_MOTOR_CONFIG))
.then(() => {
let promise;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
promise = MSP.promise(MSPCodes.MSP_SIMPLIFIED_TUNING);
}
return promise;
}).then(function() {
MSP.send_message(MSPCodes.MSP_MIXER_CONFIG, false, false, load_html);
});
})
.then(() => MSP.send_message(MSPCodes.MSP_MIXER_CONFIG, false, false, load_html));
function load_html() {
$('#content').load("./tabs/pid_tuning.html", process_html);
}
const vbatpidcompensationIsUsed = semver.gte(FC.CONFIG.apiVersion, "1.16.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44);
const vbatpidcompensationIsUsed = semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44);
function pid_and_rc_to_form() {
self.setProfile();
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
self.setRateProfile();
}
// Fill in the data from PIDs array for each pid name
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
@ -119,80 +105,47 @@ pid_tuning.initialize = function (callback) {
$('.tpa-old input[name="tpa-breakpoint"]').val(FC.RC_TUNING.dynamic_THR_breakpoint);
}
if (semver.lt(FC.CONFIG.apiVersion, "1.10.0")) {
$('.pid_tuning input[name="rc_yaw_expo"]').hide();
$('.pid_tuning input[name="rc_expo"]').attr("rowspan", "3");
}
$('.vbatpidcompensation').toggle(vbatpidcompensationIsUsed);
$('input[id="vbatpidcompensation"]').prop('checked', FC.ADVANCED_TUNING.vbatPidCompensation !== 0);
if (semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
$('#pid-tuning .delta select').val(FC.ADVANCED_TUNING.deltaMethod);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
$('.pid_tuning input[name="rc_rate_yaw"]').val(FC.RC_TUNING.rcYawRate.toFixed(2));
$('.pid_filter input[name="gyroLowpassFrequency"]').val(FC.FILTER_CONFIG.gyro_lowpass_hz);
$('.pid_filter input[name="dtermLowpassFrequency"]').val(FC.FILTER_CONFIG.dterm_lowpass_hz);
$('.pid_filter input[name="yawLowpassFrequency"]').val(FC.FILTER_CONFIG.yaw_lowpass_hz);
} else {
$('.tab-pid_tuning .subtab-filter').hide();
$('.tab-pid_tuning .tab-container').hide();
$('.pid_tuning input[name="rc_rate_yaw"]').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")
|| semver.gte(FC.CONFIG.apiVersion, "1.16.0") && FC.FEATURE_CONFIG.features.isEnabled('SUPEREXPO_RATES')) {
if (FC.FEATURE_CONFIG.features.isEnabled('SUPEREXPO_RATES')) {
$('#pid-tuning .rate').text(i18n.getMessage("pidTuningSuperRate"));
} else {
$('#pid-tuning .rate').text(i18n.getMessage("pidTuningRate"));
}
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
$('.pid_filter input[name="gyroNotch1Frequency"]').val(FC.FILTER_CONFIG.gyro_notch_hz);
$('.pid_filter input[name="gyroNotch1Cutoff"]').val(FC.FILTER_CONFIG.gyro_notch_cutoff);
$('.pid_filter input[name="dTermNotchFrequency"]').val(FC.FILTER_CONFIG.dterm_notch_hz);
$('.pid_filter input[name="dTermNotchCutoff"]').val(FC.FILTER_CONFIG.dterm_notch_cutoff);
const dtermSetpointTransitionNumberElement = $('input[name="dtermSetpointTransition-number"]');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_38)) {
dtermSetpointTransitionNumberElement.attr('min', 0.00);
} else {
dtermSetpointTransitionNumberElement.attr('min', 0.01);
}
dtermSetpointTransitionNumberElement.val(FC.ADVANCED_TUNING.dtermSetpointTransition / 100);
$('input[name="dtermSetpoint-number"]').val(FC.ADVANCED_TUNING.dtermSetpointWeight / 100);
} else {
$('.pid_filter .newFilter').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, "1.21.0")) {
$('.pid_filter input[name="gyroNotch2Frequency"]').val(FC.FILTER_CONFIG.gyro_notch2_hz);
$('.pid_filter input[name="gyroNotch2Cutoff"]').val(FC.FILTER_CONFIG.gyro_notch2_cutoff);
} else {
$('.pid_filter .gyroNotch2').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, "1.24.0")) {
$('.pid_tuning input[name="angleLimit"]').val(FC.ADVANCED_TUNING.levelAngleLimit);
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
$('.pid_tuning input[name="sensitivity"]').val(FC.ADVANCED_TUNING.levelSensitivity);
} else {
$('.pid_tuning input[name="sensitivity"]').hide();
$('.pid_tuning .levelSensitivityHeader').empty();
}
} else {
$('.pid_sensitivity').hide();
}
const antiGravitySwitch = $('#antiGravitySwitch');
const antiGravityGain = $('.antigravity input[name="itermAcceleratorGain"]');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
$('.pid_filter select[name="dtermLowpassType"]').val(FC.FILTER_CONFIG.dterm_lowpass_type);
const ITERM_ACCELERATOR_GAIN_OFF = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44) ? 0 : 1000;
@ -231,7 +184,7 @@ pid_tuning.initialize = function (callback) {
$('.antigravity .suboption').show();
$('.antigravity .antiGravityThres').toggle(semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.ADVANCED_TUNING.itermAcceleratorGain === 0);
$('.antigravity .antiGravityMode').toggle(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45));
$('.antigravity .antiGravityMode').toggle(semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45));
} else {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
antiGravityGain.val(ITERM_ACCELERATOR_GAIN_OFF / 1000);
@ -244,17 +197,10 @@ pid_tuning.initialize = function (callback) {
}
});
antiGravitySwitch.trigger("change");
} else {
$('.dtermLowpassType').hide();
$('.antigravity').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
$('.pid_tuning input[name="rc_rate_pitch"]').val(FC.RC_TUNING.rcPitchRate.toFixed(2));
$('.pid_tuning input[name="rc_pitch_expo"]').val(FC.RC_TUNING.RC_PITCH_EXPO.toFixed(2));
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
$('.pid_filter input[name="gyroLowpass2Frequency"]').val(FC.FILTER_CONFIG.gyro_lowpass2_hz);
$('.pid_filter select[name="gyroLowpassType"]').val(FC.FILTER_CONFIG.gyro_lowpass_type);
@ -267,14 +213,6 @@ pid_tuning.initialize = function (callback) {
$('.pid_filter input[name="gyroLowpassFrequency"]').val(FC.FILTER_CONFIG.gyro_lowpass_hz);
//removes 5th column which is Feedforward
$('#pid_main .pid_titlebar2 th').attr('colspan', 4);
} else {
$('.gyroLowpass2').hide();
$('.gyroLowpass2Type').hide();
$('.dtermLowpass2').hide();
$('#pid_main .pid_titlebar2 th').attr('colspan', 4);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
// I Term Rotation
$('input[id="itermrotation"]').prop('checked', FC.ADVANCED_TUNING.itermRotation !== 0);
@ -334,7 +272,7 @@ pid_tuning.initialize = function (callback) {
const feedforwardTransitionNumberElement = $('input[name="feedforwardTransition-number"]');
feedforwardTransitionNumberElement.val(Number.parseFloat(FC.ADVANCED_TUNING.feedforwardTransition / 100).toFixed(2));
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
// AntiGravity Mode
const antiGravityModeSelect = $('.antigravity select[id="antiGravityMode"]');
@ -348,23 +286,6 @@ pid_tuning.initialize = function (callback) {
antiGravityModeSelect.val(FC.ADVANCED_TUNING.antiGravityMode).trigger('change');
}
} else {
$('.itermrotation').hide();
$('.smartfeedforward').hide();
$('.itermrelax').hide();
$('.absoluteControlGain').hide();
$('.throttleBoost').hide();
$('.acroTrainerAngleLimit').hide();
$('.pid_tuning .YAW input[name="d"]').hide();
// Feedforward column
$('#pid_main tr :nth-child(6)').hide();
$('#pid-tuning .feedforwardGroup').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
$('select[id="throttleLimitType"]').val(FC.RC_TUNING.throttleLimitType);
$('.throttle_limit input[name="throttleLimitPercent"]').val(FC.RC_TUNING.throttleLimitPercent);
@ -385,20 +306,6 @@ pid_tuning.initialize = function (callback) {
$('input[id="useIntegratedYaw"]').prop('checked', FC.ADVANCED_TUNING.useIntegratedYaw !== 0);
//dmin column
$('#pid_main .pid_titlebar2 th').attr('colspan', 6);
} else {
$('.throttle_limit').hide();
$('.gyroLowpassDynLegacy').hide();
$('.dtermLowpassDynLegacy').hide();
$('.dtermLowpass2TypeGroup').hide();
$('.dminGroup').hide();
$('.dMinDisabledNote').hide();
//dmin column
$('#pid_main tr :nth-child(5)').hide();
$('.integratedYaw').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
@ -623,14 +530,10 @@ pid_tuning.initialize = function (callback) {
$('.vbatSagCompensation').hide();
$('.thrustLinearization').hide();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
$('.pid_tuning .ROLL input[name="f"]').val(FC.ADVANCED_TUNING.feedforwardRoll > 0 ? FC.ADVANCED_TUNING.feedforwardRoll : PID_DEFAULT[4]);
$('.pid_tuning .PITCH input[name="f"]').val(FC.ADVANCED_TUNING.feedforwardPitch > 0 ? FC.ADVANCED_TUNING.feedforwardPitch : PID_DEFAULT[9]);
$('.pid_tuning .YAW input[name="f"]').val(FC.ADVANCED_TUNING.feedforwardYaw > 0 ? FC.ADVANCED_TUNING.feedforwardYaw : PID_DEFAULT[14]);
$('span.feedforwardOption').hide();
} else {
$('.feedforwardGroup').hide();
}
}
$('input[id="useIntegratedYaw"]').change(function() {
@ -712,7 +615,6 @@ pid_tuning.initialize = function (callback) {
}).change();
// dMinSwitch toggle - renamed to Dynamic Damping and disabled in 4.3
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
const dMinSwitch = $('#dMinSwitch');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
@ -760,7 +662,6 @@ pid_tuning.initialize = function (callback) {
}
}).trigger('change');
}
}
$('input[id="gyroNotch1Enabled"]').change(function() {
const checked = $(this).is(':checked');
@ -1211,11 +1112,8 @@ pid_tuning.initialize = function (callback) {
FC.ADVANCED_TUNING.vbatPidCompensation = value;
}
if (semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
FC.ADVANCED_TUNING.deltaMethod = $('#pid-tuning .delta select').val();
}
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
FC.ADVANCED_TUNING.dtermSetpointTransition = parseInt($('input[name="dtermSetpointTransition-number"]').val() * 100);
FC.ADVANCED_TUNING.dtermSetpointWeight = parseInt($('input[name="dtermSetpoint-number"]').val() * 100);
@ -1223,23 +1121,13 @@ pid_tuning.initialize = function (callback) {
FC.FILTER_CONFIG.gyro_notch_cutoff = parseInt($('.pid_filter input[name="gyroNotch1Cutoff"]').val());
FC.FILTER_CONFIG.dterm_notch_hz = parseInt($('.pid_filter input[name="dTermNotchFrequency"]').val());
FC.FILTER_CONFIG.dterm_notch_cutoff = parseInt($('.pid_filter input[name="dTermNotchCutoff"]').val());
if (semver.gte(FC.CONFIG.apiVersion, "1.21.0")) {
FC.FILTER_CONFIG.gyro_notch2_hz = parseInt($('.pid_filter input[name="gyroNotch2Frequency"]').val());
FC.FILTER_CONFIG.gyro_notch2_cutoff = parseInt($('.pid_filter input[name="gyroNotch2Cutoff"]').val());
}
}
if (semver.gte(FC.CONFIG.apiVersion, "1.24.0")) {
FC.ADVANCED_TUNING.levelAngleLimit = parseInt($('.pid_tuning input[name="angleLimit"]').val());
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
FC.ADVANCED_TUNING.levelSensitivity = parseInt($('.pid_tuning input[name="sensitivity"]').val());
}
}
const antiGravityGain = $('.antigravity input[name="itermAcceleratorGain"]');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
FC.FILTER_CONFIG.dterm_lowpass_type = parseInt($('.pid_filter select[name="dtermLowpassType"]').val());
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
FC.ADVANCED_TUNING.antiGravityGain = parseInt(antiGravityGain.val() * 10);
@ -1247,17 +1135,12 @@ pid_tuning.initialize = function (callback) {
FC.ADVANCED_TUNING.itermThrottleThreshold = parseInt($('.antigravity input[name="itermThrottleThreshold"]').val());
FC.ADVANCED_TUNING.itermAcceleratorGain = parseInt(antiGravityGain.val() * 1000);
}
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
FC.FILTER_CONFIG.gyro_lowpass2_hz = parseInt($('.pid_filter input[name="gyroLowpass2Frequency"]').val());
FC.FILTER_CONFIG.gyro_lowpass_type = parseInt($('.pid_filter select[name="gyroLowpassType"]').val());
FC.FILTER_CONFIG.gyro_lowpass2_type = parseInt($('.pid_filter select[name="gyroLowpass2Type"]').val());
FC.FILTER_CONFIG.dterm_lowpass2_hz = parseInt($('.pid_filter input[name="dtermLowpass2Frequency"]').val());
FC.FILTER_CONFIG.dterm_lowpass2_type = parseInt($('.pid_filter select[name="dtermLowpass2Type"]').val());
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
FC.ADVANCED_TUNING.itermRotation = $('input[id="itermrotation"]').is(':checked') ? 1 : 0;
FC.ADVANCED_TUNING.smartFeedforward = $('input[id="smartfeedforward"]').is(':checked') ? 1 : 0;
@ -1279,9 +1162,7 @@ pid_tuning.initialize = function (callback) {
FC.ADVANCED_TUNING.feedforwardTransition = parseInt($('input[name="feedforwardTransition-number"]').val() * 100);
FC.ADVANCED_TUNING.antiGravityMode = semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45) ? $('select[id="antiGravityMode"]').val() : 0;
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
FC.RC_TUNING.throttleLimitType = $('select[id="throttleLimitType"]').val();
FC.RC_TUNING.throttleLimitPercent = parseInt($('.throttle_limit input[name="throttleLimitPercent"]').val());
@ -1306,7 +1187,7 @@ pid_tuning.initialize = function (callback) {
FC.ADVANCED_TUNING.dMinAdvance = parseInt($('.dminGroup input[name="dMinAdvance"]').val());
FC.ADVANCED_TUNING.useIntegratedYaw = $('input[id="useIntegratedYaw"]').is(':checked') ? 1 : 0;
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
FC.FILTER_CONFIG.dyn_notch_range = parseInt($('.pid_filter select[name="dynamicNotchRange"]').val());
@ -1382,12 +1263,6 @@ pid_tuning.initialize = function (callback) {
// Show titles and other elements needed by the PID
$(`.needed_by_${elementPid}`).show();
});
// Special case
if (semver.lt(FC.CONFIG.apiVersion, "1.24.0")) {
$('#pid_sensitivity').hide();
}
}
function hideUnusedPids() {
@ -1449,17 +1324,12 @@ pid_tuning.initialize = function (callback) {
return value;
}
let useLegacyCurve = false;
if (!semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
useLegacyCurve = true;
}
const useLegacyCurve = true;
self.rateCurve = new RateCurve(useLegacyCurve);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
$('.pid_tuning input[name="sensitivity"]').hide();
$('.pid_tuning .levelSensitivityHeader').empty();
}
function printMaxAngularVel(rate, rcRate, rcExpo, useSuperExpo, deadband, limit, maxAngularVelElement) {
const maxAngularVel = self.rateCurve.getMaxAngularVel(rate, rcRate, rcExpo, useSuperExpo, deadband, limit).toFixed(0);
@ -1480,13 +1350,7 @@ pid_tuning.initialize = function (callback) {
TABS.pid_tuning.isHtmlProcessing = true;
FC.FEATURE_CONFIG.features.generateElements($('.tab-pid_tuning .features'));
if (semver.lt(FC.CONFIG.apiVersion, "1.16.0") || semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
$('.tab-pid_tuning .pidTuningSuperexpoRates').hide();
}
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
$('input[name="dtermSetpoint-number"]').attr('max', self.SETPOINT_WEIGHT_RANGE_LEGACY);
}
// translate to user-selected language
i18n.localizePage();
@ -1500,7 +1364,7 @@ pid_tuning.initialize = function (callback) {
$('.tab-pid_tuning .tab-container .filter').on('click', () => activateSubtab('filter'));
function loadProfilesList() {
const numberOfProfiles = semver.gte(FC.CONFIG.apiVersion, "1.16.0") ? FC.CONFIG.numProfiles : 3;
const numberOfProfiles = FC.CONFIG.numProfiles;
const profileElements = [];
for (let i = 0; i < numberOfProfiles; i++) {
@ -1512,10 +1376,6 @@ pid_tuning.initialize = function (callback) {
function loadRateProfilesList() {
let numberOfRateProfiles = 6;
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
numberOfRateProfiles = 3;
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
numberOfRateProfiles = 4;
}
@ -1600,7 +1460,6 @@ pid_tuning.initialize = function (callback) {
});
});
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
$('.tab-pid_tuning select[name="rate_profile"]').change(function () {
self.currentRateProfile = parseInt($(this).val());
self.updating = true;
@ -1635,18 +1494,6 @@ pid_tuning.initialize = function (callback) {
checkUpdateDtermTransitionWarning($(this).val());
});
} else {
$('.tab-pid_tuning .rate_profile').hide();
$('#pid-tuning .dtermSetpointTransition').hide();
$('#pid-tuning .dtermSetpoint').hide();
}
if (!semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
$('#pid-tuning .delta').hide();
$('.tab-pid_tuning .note').hide();
}
// Add a name to each row of PIDs if empty
$('.pid_tuning tr').each(function() {
for (const pidName of FC.PID_NAMES) {
@ -1664,13 +1511,12 @@ pid_tuning.initialize = function (callback) {
const filterTypeValues = [];
filterTypeValues.push("PT1");
filterTypeValues.push("BIQUAD");
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
filterTypeValues.push("FIR");
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
filterTypeValues.push("PT2");
filterTypeValues.push("PT3");
}
return filterTypeValues;
}
@ -1728,64 +1574,11 @@ pid_tuning.initialize = function (callback) {
activateSubtab(self.activeSubtab);
const pidController_e = $('select[name="controller"]');
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
let pidControllerList;
if (semver.lt(FC.CONFIG.apiVersion, "1.14.0")) {
pidControllerList = [
{name: "MultiWii (Old)"},
{name: "MultiWii (rewrite)"},
{name: "LuxFloat"},
{name: "MultiWii (2.3 - latest)"},
{name: "MultiWii (2.3 - hybrid)"},
{name: "Harakiri"},
];
} else if (semver.lt(FC.CONFIG.apiVersion, "1.20.0")) {
pidControllerList = [
{name: ""},
{name: "Integer"},
{name: "Float"},
];
} else {
pidControllerList = [
{name: "Legacy"},
{name: "Betaflight"},
];
}
for (let i = 0; i < pidControllerList.length; i++) {
pidController_e.append(`<option value="${i}">${pidControllerList[i].name}</option>`);
}
if (semver.gte(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_PID_CONTROLLER_CHANGE)) {
pidController_e.val(FC.PID.controller);
self.updatePidControllerParameters();
} else {
GUI.log(i18n.getMessage('pidTuningUpgradeFirmwareToChangePidController', [FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_PID_CONTROLLER_CHANGE]));
pidController_e.empty();
pidController_e.append('<option value="">Unknown</option>');
pidController_e.prop('disabled', true);
}
} else {
$('.tab-pid_tuning div.controller').hide();
self.updatePidControllerParameters();
}
if (semver.lt(FC.CONFIG.apiVersion, "1.7.0")) {
$('.tpa-old .tpa-breakpoint').hide();
$('.pid_tuning .roll_rate').hide();
$('.pid_tuning .pitch_rate').hide();
} else {
$('.pid_tuning .roll_pitch_rate').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
$('.tpa-old').hide();
@ -1793,16 +1586,11 @@ pid_tuning.initialize = function (callback) {
$('.tpa').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
$('.pid_tuning .bracket').hide();
$('.pid_tuning input[name=rc_rate]').parent().attr('class', 'pid_data');
$('.pid_tuning input[name=rc_rate]').parent().attr('rowspan', 1);
$('.pid_tuning input[name=rc_expo]').parent().attr('class', 'pid_data');
$('.pid_tuning input[name=rc_expo]').parent().attr('rowspan', 1);
} else {
$('.pid_tuning input[name=rc_rate_pitch]').parent().hide();
$('.pid_tuning input[name=rc_pitch_expo]').parent().hide();
}
if (useLegacyCurve) {
$('.new_rates').hide();
@ -1839,31 +1627,12 @@ pid_tuning.initialize = function (callback) {
updateNeeded = true;
}
if (targetElement.attr('name') === 'rc_rate' && semver.lt(FC.CONFIG.apiVersion, "1.16.0")) {
self.currentRates.rc_rate_yaw = targetValue;
}
if (targetElement.attr('name') === 'roll_pitch_rate' && semver.lt(FC.CONFIG.apiVersion, "1.7.0")) {
self.currentRates.roll_rate = targetValue;
self.currentRates.pitch_rate = targetValue;
updateNeeded = true;
}
if (targetElement.attr('name') === 'SUPEREXPO_RATES') {
self.currentRates.superexpo = targetElement.is(':checked');
updateNeeded = true;
}
if (targetElement.attr('name') === 'rc_rate' && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
self.currentRates.rc_rate_pitch = targetValue;
}
if (targetElement.attr('name') === 'rc_expo' && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
self.currentRates.rc_pitch_expo = targetValue;
}
if (targetElement.attr('id') === 'ratesType' && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
self.changeRatesType(targetValue);
@ -2032,8 +1801,6 @@ pid_tuning.initialize = function (callback) {
const DIALOG_MODE_RATEPROFILE = 1;
let dialogCopyProfileMode;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
const selectProfile = $('.selectProfile');
const selectRateProfile = $('.selectRateProfile');
@ -2095,10 +1862,6 @@ pid_tuning.initialize = function (callback) {
dialogCopyProfile.close();
}
});
} else {
$('.copyprofilebtn').hide();
$('.copyrateprofilebtn').hide();
}
/*
* TuningSliders
@ -2454,37 +2217,16 @@ pid_tuning.initialize = function (callback) {
$('.tuningHelpSliders').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
$('#pid-tuning .delta select').change(function() {
self.setDirty(true);
});
}
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
pidController_e.change(function () {
self.setDirty(true);
self.updatePidControllerParameters();
});
}
// update == save.
$('a.update').click(function () {
form_to_pid_and_rc();
self.updating = true;
Promise.resolve(true)
.then(function () {
let promise;
if (semver.gte(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_PID_CONTROLLER_CHANGE) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
FC.PID.controller = pidController_e.val();
promise = MSP.promise(MSPCodes.MSP_SET_PID_CONTROLLER, mspHelper.crunch(MSPCodes.MSP_SET_PID_CONTROLLER));
} else {
console.log(`Unsupported API version: ${FC.CONFIG.apiVersion}`);
}
return promise;
})
.then(() => MSP.promise(MSPCodes.MSP_SET_PID, mspHelper.crunch(MSPCodes.MSP_SET_PID)))
MSP.promise(MSPCodes.MSP_SET_PID, mspHelper.crunch(MSPCodes.MSP_SET_PID))
.then(() => MSP.promise(MSPCodes.MSP_SET_PID_ADVANCED, mspHelper.crunch(MSPCodes.MSP_SET_PID_ADVANCED)))
.then(() => {
self.updatePIDColors();
@ -2637,9 +2379,7 @@ pid_tuning.setDirty = function (isDirty) {
self.dirty = isDirty;
$('.tab-pid_tuning select[name="profile"]').prop('disabled', isDirty);
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
$('.tab-pid_tuning select[name="rate_profile"]').prop('disabled', isDirty);
}
};
pid_tuning.checkUpdateProfile = function (updateRateProfile) {
@ -2656,9 +2396,7 @@ pid_tuning.checkUpdateProfile = function (updateRateProfile) {
}
let changedRateProfile = false;
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")
&& updateRateProfile
&& self.currentRateProfile !== FC.CONFIG.rateProfile) {
if (updateRateProfile && self.currentRateProfile !== FC.CONFIG.rateProfile) {
self.setRateProfile();
changedRateProfile = true;
@ -2711,26 +2449,10 @@ pid_tuning.checkThrottle = function() {
};
pid_tuning.updatePidControllerParameters = function () {
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_31) && $('.tab-pid_tuning select[name="controller"]').val() === '0') {
$('.pid_tuning .YAW_JUMP_PREVENTION').show();
$('#pid-tuning .delta').show();
$('#pid-tuning .dtermSetpointTransition').hide();
$('#pid-tuning .dtermSetpoint').hide();
} else {
$('.pid_tuning .YAW_JUMP_PREVENTION').hide();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
$('#pid-tuning .dtermSetpointTransition').hide();
$('#pid-tuning .dtermSetpoint').hide();
} else {
$('#pid-tuning .dtermSetpointTransition').show();
$('#pid-tuning .dtermSetpoint').show();
}
$('#pid-tuning .delta').hide();
}
};
pid_tuning.updateRatesLabels = function() {

View file

@ -20,39 +20,22 @@ ports.initialize = function (callback) {
{ name: 'BLACKBOX', groups: ['peripherals'], sharableWith: ['msp'], notSharableWith: ['telemetry'], maxPorts: 1 },
];
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
const ltmFunctionRule = {name: 'TELEMETRY_LTM', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['peripherals'], maxPorts: 1};
functionRules.push(ltmFunctionRule);
} else {
const mspFunctionRule = {name: 'TELEMETRY_MSP', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['peripherals'], maxPorts: 1};
functionRules.push(mspFunctionRule);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.18.0")) {
const mavlinkFunctionRule = {name: 'TELEMETRY_MAVLINK', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['peripherals'], maxPorts: 1};
functionRules.push(mavlinkFunctionRule);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.27.0")) {
functionRules.push({ name: 'IRC_TRAMP', groups: ['peripherals'], maxPorts: 1 });
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
functionRules.push({ name: 'ESC_SENSOR', groups: ['sensors'], maxPorts: 1 });
functionRules.push({ name: 'TBS_SMARTAUDIO', groups: ['peripherals'], maxPorts: 1 });
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_32)) {
functionRules.push({ name: 'TELEMETRY_IBUS', groups: ['telemetry'], maxPorts: 1 });
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
functionRules.push({ name: 'RUNCAM_DEVICE_CONTROL', groups: ['peripherals'], maxPorts: 1 });
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
functionRules.push({ name: 'LIDAR_TF', groups: ['peripherals'], maxPorts: 1 });
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
functionRules.push({ name: 'FRSKY_OSD', groups: ['peripherals'], maxPorts: 1 });
@ -74,12 +57,10 @@ ports.initialize = function (callback) {
'115200',
'230400',
'250000',
'500000',
'1000000',
];
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
mspBaudRates = mspBaudRates.concat(['500000', '1000000']);
}
const gpsBaudRates = [
'AUTO',
'9600',
@ -140,12 +121,6 @@ ports.initialize = function (callback) {
function update_ui() {
self.analyticsChanges = {};
if (semver.lt(FC.CONFIG.apiVersion, "1.6.0")) {
$(".tab-ports").removeClass("supported");
return;
}
$(".tab-ports").addClass("supported");
const VCP_PORT_IDENTIFIER = 20;

View file

@ -1,4 +1,3 @@
import semver from 'semver';
import { i18n } from '../localization';
const power = {
@ -54,13 +53,9 @@ power.initialize = function (callback) {
$('#content').load("./tabs/power.html", process_html);
}
this.supported = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33);
this.supported = true;
if (!this.supported) {
load_html();
} else {
load_status();
}
function updateDisplay(voltageDataSource, currentDataSource) {
// voltage meters
@ -227,18 +222,16 @@ power.initialize = function (callback) {
const elementBatteryConfiguration = templateBatteryConfiguration.clone();
destinationBatteryConfiguration.append(elementBatteryConfiguration);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
$('input[name="mincellvoltage"]').prop('step','0.01');
$('input[name="maxcellvoltage"]').prop('step','0.01');
$('input[name="warningcellvoltage"]').prop('step','0.01');
}
$('input[name="mincellvoltage"]').val(FC.BATTERY_CONFIG.vbatmincellvoltage);
$('input[name="maxcellvoltage"]').val(FC.BATTERY_CONFIG.vbatmaxcellvoltage);
$('input[name="warningcellvoltage"]').val(FC.BATTERY_CONFIG.vbatwarningcellvoltage);
$('input[name="capacity"]').val(FC.BATTERY_CONFIG.capacity);
const haveFc = (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_35) || (FC.CONFIG.boardType == 0 || FC.CONFIG.boardType == 2));
const haveFc = FC.CONFIG.boardType === 0 || FC.CONFIG.boardType === 2;
const batteryMeterTypes = [
i18n.getMessage('powerBatteryVoltageMeterTypeNone'),
@ -264,11 +257,8 @@ power.initialize = function (callback) {
if (haveFc) {
currentMeterTypes.push(i18n.getMessage('powerBatteryCurrentMeterTypeVirtual'));
currentMeterTypes.push(i18n.getMessage('powerBatteryCurrentMeterTypeEsc'));
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
currentMeterTypes.push(i18n.getMessage('powerBatteryCurrentMeterTypeMsp'));
}
}
let currentMeterType_e = $('select.currentmetersource');
@ -495,19 +485,11 @@ power.initialize = function (callback) {
}
function save_voltage_config() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
mspHelper.sendVoltageConfig(save_amperage_config);
} else {
MSP.send_message(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG), false, save_amperage_config);
}
}
function save_amperage_config() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
mspHelper.sendCurrentConfig(save_to_eeprom);
} else {
MSP.send_message(MSPCodes.MSP_SET_CURRENT_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CURRENT_METER_CONFIG), false, save_to_eeprom);
}
}
function save_to_eeprom() {

View file

@ -58,21 +58,11 @@ receiver.initialize = function (callback) {
}
function load_rc_configs() {
const nextCallback = load_rx_config;
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
MSP.send_message(MSPCodes.MSP_RC_DEADBAND, false, false, nextCallback);
} else {
nextCallback();
}
MSP.send_message(MSPCodes.MSP_RC_DEADBAND, false, false, load_rx_config);
}
function load_rx_config() {
const nextCallback = load_mixer_config;
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, nextCallback);
} else {
nextCallback();
}
MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, load_mixer_config);
}
function load_mixer_config() {
@ -95,32 +85,20 @@ receiver.initialize = function (callback) {
// translate to user-selected language
i18n.localizePage();
if (semver.lt(FC.CONFIG.apiVersion, "1.15.0")) {
$('.deadband').hide();
} else {
$('.deadband input[name="yaw_deadband"]').val(FC.RC_DEADBAND_CONFIG.yaw_deadband);
$('.deadband input[name="deadband"]').val(FC.RC_DEADBAND_CONFIG.deadband);
$('.deadband input[name="3ddeadbandthrottle"]').val(FC.RC_DEADBAND_CONFIG.deadband3d_throttle);
}
if (semver.lt(FC.CONFIG.apiVersion, "1.15.0")) {
$('.sticks').hide();
} else {
$('.sticks input[name="stick_min"]').val(FC.RX_CONFIG.stick_min);
$('.sticks input[name="stick_center"]').val(FC.RX_CONFIG.stick_center);
$('.sticks input[name="stick_max"]').val(FC.RX_CONFIG.stick_max);
}
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
$('select[name="rcInterpolation-select"]').val(FC.RX_CONFIG.rcInterpolation);
$('input[name="rcInterpolationInterval-number"]').val(FC.RX_CONFIG.rcInterpolationInterval);
$('select[name="rcInterpolation-select"]').change(function () {
tab.updateRcInterpolationParameters();
}).change();
} else {
$('.tab-receiver div.rcInterpolation').hide();
}
// generate bars
const bar_names = [
@ -289,7 +267,6 @@ receiver.initialize = function (callback) {
});
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
const spiRxTypes = [
'NRF24_V202_250K',
'NRF24_V202_1M',
@ -300,24 +277,14 @@ receiver.initialize = function (callback) {
'NRF24_H8_3D',
'NRF24_INAV',
'FRSKY_D',
];
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
spiRxTypes.push(
'FRSKY_X',
'A7105_FLYSKY',
'A7105_FLYSKY_2A',
'NRF24_KN',
);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
spiRxTypes.push(
'SFHSS',
'SPEKTRUM',
'FRSKY_X_LBT',
);
}
];
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
spiRxTypes.push(
@ -391,7 +358,6 @@ receiver.initialize = function (callback) {
} else {
tab.elrsPassphraseEnabled = false;
}
}
// UI Hooks
@ -465,14 +431,12 @@ receiver.initialize = function (callback) {
function saveConfiguration(boot=false) {
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
FC.RX_CONFIG.stick_max = parseInt($('.sticks input[name="stick_max"]').val());
FC.RX_CONFIG.stick_center = parseInt($('.sticks input[name="stick_center"]').val());
FC.RX_CONFIG.stick_min = parseInt($('.sticks input[name="stick_min"]').val());
FC.RC_DEADBAND_CONFIG.yaw_deadband = parseInt($('.deadband input[name="yaw_deadband"]').val());
FC.RC_DEADBAND_CONFIG.deadband = parseInt($('.deadband input[name="deadband"]').val());
FC.RC_DEADBAND_CONFIG.deadband3d_throttle = ($('.deadband input[name="3ddeadbandthrottle"]').val());
}
// catch rc map
rcMapLetters = ['A', 'E', 'R', 'T', '1', '2', '3', '4'];
@ -485,19 +449,14 @@ receiver.initialize = function (callback) {
// catch rssi aux
FC.RSSI_CONFIG.channel = parseInt($('select[name="rssi_channel"]').val());
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
FC.RX_CONFIG.rcInterpolation = parseInt($('select[name="rcInterpolation-select"]').val());
FC.RX_CONFIG.rcInterpolationInterval = parseInt($('input[name="rcInterpolationInterval-number"]').val());
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
FC.RX_CONFIG.rcSmoothingSetpointCutoff = parseInt($('input[name="rcSmoothingSetpointHz-number"]').val());
FC.RX_CONFIG.rcSmoothingFeedforwardCutoff = parseInt($('input[name="rcSmoothingFeedforwardCutoff-number"]').val());
FC.RX_CONFIG.rcSmoothingDerivativeType = parseInt($('select[name="rcSmoothingFeedforwardType-select"]').val());
FC.RX_CONFIG.rcInterpolationChannels = parseInt($('select[name="rcSmoothingChannels-select"]').val());
FC.RX_CONFIG.rcSmoothingInputType = parseInt($('select[name="rcSmoothingSetpointType-select"]').val());
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
FC.RX_CONFIG.rcSmoothingAutoFactor = parseInt($('input[name="rcSmoothingAutoFactor-number"]').val());
@ -521,21 +480,12 @@ receiver.initialize = function (callback) {
}
function save_rc_configs() {
const nextCallback = save_rx_config;
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
MSP.send_message(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND), false, nextCallback);
} else {
nextCallback();
}
MSP.send_message(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND), false, save_rx_config);
}
function save_rx_config() {
const nextCallback = (boot) ? save_feature_config : save_to_eeprom;
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, nextCallback);
} else {
nextCallback();
}
}
function save_feature_config() {
@ -613,10 +563,8 @@ receiver.initialize = function (callback) {
$(".bind_btn").toggle(showBindButton);
// RC Smoothing
const smoothingOnOff = ((semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) ?
FC.RX_CONFIG.rcSmoothingMode : FC.RX_CONFIG.rcSmoothingType);
const smoothingOnOff = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44) ? FC.RX_CONFIG.rcSmoothingMode : FC.RX_CONFIG.rcSmoothingType;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
$('.tab-receiver .rcSmoothing').show();
const rc_smoothing_protocol_e = $('select[name="rcSmoothing-select"]');
@ -700,17 +648,6 @@ receiver.initialize = function (callback) {
}
updateInterpolationView();
} else {
$('.tab-receiver .rcInterpolation').show();
$('.tab-receiver .rcSmoothing-feedforward-cutoff').hide();
$('.tab-receiver .rcSmoothing-setpoint-cutoff').hide();
$('.tab-receiver .rcSmoothing-feedforward-type').hide();
$('.tab-receiver .rcSmoothing-setpoint-type').hide();
$('.tab-receiver .rcSmoothing-feedforward-manual').hide();
$('.tab-receiver .rcSmoothing-setpoint-manual').hide();
$('.tab-receiver .rc-smoothing-type').hide();
$('.tab-receiver .rcSmoothing-auto-factor').hide();
}
// Only show the MSP control sticks if the MSP Rx feature is enabled
$(".sticks_btn").toggle(FC.FEATURE_CONFIG.features.isEnabled('RX_MSP'));
@ -888,15 +825,7 @@ receiver.initModelPreview = function () {
this.keepRendering = true;
this.model = new Model($('.model_preview'), $('.model_preview canvas'));
let useOldRateCurve = false;
const cleanFlight = FC.CONFIG.flightControllerIdentifier === 'CLFL' && semver.lt(FC.CONFIG.apiVersion, '2.0.0');
const betaFlight = FC.CONFIG.flightControllerIdentifier === 'BTFL' && semver.lt(FC.CONFIG.flightControllerVersion, '2.8.0');
if (cleanFlight || betaFlight) {
useOldRateCurve = true;
}
this.rateCurve = new RateCurve(useOldRateCurve);
this.rateCurve = new RateCurve(false);
this.currentRates = this.rateCurve.getCurrentRates();
$(window).on('resize', $.bind(this.model.resize, this.model));
@ -946,13 +875,11 @@ receiver.refresh = function (callback) {
};
receiver.updateRcInterpolationParameters = function () {
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
if ($('select[name="rcInterpolation-select"]').val() === '3') {
$('.tab-receiver .rc-interpolation-manual').show();
} else {
$('.tab-receiver .rc-interpolation-manual').hide();
}
}
};
function updateInterpolationView() {

View file

@ -193,7 +193,7 @@ sensors.initialize = function (callback) {
if (!have_sensor(FC.CONFIG.activeSensors, 'mag')) {
checkboxes.eq(2).prop('disabled', true);
}
if (!(have_sensor(FC.CONFIG.activeSensors, 'baro') || (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40) && have_sensor(FC.CONFIG.activeSensors, 'gps')))) {
if (!(have_sensor(FC.CONFIG.activeSensors, 'baro') || have_sensor(FC.CONFIG.activeSensors, 'gps'))) {
checkboxes.eq(3).prop('disabled', true);
}
if (!have_sensor(FC.CONFIG.activeSensors, 'sonar')) {
@ -241,11 +241,6 @@ sensors.initialize = function (callback) {
ConfigStorage.set({'graphs_enabled': _checkboxes});
});
let altitudeHint_e = $('.tab-sensors #sensorsAltitudeHint');
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
altitudeHint_e.hide();
}
// Always start with default/empty sensor data array, clean slate all
initSensorData();

View file

@ -30,7 +30,7 @@ servos.initialize = function (callback) {
function update_ui() {
if (semver.lt(FC.CONFIG.apiVersion, "1.12.0") || FC.SERVO_CONFIG.length === 0) {
if (FC.SERVO_CONFIG.length === 0) {
$(".tab-servos").removeClass("supported");
return;

View file

@ -29,34 +29,6 @@ setup.initialize = function (callback) {
// translate to user-selected language
i18n.localizePage();
const backupButton = $('#content .backup');
const restoreButton = $('#content .restore');
backupButton.on('click', () => configuration_backup(() => GUI.log(i18n.getMessage('initialSetupBackupSuccess'))));
restoreButton.on('click', () => configuration_restore(() => {
// get latest settings
TABS.setup.initialize();
GUI.log(i18n.getMessage('initialSetupRestoreSuccess'));
}));
if (semver.lt(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE)) {
backupButton.addClass('disabled');
restoreButton.addClass('disabled');
GUI.log(i18n.getMessage('initialSetupBackupAndRestoreApiVersion', [FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE]));
}
if (CONFIGURATOR.virtualMode) {
// saving and uploading an imaginary config to hardware is a bad idea
backupButton.addClass('disabled');
} else if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
restoreButton.addClass('disabled');
$('.backupRestore').hide();
}
// initialize 3D Model
self.initModel();
@ -82,7 +54,6 @@ setup.initialize = function (callback) {
$('#arming-disable-flag').attr('title', i18n.getMessage('initialSetupArmingDisableFlagsTooltip'));
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
if (isExpertModeEnabled()) {
$('.initialSetupRebootBootloader').show();
} else {
@ -94,9 +65,6 @@ setup.initialize = function (callback) {
buffer.push(FC.boardHasFlashBootloader() ? mspHelper.REBOOT_TYPES.BOOTLOADER_FLASH : mspHelper.REBOOT_TYPES.BOOTLOADER);
MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false);
});
} else {
$('.initialSetupRebootBootloader').hide();
}
// UI Hooks
$('a.calibrateAccel').click(function () {
@ -192,9 +160,7 @@ setup.initialize = function (callback) {
pitch_e = $('dd.pitch'),
heading_e = $('dd.heading');
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
arming_disable_flags_e.hide();
}
// DISARM FLAGS
// We add all the arming/disarming flags available, and show/hide them if needed.
@ -219,25 +185,20 @@ setup.initialize = function (callback) {
'MSP',
];
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_38)) {
disarmFlagElements.splice(disarmFlagElements.indexOf('THROTTLE'), 0, 'RUNAWAY_TAKEOFF');
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
disarmFlagElements = disarmFlagElements.concat(['PARALYZE',
'GPS']);
}
disarmFlagElements = disarmFlagElements.concat(['PARALYZE', 'GPS']);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
disarmFlagElements.splice(disarmFlagElements.indexOf('OSD_MENU'), 1);
disarmFlagElements = disarmFlagElements.concat(['RESC']);
disarmFlagElements = disarmFlagElements.concat(['RPMFILTER']);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
disarmFlagElements.splice(disarmFlagElements.indexOf('THROTTLE'), 0, 'CRASH');
disarmFlagElements = disarmFlagElements.concat(['REBOOT_REQD',
'DSHOT_BBANG']);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
disarmFlagElements = disarmFlagElements.concat(['NO_ACC_CAL', 'MOTOR_PROTO']);
}

View file

@ -108,14 +108,13 @@ transponder.initialize = function(callback) {
};
/////////////////////////////////////////////
if ( GUI.active_tab != 'transponder' ) {
GUI.active_tab = 'transponder';
// Disabled on merge into betaflight-configurator
//googleAnalytics.sendAppView('Transponder');
}
// transponder supported added in MSP API Version 1.16.0
if ( FC.CONFIG ) {
TABS.transponder.available = semver.gte(FC.CONFIG.apiVersion, "1.16.0");
if (FC.CONFIG) {
TABS.transponder.available = true;
}
//////////////
if ( !TABS.transponder.available ) {

View file

@ -102,7 +102,6 @@
<script type="text/javascript" src="./js/msp/MSPConnector.js"></script>
<script type="text/javascript" src="./js/msp.js"></script>
<script type="text/javascript" src="./js/msp/MSPHelper.js"></script>
<script type="text/javascript" src="./js/backup_restore.js"></script>
<script type="text/javascript" src="./js/peripherals.js"></script>
<script type="text/javascript" src="./js/protocols/stm32.js"></script>
<script type="text/javascript" src="./js/protocols/stm32usbdfu.js"></script>

View file

@ -49,6 +49,9 @@
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="300">300</option>
<option value="400">400</option>
<option value="500">500</option>
<option value="1000">1000</option>
<option value="2000" selected="selected">2000</option>

View file

@ -152,22 +152,6 @@
</div>
<span id="attitude"></span> <span id="heading"></span>
</div>
<div class="gui_box grey backupRestore">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="initialSetupBackupRestoreHeader"></div>
</div>
<div class="spacer_box">
<div class="default_btn">
<a class="backup" href="#" i18n="initialSetupButtonBackup"></a>
</div>
<div class="default_btn">
<a class="restore" href="#" i18n="initialSetupButtonRestore"></a>
</div>
<div class="cell_setup">
<span i18n="initialSetupBackupRestoreText"></span>
</div>
</div>
</div>
</div>
</div>
</div>