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>
10.9-maintenance
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,22 +24,12 @@ class Beepers {
{ bit: 16, name: 'SYSTEM_INIT', visible: true },
{ bit: 17, name: 'USB', visible: true },
{ bit: 18, name: 'BLACKBOX_ERASE', visible: true },
{ bit: 19, name: 'CRASH_FLIP', visible: true },
{ bit: 20, name: 'CAM_CONNECTION_OPEN', visible: true },
{ bit: 21, name: 'CAM_CONNECTION_CLOSE', visible: true },
{ bit: 22, name: 'RC_SMOOTHING_INIT_FAIL', 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 = [];
beepers.forEach(function (beeper) {

View File

@ -532,34 +532,25 @@ 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,
search: function(term, callback) {
sendOnEnter = true;
searcher(term, callback, ['all'], 1, true);
},
template: highlighterPrefix,
}),
]);
}
$textarea.textcomplete('register', [
strategy({ // "resource show all", from BF 4.0.0 onwards
match: /^(\s*resource\s+show\s+)(\w*)$/i,
search: function(term, callback) {
sendOnEnter = true;
searcher(term, callback, ['all'], 1, true);
},
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");
}
}
// above 3.4.0
diffArgs2.push("defaults");
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,94 +14,29 @@ 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},
{bit: 18, group: 'other', name: 'OSD'},
{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'},
{bit: 28, group: 'antiGravity', name: 'ANTI_GRAVITY', haveTip: true, hideName: true},
];
if (!semver.gte(config.apiVersion, API_VERSION_1_33)) {
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: 19, group: 'other', name: 'BLACKBOX', haveTip: true},
{bit: 29, group: 'other', name: 'DYNAMIC_FILTER'},
);
}
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: 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;
}
expoPower = 3;
rcRateConstant = 200;
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;
}
currentRates.superexpo = true;
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,44 +821,44 @@ 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;
versionFilterDefaults.gyro_lowpass2_type = this.FILTER_TYPE_FLAGS.BIQUAD;
versionFilterDefaults.gyro_lowpass_hz = 150;
versionFilterDefaults.gyro_lowpass_type = this.FILTER_TYPE_FLAGS.BIQUAD;
versionFilterDefaults.gyro_lowpass2_hz = 0;
versionFilterDefaults.gyro_lowpass2_type = this.FILTER_TYPE_FLAGS.BIQUAD;
versionFilterDefaults.dterm_lowpass_hz = 150;
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;
versionFilterDefaults.gyro_lowpass_dyn_max_hz = 500;
versionFilterDefaults.gyro_lowpass_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.gyro_lowpass2_hz = 250;
versionFilterDefaults.gyro_lowpass2_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.dterm_lowpass_hz = 150;
versionFilterDefaults.dterm_lowpass_type = this.FILTER_TYPE_FLAGS.BIQUAD;
versionFilterDefaults.dterm_lowpass_dyn_min_hz = 70;
versionFilterDefaults.dterm_lowpass_dyn_max_hz = 170;
versionFilterDefaults.dterm_lowpass_type = this.FILTER_TYPE_FLAGS.PT1;
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;
versionFilterDefaults.gyro_lowpass_dyn_max_hz = 500;
versionFilterDefaults.gyro_lowpass_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.gyro_lowpass2_hz = 250;
versionFilterDefaults.gyro_lowpass2_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.dterm_lowpass_hz = 150;
versionFilterDefaults.dterm_lowpass_dyn_min_hz = 70;
versionFilterDefaults.dterm_lowpass_dyn_max_hz = 170;
versionFilterDefaults.dterm_lowpass_type = this.FILTER_TYPE_FLAGS.PT1;
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;
versionFilterDefaults.gyro_lowpass_dyn_min_hz = 250;
versionFilterDefaults.gyro_lowpass2_hz = 500;
versionFilterDefaults.dterm_lowpass_hz = 75;
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;
}
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;
versionFilterDefaults.gyro_lowpass_dyn_min_hz = 250;
versionFilterDefaults.gyro_lowpass2_hz = 500;
versionFilterDefaults.dterm_lowpass_hz = 75;
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();
}
$('#tabs ul.mode-connected li.tab_power').show();
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();
}
processCraftName();
});
}
@ -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();
}
MSP.send_message(MSPCodes.MSP_SET_RTC, mspHelper.crunch(MSPCodes.MSP_SET_RTC), false, 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 bit_check(sensors_detected, 5);
}
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);
}
return MSP.promise(MSPCodes.MSP_STATUS_EX);
}
async function update_live_status() {

View File

@ -289,38 +289,24 @@ 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']");
const element22 = selectFunction.find("option[value='22']");
const element23 = selectFunction.find("option[value='23']");
// Change the "text"
element22.text(i18n.getMessage('adjustmentsFunction22_2'));
element23.text(i18n.getMessage('adjustmentsFunction23_2'));
// Change the "text"
element22.text(i18n.getMessage('adjustmentsFunction22_2'));
element23.text(i18n.getMessage('adjustmentsFunction23_2'));
// 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']"));
}
// 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);
}
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,13 +444,11 @@ 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);
if ((FC.CONFIG.armingDisableFlags & armSwitchMask) > 0) {
armSwitchActive = true;
}
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);
if ((FC.CONFIG.armingDisableFlags & armSwitchMask) > 0) {
armSwitchActive = true;
}
}

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();
for (let i = 1; i <= 5; i++) {
dshotBeeperBeaconTone.append(`<option value="${(i)}">${(i)}</option>`);
}
dshotBeeper_e.show();
dshotBeeperBeaconTone.change(function() {
FC.BEEPER_CONFIG.dshotBeaconTone = dshotBeeperBeaconTone.val();
@ -80,41 +73,19 @@ 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);
dshotBeaconSwitch_e.hide();
FC.BEEPER_CONFIG.dshotBeaconConditions.generateElements(template, dshotBeaconCondition_e);
$('input.condition', dshotBeaconCondition_e).change(function () {
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();
}
$('input.condition', dshotBeaconCondition_e).change(function () {
const element = $(this);
FC.BEEPER_CONFIG.dshotBeaconConditions.updateData(element);
});
// 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();
}
FC.BEEPER_CONFIG.beepers.generateElements(template, destination);
// translate to user-selected language
i18n.localizePage();
@ -147,125 +118,117 @@ 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>`);
orientation_mag_e.append(`<option value="${(i+1)}">${alignments[i]}</option>`);
}
orientation_gyro_e.val(FC.SENSOR_ALIGNMENT.align_gyro);
orientation_acc_e.val(FC.SENSOR_ALIGNMENT.align_acc);
orientation_mag_e.val(FC.SENSOR_ALIGNMENT.align_mag);
orientation_gyro_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.align_gyro) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['GyroAlignment'] = newValue;
FC.SENSOR_ALIGNMENT.align_gyro = value;
});
orientation_acc_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.align_acc) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['AccAlignment'] = newValue;
FC.SENSOR_ALIGNMENT.align_acc = value;
});
orientation_mag_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.align_mag) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['MagAlignment'] = newValue;
FC.SENSOR_ALIGNMENT.align_mag = value;
});
// Multi gyro config
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
gyro_align_content_e.show();
legacy_gyro_alignment_e.hide();
legacy_accel_alignment_e.hide();
const GYRO_DETECTION_FLAGS = {
DETECTED_GYRO_1: (1 << 0),
DETECTED_GYRO_2: (1 << 1),
DETECTED_DUAL_GYROS: (1 << 7),
};
const detected_gyro_1 = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_1) != 0;
const detected_gyro_2 = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_2) != 0;
const detected_dual_gyros = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_DUAL_GYROS) != 0;
if (detected_gyro_1) {
orientation_gyro_to_use_e.append(`<option value="0">${i18n.getMessage('configurationSensorGyroToUseFirst')}</option>`);
}
if (detected_gyro_2) {
orientation_gyro_to_use_e.append(`<option value="1">${i18n.getMessage('configurationSensorGyroToUseSecond')}</option>`);
}
if (detected_dual_gyros) {
orientation_gyro_to_use_e.append(`<option value="2">${i18n.getMessage('configurationSensorGyroToUseBoth')}</option>`);
}
for (let i = 0; i < alignments.length; i++) {
orientation_gyro_1_align_e.append(`<option value="${(i+1)}">${alignments[i]}</option>`);
orientation_gyro_2_align_e.append(`<option value="${(i+1)}">${alignments[i]}</option>`);
}
orientation_gyro_to_use_e.val(FC.SENSOR_ALIGNMENT.gyro_to_use);
orientation_gyro_1_align_e.val(FC.SENSOR_ALIGNMENT.gyro_1_align);
orientation_gyro_2_align_e.val(FC.SENSOR_ALIGNMENT.gyro_2_align);
$('.gyro_alignment_inputs_first').toggle(detected_gyro_1);
$('.gyro_alignment_inputs_second').toggle(detected_gyro_2);
$('.gyro_alignment_inputs_selection').toggle(detected_gyro_1 || detected_gyro_2);
$('.gyro_alignment_inputs_notfound').toggle(!detected_gyro_1 && !detected_gyro_2);
orientation_gyro_1_align_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.gyro_1_align) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['Gyro1Alignment'] = newValue;
FC.SENSOR_ALIGNMENT.gyro_1_align = value;
});
orientation_gyro_2_align_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.gyro_2_align) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['Gyro2Alignment'] = newValue;
FC.SENSOR_ALIGNMENT.gyro_2_align = value;
});
}
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>`);
orientation_mag_e.append(`<option value="${(i+1)}">${alignments[i]}</option>`);
}
orientation_gyro_e.val(FC.SENSOR_ALIGNMENT.align_gyro);
orientation_acc_e.val(FC.SENSOR_ALIGNMENT.align_acc);
orientation_mag_e.val(FC.SENSOR_ALIGNMENT.align_mag);
orientation_gyro_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.align_gyro) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['GyroAlignment'] = newValue;
FC.SENSOR_ALIGNMENT.align_gyro = value;
});
orientation_acc_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.align_acc) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['AccAlignment'] = newValue;
FC.SENSOR_ALIGNMENT.align_acc = value;
});
orientation_mag_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.align_mag) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['MagAlignment'] = newValue;
FC.SENSOR_ALIGNMENT.align_mag = value;
});
// Multi gyro config
gyro_align_content_e.show();
legacy_gyro_alignment_e.hide();
legacy_accel_alignment_e.hide();
const GYRO_DETECTION_FLAGS = {
DETECTED_GYRO_1: (1 << 0),
DETECTED_GYRO_2: (1 << 1),
DETECTED_DUAL_GYROS: (1 << 7),
};
const detected_gyro_1 = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_1) != 0;
const detected_gyro_2 = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_2) != 0;
const detected_dual_gyros = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_DUAL_GYROS) != 0;
if (detected_gyro_1) {
orientation_gyro_to_use_e.append(`<option value="0">${i18n.getMessage('configurationSensorGyroToUseFirst')}</option>`);
}
if (detected_gyro_2) {
orientation_gyro_to_use_e.append(`<option value="1">${i18n.getMessage('configurationSensorGyroToUseSecond')}</option>`);
}
if (detected_dual_gyros) {
orientation_gyro_to_use_e.append(`<option value="2">${i18n.getMessage('configurationSensorGyroToUseBoth')}</option>`);
}
for (let i = 0; i < alignments.length; i++) {
orientation_gyro_1_align_e.append(`<option value="${(i+1)}">${alignments[i]}</option>`);
orientation_gyro_2_align_e.append(`<option value="${(i+1)}">${alignments[i]}</option>`);
}
orientation_gyro_to_use_e.val(FC.SENSOR_ALIGNMENT.gyro_to_use);
orientation_gyro_1_align_e.val(FC.SENSOR_ALIGNMENT.gyro_1_align);
orientation_gyro_2_align_e.val(FC.SENSOR_ALIGNMENT.gyro_2_align);
$('.gyro_alignment_inputs_first').toggle(detected_gyro_1);
$('.gyro_alignment_inputs_second').toggle(detected_gyro_2);
$('.gyro_alignment_inputs_selection').toggle(detected_gyro_1 || detected_gyro_2);
$('.gyro_alignment_inputs_notfound').toggle(!detected_gyro_1 && !detected_gyro_2);
orientation_gyro_1_align_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.gyro_1_align) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['Gyro1Alignment'] = newValue;
FC.SENSOR_ALIGNMENT.gyro_1_align = value;
});
orientation_gyro_2_align_e.change(function () {
let value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.SENSOR_ALIGNMENT.gyro_2_align) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['Gyro2Alignment'] = newValue;
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,24 +274,12 @@ 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);
$('div.gyroUse32kHz').hide();
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)) {
updateGyroDenomReadOnly(FC.CONFIG.sampleRateHz);
} else {
updateGyroDenom(8);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
updateGyroDenomReadOnly(FC.CONFIG.sampleRateHz);
} 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();
}
$('input[name="fpvCamAngleDegrees"]').val(FC.RX_CONFIG.fpvCamAngleDegrees);
$('input[name="fpvCamAngleDegrees"]').attr("max", 90);
// 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();
}
gpsAutoBaudGroup.show();
gpsAutoConfigGroup.show();
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();
}
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)) {
$('input[id="configurationSmallAngle"]').val(FC.ARMING_CONFIG.small_angle);
}
$('._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);
}
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());
}
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.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.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,37 +133,21 @@ 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>\
fullChannels_e.append(`\
<div class="number">\
<div class="channelprimary">\
<span>${channelNames[i]}</span>\
</div>\
`);
} else {
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>\
<option value="2">Set</option>\
</select>\
</div>\
<div class="auxiliary"><input type="number" name="aux_value" min="750" max="2250" step="25" id="${i}"/></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>\
<option value="2">Set</option>\
</select>\
</div>\
`);
}
<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'));
}
$('tbody.rxFailsafe').hide();
toggleStage2(true);
$('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,66 +248,45 @@ 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();
}
// `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();
// 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);
$('input[name="gps_rescue_descent_distance"]').val(FC.GPS_RESCUE.descentDistanceM);
$('input[name="gps_rescue_ground_speed"]').val((FC.GPS_RESCUE.rescueGroundspeed / 100).toFixed(2));
$('input[name="gps_rescue_throttle_min"]').val(FC.GPS_RESCUE.throttleMin);
$('input[name="gps_rescue_throttle_max"]').val(FC.GPS_RESCUE.throttleMax);
$('input[name="gps_rescue_throttle_hover"]').val(FC.GPS_RESCUE.throttleHover);
$('input[name="gps_rescue_min_sats"]').val(FC.GPS_RESCUE.minSats);
$('select[name="gps_rescue_sanity_checks"]').val(FC.GPS_RESCUE.sanityChecks);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
$('input[name="gps_rescue_ascend_rate"]').val((FC.GPS_RESCUE.ascendRate / 100).toFixed(2));
$('input[name="gps_rescue_descend_rate"]').val((FC.GPS_RESCUE.descendRate / 100).toFixed(2));
$('input[name="gps_rescue_allow_arming_without_fix"]').prop('checked', FC.GPS_RESCUE.allowArmingWithoutFix > 0);
$('select[name="gps_rescue_altitude_mode"]').val(FC.GPS_RESCUE.altitudeMode);
} else {
$('input[name="gps_rescue_ascend_rate"]').closest('.number').hide();
$('input[name="gps_rescue_descend_rate"]').closest('.number').hide();
$('input[name="gps_rescue_allow_arming_without_fix"]').closest('.number').hide();
$('select[name="gps_rescue_altitude_mode"]').closest('.number').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
$('input[name="gps_rescue_min_dth"]').val(FC.GPS_RESCUE.minRescueDth);
} else {
$('input[name="gps_rescue_min_dth"]').closest('.number').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
$('input[name="gps_rescue_min_dth"]').attr("min", 20);
}
} else {
// GPS Rescue Parameters not available
$('.pro4 > .proceduresettings').hide();
}
// 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);
$('input[name="gps_rescue_descent_distance"]').val(FC.GPS_RESCUE.descentDistanceM);
$('input[name="gps_rescue_ground_speed"]').val((FC.GPS_RESCUE.rescueGroundspeed / 100).toFixed(2));
$('input[name="gps_rescue_throttle_min"]').val(FC.GPS_RESCUE.throttleMin);
$('input[name="gps_rescue_throttle_max"]').val(FC.GPS_RESCUE.throttleMax);
$('input[name="gps_rescue_throttle_hover"]').val(FC.GPS_RESCUE.throttleHover);
$('input[name="gps_rescue_min_sats"]').val(FC.GPS_RESCUE.minSats);
$('select[name="gps_rescue_sanity_checks"]').val(FC.GPS_RESCUE.sanityChecks);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
$('input[name="gps_rescue_ascend_rate"]').val((FC.GPS_RESCUE.ascendRate / 100).toFixed(2));
$('input[name="gps_rescue_descend_rate"]').val((FC.GPS_RESCUE.descendRate / 100).toFixed(2));
$('input[name="gps_rescue_allow_arming_without_fix"]').prop('checked', FC.GPS_RESCUE.allowArmingWithoutFix > 0);
$('select[name="gps_rescue_altitude_mode"]').val(FC.GPS_RESCUE.altitudeMode);
} else {
// GPS Rescue option not available
$('.pro4').hide();
$('input[name="gps_rescue_ascend_rate"]').closest('.number').hide();
$('input[name="gps_rescue_descend_rate"]').closest('.number').hide();
$('input[name="gps_rescue_allow_arming_without_fix"]').closest('.number').hide();
$('select[name="gps_rescue_altitude_mode"]').closest('.number').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
$('input[name="gps_rescue_min_dth"]').val(FC.GPS_RESCUE.minRescueDth);
} else {
$('input[name="gps_rescue_min_dth"]').closest('.number').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
$('input[name="gps_rescue_min_dth"]').attr("min", 20);
}
$('a.save').click(function () {
// gather data that doesn't have automatic change event bound
@ -355,25 +309,18 @@ 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;
}
FC.FAILSAFE_CONFIG.failsafe_switch_mode = $('select[name="failsafe_switch_mode"]').val();
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();
FC.GPS_RESCUE.descentDistanceM = $('input[name="gps_rescue_descent_distance"]').val();
FC.GPS_RESCUE.rescueGroundspeed = $('input[name="gps_rescue_ground_speed"]').val() * 100;
FC.GPS_RESCUE.throttleMin = $('input[name="gps_rescue_throttle_min"]').val();
FC.GPS_RESCUE.throttleMax = $('input[name="gps_rescue_throttle_max"]').val();
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();
}
// 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();
FC.GPS_RESCUE.descentDistanceM = $('input[name="gps_rescue_descent_distance"]').val();
FC.GPS_RESCUE.rescueGroundspeed = $('input[name="gps_rescue_ground_speed"]').val() * 100;
FC.GPS_RESCUE.throttleMin = $('input[name="gps_rescue_throttle_min"]').val();
FC.GPS_RESCUE.throttleMax = $('input[name="gps_rescue_throttle_max"]').val();
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.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'];
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();
MSP.send_message(MSPCodes.MSP_LED_STRIP_MODECOLOR, false, false, load_html);
}
@ -73,13 +60,7 @@ 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>');
}
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(''));
@ -88,31 +69,20 @@ 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();
$('.auxSelect').show();
$('.labelSelect').hide();
const AuxMode = 7;
const AuxDir = 0;
const AuxMode = 7;
const AuxDir = 0;
$('.auxSelect').val(getModeColor(AuxMode, AuxDir));
$('.auxSelect').val(getModeColor(AuxMode, AuxDir));
$('.auxSelect').on('change', function() {
setModeColor(AuxMode, AuxDir, $('.auxSelect').val());
});
}
$('.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();
}
$('.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();
mspHelper.sendLedStripModeColors(save_to_eeprom);
}
function save_to_eeprom() {
@ -727,19 +694,17 @@ 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;
element.find('[class*="mode_color"]').each(function() {
let m = 0;
let d = 0;
const match = $(this).attr("class").match(/(^|\s)mode_color-([0-9]+)-([0-9]+)(\s|$)/);
if (match) {
m = Number(match[2]);
d = Number(match[3]);
$(this).css('background-color', HsvToColor(FC.LED_COLORS[getModeColor(m, d)]));
}
});
}
const match = $(this).attr("class").match(/(^|\s)mode_color-([0-9]+)-([0-9]+)(\s|$)/);
if (match) {
m = Number(match[2]);
d = Number(match[3]);
$(this).css('background-color', HsvToColor(FC.LED_COLORS[getModeColor(m, d)]));
}
});
}
function setBackgroundColor(element) {
@ -767,45 +732,31 @@ 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":
case "function-a":
case "function-f":
case "function-s":
case "function-l":
case "function-r":
case "function-o":
case "function-g":
return true;
default:
break;
}
switch (activeFunction) {
case "":
case "function-c":
case "function-a":
case "function-f":
case "function-s":
case "function-l":
case "function-r":
case "function-o":
case "function-g":
return true;
default:
break;
}
return false;
}
function areBlinkersActive(activeFunction) {
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
switch (activeFunction) {
case "function-c":
case "function-a":
case "function-f":
return true;
default:
break;
}
switch (activeFunction) {
case "function-c":
case "function-a":
case "function-f":
return true;
default:
break;
}
return false;
}
@ -818,26 +769,20 @@ 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":
case "function-a":
case "function-f":
return true;
default:
return false;
}
switch (activeFunction) {
case "function-v":
case "function-c":
case "function-a":
case "function-f":
return true;
default:
return false;
}
}
@ -846,23 +791,12 @@ led_strip.initialize = function (callback, scrollPosition) {
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();
}
// >= 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,67 +809,50 @@ 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();
// set mode colors visibility
if (activeFunction === "function-f") {
$('.mode_colors').show();
}
$('.mode_colors').hide();
if (semver.gte(FC.CONFIG.apiVersion, "1.19.0")) {
// set mode colors visibility
// set special colors visibility
$('.special_colors').show();
$('.mode_color-6-0').hide();
$('.mode_color-6-1').hide();
$('.mode_color-6-2').hide();
$('.mode_color-6-3').hide();
$('.mode_color-6-4').hide();
$('.mode_color-6-5').hide();
$('.mode_color-6-6').hide();
$('.mode_color-6-7').hide();
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
if (activeFunction === "function-f") {
$('.mode_colors').show();
}
}
// set special colors visibility
$('.special_colors').show();
$('.mode_color-6-0').hide();
$('.mode_color-6-1').hide();
$('.mode_color-6-2').hide();
$('.mode_color-6-3').hide();
$('.mode_color-6-4').hide();
$('.mode_color-6-5').hide();
$('.mode_color-6-6').hide();
$('.mode_color-6-7').hide();
switch (activeFunction) {
case "": // none
case "function-f": // Modes & Orientation
case "function-l": // Battery
// $('.mode_color-6-3').show(); // background
$('.special_colors').hide();
break;
case "function-g": // GPS
$('.mode_color-6-5').show(); // no sats
$('.mode_color-6-6').show(); // no lock
$('.mode_color-6-7').show(); // locked
// $('.mode_color-6-3').show(); // background
break;
case "function-b": // Blink
$('.mode_color-6-4').show(); // blink background
break;
case "function-a": // Arm state
$('.mode_color-6-0').show(); // disarmed
$('.mode_color-6-1').show(); // armed
break;
case "function-r": // Ring
default:
$('.special_colors').hide();
switch (activeFunction) {
case "": // none
case "function-f": // Modes & Orientation
case "function-l": // Battery
// $('.mode_color-6-3').show(); // background
$('.special_colors').hide();
break;
}
case "function-g": // GPS
$('.mode_color-6-5').show(); // no sats
$('.mode_color-6-6').show(); // no lock
$('.mode_color-6-7').show(); // locked
// $('.mode_color-6-3').show(); // background
break;
case "function-b": // Blink
$('.mode_color-6-4').show(); // blink background
break;
case "function-a": // Arm state
$('.mode_color-6-0').show(); // disarmed
$('.mode_color-6-1').show(); // armed
break;
case "function-r": // Ring
default:
$('.special_colors').hide();
break;
}
}
@ -966,32 +883,20 @@ 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');
unselectOverlay(letter, 'b');
unselectOverlay(letter, 'n');
unselectOverlay(letter, 't');
}
if (letter == 'l' || letter == 'g' || letter == 's') {
unselectOverlay(letter, 'w');
unselectOverlay(letter, 'v');
unselectOverlay(letter, 't');
unselectOverlay(letter, 'o');
unselectOverlay(letter, 'b');
unselectOverlay(letter, 'n');
}
// MSP 1.20
if (letter == 'r' || letter == '') {
unselectOverlay(letter, 'o');
unselectOverlay(letter, 'b');
unselectOverlay(letter, 'n');
unselectOverlay(letter, 't');
}
if (letter == 'l' || letter == 'g' || letter == 's') {
unselectOverlay(letter, 'w');
unselectOverlay(letter, 'v');
unselectOverlay(letter, 't');
unselectOverlay(letter, 'o');
unselectOverlay(letter, 'b');
unselectOverlay(letter, 'n');
}
}

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);
}
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,30 +130,24 @@ 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)) {
if ((FC.SDCARD.supported && deviceSelect.val() == 2) || (FC.DATAFLASH.supported && deviceSelect.val() == 1)) {
$(".tab-onboard_logging")
.toggleClass("msc-supported", true);
$(".tab-onboard_logging")
.toggleClass("msc-supported", true);
$('a.onboardLoggingRebootMsc').click(function () {
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'RebootMsc');
$('a.onboardLoggingRebootMsc').click(function () {
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
buffer.push(mspHelper.REBOOT_TYPES.MSC_UTC);
} else {
buffer.push(mspHelper.REBOOT_TYPES.MSC);
}
} else {
buffer.push(mspHelper.REBOOT_TYPES.MSC);
}
MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false);
});
}
const buffer = [];
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
buffer.push(mspHelper.REBOOT_TYPES.MSC_UTC);
} else {
buffer.push(mspHelper.REBOOT_TYPES.MSC);
}
MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false);
});
}
update_html();
@ -170,24 +159,14 @@ 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>`);
}
if (FC.SDCARD.supported) {
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.append(`<option value="0">${i18n.getMessage('blackboxLoggingNone')}</option>`);
if (FC.DATAFLASH.supported) {
deviceSelect.append(`<option value="1">${i18n.getMessage('blackboxLoggingFlash')}</option>`);
}
if (FC.SDCARD.supported) {
deviceSelect.append(`<option value="2">${i18n.getMessage('blackboxLoggingSdCard')}</option>`);
}
deviceSelect.append(`<option value="3">${i18n.getMessage('blackboxLoggingSerial')}</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,16 +394,14 @@ 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);
const mscIsReady = dataflashPresent || (FC.SDCARD.state === MSP.SDCARD_STATE_READY);
$(".tab-onboard_logging")
.toggleClass("msc-not-ready", !mscIsReady);
if (!mscIsReady) {
$('a.onboardLoggingRebootMsc').addClass('disabled');
} else {
$('a.onboardLoggingRebootMsc').removeClass('disabled');
}
if (!mscIsReady) {
$('a.onboardLoggingRebootMsc').addClass('disabled');
} else {
$('a.onboardLoggingRebootMsc').removeClass('disabled');
}
let loggingStatus;
@ -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;
}
self.blockSize = self.VCP_BLOCK_SIZE;
} else {
self.blockSize = self.BLOCK_SIZE;
}

File diff suppressed because it is too large Load Diff

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);
}
const ltmFunctionRule = {name: 'TELEMETRY_LTM', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['peripherals'], maxPorts: 1};
functionRules.push(ltmFunctionRule);
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);
}
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 });
}
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 });
}
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 });
}
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 });
}
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 });
}
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();
}
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"]').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,10 +257,7 @@ 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'));
}
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);
}
mspHelper.sendVoltageConfig(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);
}
mspHelper.sendCurrentConfig(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);
}
$('.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);
}
$('.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"]').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();
}
$('select[name="rcInterpolation-select"]').change(function () {
tab.updateRcInterpolationParameters();
}).change();
// generate bars
const bar_names = [
@ -289,108 +267,96 @@ receiver.initialize = function (callback) {
});
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
const spiRxTypes = [
'NRF24_V202_250K',
'NRF24_V202_1M',
'NRF24_SYMA_X',
'NRF24_SYMA_X5C',
'NRF24_CX10',
'CX10A',
'NRF24_H8_3D',
'NRF24_INAV',
'FRSKY_D',
];
const spiRxTypes = [
'NRF24_V202_250K',
'NRF24_V202_1M',
'NRF24_SYMA_X',
'NRF24_SYMA_X5C',
'NRF24_CX10',
'CX10A',
'NRF24_H8_3D',
'NRF24_INAV',
'FRSKY_D',
'FRSKY_X',
'A7105_FLYSKY',
'A7105_FLYSKY_2A',
'NRF24_KN',
'SFHSS',
'SPEKTRUM',
'FRSKY_X_LBT',
];
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_43)) {
spiRxTypes.push(
'REDPINE',
);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
spiRxTypes.push(
'FRSKY_X_V2',
'FRSKY_X_LBT_V2',
'EXPRESSLRS',
);
}
const spiRxElement = $('select.spiRx');
for (let i = 0; i < spiRxTypes.length; i++) {
spiRxElement.append(`<option value="${i}">${spiRxTypes[i]}</option>`);
}
spiRxElement.change(function () {
const value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.RX_CONFIG.rxSpiProtocol) {
newValue = $(this).find('option:selected').text();
updateSaveButton(true);
}
tab.analyticsChanges['SPIRXProtocol'] = newValue;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
spiRxTypes.push(
'SFHSS',
'SPEKTRUM',
'FRSKY_X_LBT',
);
}
FC.RX_CONFIG.rxSpiProtocol = value;
});
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
spiRxTypes.push(
'REDPINE',
);
}
// select current serial RX type
spiRxElement.val(FC.RX_CONFIG.rxSpiProtocol);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
spiRxTypes.push(
'FRSKY_X_V2',
'FRSKY_X_LBT_V2',
'EXPRESSLRS',
);
}
const spiRxElement = $('select.spiRx');
for (let i = 0; i < spiRxTypes.length; i++) {
spiRxElement.append(`<option value="${i}">${spiRxTypes[i]}</option>`);
}
spiRxElement.change(function () {
const value = parseInt($(this).val());
let newValue = undefined;
if (value !== FC.RX_CONFIG.rxSpiProtocol) {
newValue = $(this).find('option:selected').text();
updateSaveButton(true);
}
tab.analyticsChanges['SPIRXProtocol'] = newValue;
FC.RX_CONFIG.rxSpiProtocol = value;
if (!GUI.isCordova()) {
// Convert to select2 and order alphabetic
spiRxElement.select2({
sorter(data) {
return data.sort(function(a, b) {
return a.text.localeCompare(b.text);
});
},
});
}
// select current serial RX type
spiRxElement.val(FC.RX_CONFIG.rxSpiProtocol);
if (FC.FEATURE_CONFIG.features.isEnabled('RX_SPI') && FC.RX_CONFIG.rxSpiProtocol == 19 && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
tab.elrsPassphraseEnabled = true;
if (!GUI.isCordova()) {
// Convert to select2 and order alphabetic
spiRxElement.select2({
sorter(data) {
return data.sort(function(a, b) {
return a.text.localeCompare(b.text);
});
},
});
const elrsUid = $('span.elrsUid');
const elrsUidString = FC.RX_CONFIG.elrsUid.join(',');
elrsUid.text(elrsUidString);
const elrsPassphrase = $('input.elrsPassphrase');
const passphraseString = lookup_elrs_passphrase(elrsUidString);
if (passphraseString) {
elrsPassphrase.val(passphraseString);
}
if (FC.FEATURE_CONFIG.features.isEnabled('RX_SPI') && FC.RX_CONFIG.rxSpiProtocol == 19 && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
tab.elrsPassphraseEnabled = true;
const elrsUid = $('span.elrsUid');
const elrsUidString = FC.RX_CONFIG.elrsUid.join(',');
elrsUid.text(elrsUidString);
const elrsPassphrase = $('input.elrsPassphrase');
const passphraseString = lookup_elrs_passphrase(elrsUidString);
if (passphraseString) {
elrsPassphrase.val(passphraseString);
elrsPassphrase.on('keyup', function() {
const passphrase = elrsPassphrase.val();
if (passphrase) {
elrsUid.text(elrs_passphrase_to_bytes(passphrase));
} else {
elrsUid.text("0.0.0.0.0.0");
}
elrsPassphrase.on('keyup', function() {
const passphrase = elrsPassphrase.val();
if (passphrase) {
elrsUid.text(elrs_passphrase_to_bytes(passphrase));
} else {
elrsUid.text("0.0.0.0.0.0");
}
updateSaveButton(true);
});
} else {
tab.elrsPassphraseEnabled = false;
}
updateSaveButton(true);
});
} 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());
}
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());
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, "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());
}
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();
}
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, nextCallback);
}
function save_feature_config() {
@ -613,105 +563,92 @@ 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"]');
rc_smoothing_protocol_e.change(function () {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
FC.RX_CONFIG.rcSmoothingMode = parseFloat($(this).val());
} else {
FC.RX_CONFIG.rcSmoothingType = parseFloat($(this).val());
}
updateInterpolationView();
});
rc_smoothing_protocol_e.val(smoothingOnOff);
const rcSmoothingNumberElement = $('input[name="rcSmoothingSetpointHz-number"]');
const rcSmoothingFeedforwardNumberElement = $('input[name="rcSmoothingFeedforwardCutoff-number"]');
rcSmoothingNumberElement.val(FC.RX_CONFIG.rcSmoothingSetpointCutoff);
rcSmoothingFeedforwardNumberElement.val(FC.RX_CONFIG.rcSmoothingFeedforwardCutoff);
$('.tab-receiver .rcSmoothing-setpoint-cutoff').show();
$('select[name="rcSmoothing-setpoint-manual-select"]').val("1");
if (FC.RX_CONFIG.rcSmoothingSetpointCutoff === 0) {
$('.tab-receiver .rcSmoothing-setpoint-cutoff').hide();
$('select[name="rcSmoothing-setpoint-manual-select"]').val("0");
}
$('select[name="rcSmoothing-setpoint-manual-select"]').change(function () {
if ($(this).val() === "0") {
rcSmoothingNumberElement.val(0);
$('.tab-receiver .rcSmoothing-setpoint-cutoff').hide();
}
if ($(this).val() === "1") {
rcSmoothingNumberElement.val(FC.RX_CONFIG.rcSmoothingSetpointCutoff);
$('.tab-receiver .rcSmoothing-setpoint-cutoff').show();
}
}).change();
$('.tab-receiver .rcSmoothing-feedforward-cutoff').show();
$('select[name="rcSmoothing-feedforward-select"]').val("1");
if (FC.RX_CONFIG.rcSmoothingFeedforwardCutoff === 0) {
$('select[name="rcSmoothing-feedforward-select"]').val("0");
$('.tab-receiver .rcSmoothing-feedforward-cutoff').hide();
}
$('select[name="rcSmoothing-feedforward-select"]').change(function () {
if ($(this).val() === "0") {
$('.tab-receiver .rcSmoothing-feedforward-cutoff').hide();
rcSmoothingFeedforwardNumberElement.val(0);
}
if ($(this).val() === "1") {
$('.tab-receiver .rcSmoothing-feedforward-cutoff').show();
rcSmoothingFeedforwardNumberElement.val(FC.RX_CONFIG.rcSmoothingFeedforwardCutoff);
}
}).change();
const rcSmoothingFeedforwardType = $('select[name="rcSmoothingFeedforwardType-select"]');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
rcSmoothingFeedforwardType.append($(`<option value="3">${i18n.getMessage("receiverRcSmoothingFeedforwardTypeAuto")}</option>`));
}
rcSmoothingFeedforwardType.val(FC.RX_CONFIG.rcSmoothingDerivativeType);
const rcSmoothingChannels = $('select[name="rcSmoothingChannels-select"]');
rcSmoothingChannels.val(FC.RX_CONFIG.rcInterpolationChannels);
const rcSmoothingSetpointType = $('select[name="rcSmoothingSetpointType-select"]');
rcSmoothingSetpointType.val(FC.RX_CONFIG.rcSmoothingInputType);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
$('select[name="rcSmoothing-setpoint-manual-select"], select[name="rcSmoothing-feedforward-select"]').change(function() {
if ($('select[name="rcSmoothing-setpoint-manual-select"]').val() === "0" || $('select[name="rcSmoothing-feedforward-select"]').val() === "0") {
$('.tab-receiver .rcSmoothing-auto-factor').show();
} else {
$('.tab-receiver .rcSmoothing-auto-factor').hide();
}
});
$('select[name="rcSmoothing-setpoint-manual-select"]').change();
const rcSmoothingAutoFactor = $('input[name="rcSmoothingAutoFactor-number"]');
rcSmoothingAutoFactor.val(FC.RX_CONFIG.rcSmoothingAutoFactor);
} else {
$('.tab-receiver .rcSmoothing-auto-factor').hide();
}
$('.tab-receiver .rcSmoothing').show();
const rc_smoothing_protocol_e = $('select[name="rcSmoothing-select"]');
rc_smoothing_protocol_e.change(function () {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
$('.receiverRcSmoothingAutoFactorHelp').attr('title', i18n.getMessage("receiverRcSmoothingAutoFactorHelp2"));
FC.RX_CONFIG.rcSmoothingMode = parseFloat($(this).val());
} else {
FC.RX_CONFIG.rcSmoothingType = parseFloat($(this).val());
}
updateInterpolationView();
} else {
$('.tab-receiver .rcInterpolation').show();
$('.tab-receiver .rcSmoothing-feedforward-cutoff').hide();
});
rc_smoothing_protocol_e.val(smoothingOnOff);
const rcSmoothingNumberElement = $('input[name="rcSmoothingSetpointHz-number"]');
const rcSmoothingFeedforwardNumberElement = $('input[name="rcSmoothingFeedforwardCutoff-number"]');
rcSmoothingNumberElement.val(FC.RX_CONFIG.rcSmoothingSetpointCutoff);
rcSmoothingFeedforwardNumberElement.val(FC.RX_CONFIG.rcSmoothingFeedforwardCutoff);
$('.tab-receiver .rcSmoothing-setpoint-cutoff').show();
$('select[name="rcSmoothing-setpoint-manual-select"]').val("1");
if (FC.RX_CONFIG.rcSmoothingSetpointCutoff === 0) {
$('.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();
$('select[name="rcSmoothing-setpoint-manual-select"]').val("0");
}
$('select[name="rcSmoothing-setpoint-manual-select"]').change(function () {
if ($(this).val() === "0") {
rcSmoothingNumberElement.val(0);
$('.tab-receiver .rcSmoothing-setpoint-cutoff').hide();
}
if ($(this).val() === "1") {
rcSmoothingNumberElement.val(FC.RX_CONFIG.rcSmoothingSetpointCutoff);
$('.tab-receiver .rcSmoothing-setpoint-cutoff').show();
}
}).change();
$('.tab-receiver .rcSmoothing-feedforward-cutoff').show();
$('select[name="rcSmoothing-feedforward-select"]').val("1");
if (FC.RX_CONFIG.rcSmoothingFeedforwardCutoff === 0) {
$('select[name="rcSmoothing-feedforward-select"]').val("0");
$('.tab-receiver .rcSmoothing-feedforward-cutoff').hide();
}
$('select[name="rcSmoothing-feedforward-select"]').change(function () {
if ($(this).val() === "0") {
$('.tab-receiver .rcSmoothing-feedforward-cutoff').hide();
rcSmoothingFeedforwardNumberElement.val(0);
}
if ($(this).val() === "1") {
$('.tab-receiver .rcSmoothing-feedforward-cutoff').show();
rcSmoothingFeedforwardNumberElement.val(FC.RX_CONFIG.rcSmoothingFeedforwardCutoff);
}
}).change();
const rcSmoothingFeedforwardType = $('select[name="rcSmoothingFeedforwardType-select"]');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
rcSmoothingFeedforwardType.append($(`<option value="3">${i18n.getMessage("receiverRcSmoothingFeedforwardTypeAuto")}</option>`));
}
rcSmoothingFeedforwardType.val(FC.RX_CONFIG.rcSmoothingDerivativeType);
const rcSmoothingChannels = $('select[name="rcSmoothingChannels-select"]');
rcSmoothingChannels.val(FC.RX_CONFIG.rcInterpolationChannels);
const rcSmoothingSetpointType = $('select[name="rcSmoothingSetpointType-select"]');
rcSmoothingSetpointType.val(FC.RX_CONFIG.rcSmoothingInputType);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
$('select[name="rcSmoothing-setpoint-manual-select"], select[name="rcSmoothing-feedforward-select"]').change(function() {
if ($('select[name="rcSmoothing-setpoint-manual-select"]').val() === "0" || $('select[name="rcSmoothing-feedforward-select"]').val() === "0") {
$('.tab-receiver .rcSmoothing-auto-factor').show();
} else {
$('.tab-receiver .rcSmoothing-auto-factor').hide();
}
});
$('select[name="rcSmoothing-setpoint-manual-select"]').change();
const rcSmoothingAutoFactor = $('input[name="rcSmoothingAutoFactor-number"]');
rcSmoothingAutoFactor.val(FC.RX_CONFIG.rcSmoothingAutoFactor);
} else {
$('.tab-receiver .rcSmoothing-auto-factor').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
$('.receiverRcSmoothingAutoFactorHelp').attr('title', i18n.getMessage("receiverRcSmoothingAutoFactorHelp2"));
}
updateInterpolationView();
// 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,12 +875,10 @@ 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();
}
if ($('select[name="rcInterpolation-select"]').val() === '3') {
$('.tab-receiver .rc-interpolation-manual').show();
} else {
$('.tab-receiver .rc-interpolation-manual').hide();
}
};

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,22 +54,18 @@ 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 {
$('.initialSetupRebootBootloader').hide();
}
$('a.rebootBootloader').click(function () {
const buffer = [];
buffer.push(FC.boardHasFlashBootloader() ? mspHelper.REBOOT_TYPES.BOOTLOADER_FLASH : mspHelper.REBOOT_TYPES.BOOTLOADER);
MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false);
});
if (isExpertModeEnabled()) {
$('.initialSetupRebootBootloader').show();
} else {
$('.initialSetupRebootBootloader').hide();
}
$('a.rebootBootloader').click(function () {
const buffer = [];
buffer.push(FC.boardHasFlashBootloader() ? mspHelper.REBOOT_TYPES.BOOTLOADER_FLASH : mspHelper.REBOOT_TYPES.BOOTLOADER);
MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false);
});
// UI Hooks
$('a.calibrateAccel').click(function () {
const _self = $(this);
@ -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();
}
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');
}
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']);
disarmFlagElements.splice(disarmFlagElements.indexOf('OSD_MENU'), 1);
disarmFlagElements = disarmFlagElements.concat(['RESC']);
disarmFlagElements = disarmFlagElements.concat(['RPMFILTER']);
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');
}
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>