Restore experimental backup and restore only for virtual and fw below 4.3 (#3134)
Restore backup and restore10.9-maintenance
parent
867b59d204
commit
c625741604
|
@ -770,12 +770,30 @@
|
|||
"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"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,896 @@
|
|||
'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,
|
||||
MSPCodes.MSP_SERVO_MIX_RULES,
|
||||
MSPCodes.MSP_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, 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),
|
||||
});
|
||||
|
||||
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() {
|
||||
uniqueData.push(MSPCodes.MSP_LOOP_TIME);
|
||||
uniqueData.push(MSPCodes.MSP_ARMING_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_MOTOR_3D_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SENSOR_ALIGNMENT);
|
||||
uniqueData.push(MSPCodes.MSP_RX_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_FAILSAFE_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_RXFAIL_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_LED_STRIP_MODECOLOR);
|
||||
uniqueData.push(MSPCodes.MSP_MOTOR_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_RSSI_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_GPS_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_FEATURE_CONFIG);
|
||||
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);
|
||||
|
||||
configuration.LED_MODE_COLORS = jQuery.extend(true, [], FC.LED_MODE_COLORS);
|
||||
configuration.FC_CONFIG = jQuery.extend(true, {}, FC.FC_CONFIG);
|
||||
configuration.ARMING_CONFIG = jQuery.extend(true, {}, FC.ARMING_CONFIG);
|
||||
configuration.MOTOR_3D_CONFIG = jQuery.extend(true, {}, FC.MOTOR_3D_CONFIG);
|
||||
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);
|
||||
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);
|
||||
configuration.BEEPER_CONFIG = jQuery.extend(true, {}, FC.BEEPER_CONFIG);
|
||||
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(() => MSP.promise(MSPCodes.MSP_SENSOR_CONFIG))
|
||||
.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))
|
||||
: MSP.promise(MSPCodes.MSP_NAME))
|
||||
.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_BOARD_ALIGNMENT_CONFIG))
|
||||
.then(() => MSP.promise(MSPCodes.MSP_MIXER_CONFIG))
|
||||
.then(() => MSP.promise(MSPCodes.MSP_BEEPER_CONFIG))
|
||||
.then(() => 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,
|
||||
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);
|
||||
|
||||
uniqueData.push(MSPCodes.MSP_SET_LOOP_TIME);
|
||||
uniqueData.push(MSPCodes.MSP_SET_ARMING_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_MOTOR_3D_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_SENSOR_ALIGNMENT);
|
||||
uniqueData.push(MSPCodes.MSP_SET_RX_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_FAILSAFE_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_FEATURE_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_MOTOR_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_GPS_CONFIG);
|
||||
uniqueData.push(MSPCodes.MSP_SET_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() {
|
||||
mspHelper.sendLedStripModeColors(send_rxfail_config);
|
||||
}
|
||||
|
||||
function send_rxfail_config() {
|
||||
mspHelper.sendRxFailConfig(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.Promise(MSPCodes.MSP_SET_REBOOT)
|
||||
.then(() => reinitializeConnection())
|
||||
.then(() => _callback());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (CONFIGURATOR.virtualMode) {
|
||||
FC.resetState();
|
||||
FC.CONFIG.apiVersion = CONFIGURATOR.virtualApiVersion;
|
||||
|
||||
sensor_status(FC.CONFIG.activeSensors);
|
||||
update_dataflash_global();
|
||||
}
|
||||
|
||||
upload();
|
||||
}
|
||||
}
|
|
@ -1,15 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
const API_VERSION_1_31 = '1.31.0';
|
||||
const API_VERSION_1_32 = '1.32.0';
|
||||
const API_VERSION_1_33 = '1.33.0';
|
||||
const API_VERSION_1_34 = '1.34.0';
|
||||
const API_VERSION_1_35 = '1.35.0';
|
||||
const API_VERSION_1_36 = '1.36.0';
|
||||
const API_VERSION_1_37 = '1.37.0';
|
||||
const API_VERSION_1_38 = '1.38.0';
|
||||
const API_VERSION_1_39 = '1.39.0';
|
||||
const API_VERSION_1_40 = '1.40.0';
|
||||
|
||||
const API_VERSION_1_41 = '1.41.0';
|
||||
const API_VERSION_1_42 = '1.42.0';
|
||||
const API_VERSION_1_43 = '1.43.0';
|
||||
|
@ -19,6 +12,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: API_VERSION_1_41,
|
||||
API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE: API_VERSION_1_41,
|
||||
API_VERSION_MAX_SUPPORTED: API_VERSION_1_45,
|
||||
|
||||
connectionValid: false,
|
||||
|
|
|
@ -2220,14 +2220,9 @@ MspHelper.prototype.dataflashRead = function(address, blockSize, onDataCallback)
|
|||
if (!response.crcError) {
|
||||
const chunkAddress = response.data.readU32();
|
||||
|
||||
let headerSize = 4;
|
||||
let dataSize = response.data.buffer.byteLength - headerSize;
|
||||
let dataCompressionType = 0;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
|
||||
headerSize = headerSize + 3;
|
||||
dataSize = response.data.readU16();
|
||||
dataCompressionType = response.data.readU8();
|
||||
}
|
||||
const headerSize = 7;
|
||||
const dataSize = response.data.readU16();
|
||||
const dataCompressionType = response.data.readU8();
|
||||
|
||||
// Verify that the address of the memory returned matches what the caller asked for and there was not a CRC error
|
||||
if (chunkAddress == address) {
|
||||
|
|
|
@ -211,7 +211,7 @@ motors.initialize = async function (callback) {
|
|||
}
|
||||
|
||||
function update_model(mixer) {
|
||||
const imgSrc = getMixerImageSrc(mixer, FC.MIXER_CONFIG.reverseMotorDir, FC.CONFIG.apiVersion);
|
||||
const imgSrc = getMixerImageSrc(mixer, FC.MIXER_CONFIG.reverseMotorDir);
|
||||
$('.mixerPreview img').attr('src', imgSrc);
|
||||
|
||||
const motorOutputReorderConfig = new MotorOutputReorderConfig(100);
|
||||
|
|
|
@ -653,7 +653,7 @@ OSD.loadDisplayFields = function() {
|
|||
},
|
||||
draw_order: 40,
|
||||
positionable() {
|
||||
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39) ? true : false;
|
||||
return true;
|
||||
},
|
||||
preview() {
|
||||
return FONT.symbol(SYM.AH_CENTER_LINE) + FONT.symbol(SYM.AH_CENTER) + FONT.symbol(SYM.AH_CENTER_LINE_RIGHT);
|
||||
|
@ -668,7 +668,7 @@ OSD.loadDisplayFields = function() {
|
|||
},
|
||||
draw_order: 10,
|
||||
positionable() {
|
||||
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39) ? true : false;
|
||||
return true;
|
||||
},
|
||||
preview() {
|
||||
const artificialHorizon = [];
|
||||
|
@ -701,7 +701,7 @@ OSD.loadDisplayFields = function() {
|
|||
},
|
||||
draw_order: 50,
|
||||
positionable() {
|
||||
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39) ? true : false;
|
||||
return true;
|
||||
},
|
||||
preview() {
|
||||
|
||||
|
@ -747,7 +747,7 @@ OSD.loadDisplayFields = function() {
|
|||
draw_order: 130,
|
||||
positionable: true,
|
||||
preview() {
|
||||
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36) ? ` 42.00${FONT.symbol(SYM.AMP)}` : `${FONT.symbol(SYM.AMP)}42.0`;
|
||||
return ` 42.00${FONT.symbol(SYM.AMP)}`;
|
||||
},
|
||||
},
|
||||
MAH_DRAWN: {
|
||||
|
@ -758,7 +758,7 @@ OSD.loadDisplayFields = function() {
|
|||
draw_order: 140,
|
||||
positionable: true,
|
||||
preview() {
|
||||
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36) ? ` 690${FONT.symbol(SYM.MAH)}` : `${FONT.symbol(SYM.MAH)}690`;
|
||||
return ` 690${FONT.symbol(SYM.MAH)}`;
|
||||
},
|
||||
},
|
||||
CRAFT_NAME: {
|
||||
|
@ -910,7 +910,7 @@ OSD.loadDisplayFields = function() {
|
|||
draw_order: 200,
|
||||
positionable: true,
|
||||
preview() {
|
||||
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36) ? ' 142W' : '142W';
|
||||
return ' 142W';
|
||||
},
|
||||
},
|
||||
PID_RATE_PROFILE: {
|
||||
|
@ -1801,29 +1801,15 @@ OSD.searchLimitsElement = function(arrayElements) {
|
|||
// Pick display fields by version, order matters, so these are going in an array... pry could iterate the example map instead
|
||||
OSD.chooseFields = function() {
|
||||
let F = OSD.ALL_DISPLAY_FIELDS;
|
||||
// version 3.0.1
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.21.0")) {
|
||||
|
||||
OSD.constants.DISPLAY_FIELDS = [
|
||||
F.RSSI_VALUE,
|
||||
F.MAIN_BATT_VOLTAGE,
|
||||
F.CROSSHAIRS,
|
||||
F.ARTIFICIAL_HORIZON,
|
||||
F.HORIZON_SIDEBARS,
|
||||
];
|
||||
|
||||
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.ONTIME,
|
||||
F.FLYTIME,
|
||||
]);
|
||||
} else {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.TIMER_1,
|
||||
F.TIMER_2,
|
||||
]);
|
||||
}
|
||||
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.FLYMODE,
|
||||
F.CRAFT_NAME,
|
||||
F.THROTTLE_POSITION,
|
||||
|
@ -1833,34 +1819,18 @@ OSD.chooseFields = function() {
|
|||
F.GPS_SPEED,
|
||||
F.GPS_SATS,
|
||||
F.ALTITUDE,
|
||||
]);
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.PID_ROLL,
|
||||
F.PID_PITCH,
|
||||
F.PID_YAW,
|
||||
F.POWER,
|
||||
]);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_32)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.PID_RATE_PROFILE,
|
||||
semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36) ? F.WARNINGS : F.BATTERY_WARNING,
|
||||
F.WARNINGS,
|
||||
F.AVG_CELL_VOLTAGE,
|
||||
]);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_34)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.GPS_LON,
|
||||
F.GPS_LAT,
|
||||
F.DEBUG,
|
||||
]);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_35)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.PITCH_ANGLE,
|
||||
F.ROLL_ANGLE,
|
||||
]);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.MAIN_BATT_USAGE,
|
||||
F.DISARMED,
|
||||
F.HOME_DIR,
|
||||
|
@ -1870,24 +1840,12 @@ OSD.chooseFields = function() {
|
|||
F.COMPASS_BAR,
|
||||
F.ESC_TEMPERATURE,
|
||||
F.ESC_RPM,
|
||||
]);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.REMAINING_TIME_ESTIMATE,
|
||||
F.RTC_DATE_TIME,
|
||||
F.ADJUSTMENT_RANGE,
|
||||
F.CORE_TEMPERATURE,
|
||||
]);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.ANTI_GRAVITY,
|
||||
]);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.G_FORCE,
|
||||
]);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.MOTOR_DIAG,
|
||||
F.LOG_STATUS,
|
||||
F.FLIP_ARROW,
|
||||
|
@ -1898,7 +1856,8 @@ OSD.chooseFields = function() {
|
|||
// show either DISPLAY_NAME or PILOT_NAME depending on the MSP version
|
||||
(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? F.PILOT_NAME : F.DISPLAY_NAME),
|
||||
F.ESC_RPM_FREQ,
|
||||
]);
|
||||
];
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.RATE_PROFILE_NAME,
|
||||
|
@ -1906,18 +1865,24 @@ OSD.chooseFields = function() {
|
|||
F.OSD_PROFILE_NAME,
|
||||
F.RSSI_DBM_VALUE,
|
||||
]);
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.RC_CHANNELS,
|
||||
F.CAMERA_FRAME,
|
||||
F.OSD_EFFICIENCY,
|
||||
]);
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.TOTAL_FLIGHTS,
|
||||
F.OSD_UP_DOWN_REFERENCE,
|
||||
F.OSD_TX_UPLINK_POWER,
|
||||
]);
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||
OSD.constants.DISPLAY_FIELDS = OSD.constants.DISPLAY_FIELDS.concat([
|
||||
F.WH_DRAWN,
|
||||
|
@ -1937,38 +1902,6 @@ OSD.chooseFields = function() {
|
|||
F.SYS_FAN_SPEED,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// version 3.0.0
|
||||
OSD.constants.DISPLAY_FIELDS = [
|
||||
F.MAIN_BATT_VOLTAGE,
|
||||
F.RSSI_VALUE,
|
||||
F.TIMER,
|
||||
F.THROTTLE_POSITION,
|
||||
F.CPU_LOAD,
|
||||
F.VTX_CHANNEL,
|
||||
F.VOLTAGE_WARNING,
|
||||
F.ARMED,
|
||||
F.DISARMED,
|
||||
F.ARTIFICIAL_HORIZON,
|
||||
F.HORIZON_SIDEBARS,
|
||||
F.CURRENT_DRAW,
|
||||
F.MAH_DRAWN,
|
||||
F.CRAFT_NAME,
|
||||
F.ALTITUDE,
|
||||
];
|
||||
}
|
||||
|
||||
// Choose statistic fields
|
||||
// Nothing much to do here, I'm preempting there being new statistics
|
||||
|
@ -1982,27 +1915,7 @@ OSD.chooseFields = function() {
|
|||
// that needs to be implemented here as well. Simply appending new stats does not
|
||||
// require a completely new section for the version - only reordering.
|
||||
|
||||
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
|
||||
OSD.constants.STATISTIC_FIELDS = [
|
||||
F.MAX_SPEED,
|
||||
F.MIN_BATTERY,
|
||||
F.MIN_RSSI,
|
||||
F.MAX_CURRENT,
|
||||
F.USED_MAH,
|
||||
F.MAX_ALTITUDE,
|
||||
F.BLACKBOX,
|
||||
F.END_BATTERY,
|
||||
F.TIMER_1,
|
||||
F.TIMER_2,
|
||||
F.MAX_DISTANCE,
|
||||
F.BLACKBOX_LOG_NUMBER,
|
||||
];
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
|
||||
OSD.constants.STATISTIC_FIELDS = OSD.constants.STATISTIC_FIELDS.concat([
|
||||
F.RTC_DATE_TIME,
|
||||
]);
|
||||
}
|
||||
} else { // Starting with 1.39.0 OSD stats are reordered to match how they're presented on screen
|
||||
// Starting with 1.39.0 OSD stats are reordered to match how they're presented on screen
|
||||
OSD.constants.STATISTIC_FIELDS = [
|
||||
F.RTC_DATE_TIME,
|
||||
F.TIMER_1,
|
||||
|
@ -2018,17 +1931,14 @@ OSD.chooseFields = function() {
|
|||
F.MAX_ALTITUDE,
|
||||
F.BLACKBOX,
|
||||
F.BLACKBOX_LOG_NUMBER,
|
||||
];
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
|
||||
OSD.constants.STATISTIC_FIELDS = OSD.constants.STATISTIC_FIELDS.concat([
|
||||
F.MAX_G_FORCE,
|
||||
F.MAX_ESC_TEMP,
|
||||
F.MAX_ESC_RPM,
|
||||
F.MIN_LINK_QUALITY,
|
||||
F.FLIGHT_DISTANCE,
|
||||
F.MAX_FFT,
|
||||
]);
|
||||
}
|
||||
];
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
|
||||
OSD.constants.STATISTIC_FIELDS = OSD.constants.STATISTIC_FIELDS.concat([
|
||||
F.STAT_TOTAL_FLIGHTS,
|
||||
|
@ -2037,17 +1947,18 @@ OSD.chooseFields = function() {
|
|||
F.MIN_RSSI_DBM,
|
||||
]);
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||
OSD.constants.STATISTIC_FIELDS = OSD.constants.STATISTIC_FIELDS.concat([
|
||||
F.USED_WH,
|
||||
F.MIN_RSNR,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// Choose warnings
|
||||
// Nothing much to do here, I'm preempting there being new warnings
|
||||
F = OSD.constants.ALL_WARNINGS;
|
||||
|
||||
OSD.constants.WARNINGS = [
|
||||
F.ARMING_DISABLED,
|
||||
F.BATTERY_NOT_FULL,
|
||||
|
@ -2055,28 +1966,21 @@ OSD.chooseFields = function() {
|
|||
F.BATTERY_CRITICAL,
|
||||
F.VISUAL_BEEPER,
|
||||
F.CRASH_FLIP_MODE,
|
||||
];
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
|
||||
OSD.constants.WARNINGS = OSD.constants.WARNINGS.concat([
|
||||
F.ESC_FAIL,
|
||||
F.CORE_TEMPERATURE,
|
||||
F.RC_SMOOTHING_FAILURE,
|
||||
]);
|
||||
}
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
|
||||
OSD.constants.WARNINGS = OSD.constants.WARNINGS.concat([
|
||||
F.FAILSAFE,
|
||||
F.LAUNCH_CONTROL,
|
||||
F.GPS_RESCUE_UNAVAILABLE,
|
||||
F.GPS_RESCUE_DISABLED,
|
||||
]);
|
||||
}
|
||||
];
|
||||
|
||||
OSD.constants.TIMER_TYPES = [
|
||||
'ON_TIME',
|
||||
'TOTAL_ARMED_TIME',
|
||||
'LAST_ARMED_TIME',
|
||||
];
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
|
||||
OSD.constants.TIMER_TYPES = OSD.constants.TIMER_TYPES.concat([
|
||||
'ON_ARM_TIME',
|
||||
|
@ -2212,19 +2116,14 @@ OSD.msp = {
|
|||
},
|
||||
encodeOther() {
|
||||
const result = [-1, OSD.data.video_system];
|
||||
if (OSD.data.state.haveOsdFeature && semver.gte(FC.CONFIG.apiVersion, "1.21.0")) {
|
||||
if (OSD.data.state.haveOsdFeature) {
|
||||
result.push8(OSD.data.unit_mode);
|
||||
// watch out, order matters! match the firmware
|
||||
result.push8(OSD.data.alarms.rssi.value);
|
||||
result.push16(OSD.data.alarms.cap.value);
|
||||
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
result.push16(OSD.data.alarms.time.value);
|
||||
} else {
|
||||
// This value is unused by the firmware with configurable timers
|
||||
result.push16(0);
|
||||
}
|
||||
result.push16(0); // This value is unused by the firmware with configurable timers
|
||||
result.push16(OSD.data.alarms.alt.value);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
|
||||
|
||||
let warningFlags = 0;
|
||||
for (let i = 0; i < OSD.data.warnings.length; i++) {
|
||||
if (OSD.data.warnings[i].enabled) {
|
||||
|
@ -2238,20 +2137,17 @@ OSD.msp = {
|
|||
|
||||
console.log(warningFlags);
|
||||
result.push16(warningFlags);
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
|
||||
result.push32(warningFlags);
|
||||
|
||||
result.push8(OSD.data.osd_profiles.selected + 1);
|
||||
|
||||
result.push8(OSD.data.parameters.overlayRadioMode);
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||
result.push8(OSD.data.parameters.cameraFrameWidth);
|
||||
result.push8(OSD.data.parameters.cameraFrameHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
encodeLayout(displayItem) {
|
||||
|
@ -2331,21 +2227,14 @@ OSD.msp = {
|
|||
|
||||
if (d.flags > 0 && payload.length > 1) {
|
||||
d.video_system = view.readU8();
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.21.0") && bit_check(d.flags, 0)) {
|
||||
if (bit_check(d.flags, 0)) {
|
||||
d.unit_mode = view.readU8();
|
||||
d.alarms = {};
|
||||
d.alarms['rssi'] = { display_name: i18n.getMessage('osdTimerAlarmOptionRssi'), value: view.readU8() };
|
||||
d.alarms['cap'] = { display_name: i18n.getMessage('osdTimerAlarmOptionCapacity'), value: view.readU16() };
|
||||
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
d.alarms['time'] = { display_name: 'Minutes', value: view.readU16() };
|
||||
} else {
|
||||
// This value was obsoleted by the introduction of configurable timers, and has been reused to encode the number of display elements sent in this command
|
||||
view.readU8();
|
||||
const tmp = view.readU8();
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
|
||||
displayItemsCountActual = tmp;
|
||||
}
|
||||
}
|
||||
displayItemsCountActual = view.readU8();
|
||||
|
||||
d.alarms['alt'] = { display_name: i18n.getMessage('osdTimerAlarmOptionAltitude'), value: view.readU16() };
|
||||
}
|
||||
|
@ -2353,12 +2242,12 @@ OSD.msp = {
|
|||
|
||||
d.state = {};
|
||||
d.state.haveSomeOsd = (d.flags !== 0);
|
||||
d.state.haveMax7456Configured = bit_check(d.flags, 4) || (d.flags === 1 && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_34));
|
||||
d.state.haveMax7456Configured = bit_check(d.flags, 4);
|
||||
d.state.haveFrSkyOSDConfigured = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43) && bit_check(d.flags, 3);
|
||||
d.state.haveMax7456FontDeviceConfigured = d.state.haveMax7456Configured || d.state.haveFrSkyOSDConfigured;
|
||||
d.state.isMax7456FontDeviceDetected = bit_check(d.flags, 5) || (d.state.haveMax7456FontDeviceConfigured && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_43));
|
||||
d.state.haveOsdFeature = bit_check(d.flags, 0) || (d.flags === 1 && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_34));
|
||||
d.state.isOsdSlave = bit_check(d.flags, 1) && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_34);
|
||||
d.state.haveOsdFeature = bit_check(d.flags, 0);
|
||||
d.state.isOsdSlave = bit_check(d.flags, 1);
|
||||
d.state.isMspDevice = bit_check(d.flags, 6) && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45);
|
||||
|
||||
d.displayItems = [];
|
||||
|
@ -2374,16 +2263,10 @@ OSD.msp = {
|
|||
// Read display element positions, the parsing is done later because we need the number of profiles
|
||||
const itemsPositionsRead = [];
|
||||
while (view.offset < view.byteLength && itemsPositionsRead.length < displayItemsCountActual) {
|
||||
let v = null;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.21.0")) {
|
||||
v = view.readU16();
|
||||
} else {
|
||||
v = view.read16();
|
||||
}
|
||||
const v = view.readU16();
|
||||
itemsPositionsRead.push(v);
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
// Parse statistics display enable
|
||||
const expectedStatsCount = view.readU8();
|
||||
if (expectedStatsCount !== OSD.constants.STATISTIC_FIELDS.length) {
|
||||
|
@ -2437,13 +2320,11 @@ OSD.msp = {
|
|||
}
|
||||
|
||||
// Parse enabled warnings
|
||||
let warningCount = OSD.constants.WARNINGS.length;
|
||||
let warningFlags = view.readU16();
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
|
||||
warningCount = view.readU8();
|
||||
view.readU16(); // obsolete
|
||||
const warningCount = view.readU8();
|
||||
// the flags were replaced with a 32bit version
|
||||
warningFlags = view.readU32();
|
||||
}
|
||||
const warningFlags = view.readU32();
|
||||
|
||||
for (let i = 0; i < warningCount; i++) {
|
||||
|
||||
const enabled = (warningFlags & (1 << i)) !== 0;
|
||||
|
@ -2464,9 +2345,7 @@ OSD.msp = {
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
|
||||
// OSD profiles
|
||||
d.osd_profiles.number = view.readU8();
|
||||
d.osd_profiles.selected = view.readU8() - 1;
|
||||
|
@ -2474,11 +2353,6 @@ OSD.msp = {
|
|||
// Overlay radio mode
|
||||
d.parameters.overlayRadioMode = view.readU8();
|
||||
|
||||
} else {
|
||||
d.osd_profiles.number = 1;
|
||||
d.osd_profiles.selected = 0;
|
||||
}
|
||||
|
||||
// Camera frame size
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||
d.parameters.cameraFrameWidth = view.readU8();
|
||||
|
@ -2497,7 +2371,6 @@ OSD.msp = {
|
|||
d.warnings = [];
|
||||
d.timers = [];
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
// Parse statistics display enable
|
||||
const expectedStatsCount = OSD.constants.STATISTIC_FIELDS.length;
|
||||
|
||||
|
@ -2558,7 +2431,6 @@ OSD.msp = {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.processOsdElements(OSD.data, OSD.virtualMode.itemPositions);
|
||||
|
||||
|
@ -2683,13 +2555,6 @@ OSD.GUI.preview = {
|
|||
}
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.21.0")) {
|
||||
// unsigned now
|
||||
} else {
|
||||
if (position > OSD.data.displaySize.total / 2) {
|
||||
position = position - OSD.data.displaySize.total;
|
||||
}
|
||||
}
|
||||
$(`input.${fieldId}.position`).val(position).change();
|
||||
},
|
||||
};
|
||||
|
@ -2837,7 +2702,6 @@ osd.initialize = function(callback) {
|
|||
.then(updateOsdView);
|
||||
});
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.21.0")) {
|
||||
// units
|
||||
$('.units-container').show();
|
||||
const $unitMode = $('.units').empty();
|
||||
|
@ -2873,7 +2737,6 @@ osd.initialize = function(callback) {
|
|||
$alarms.append($input);
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
// Timers
|
||||
$('.timers-container').show();
|
||||
const $timers = $('#timer-fields').empty();
|
||||
|
@ -2947,7 +2810,6 @@ osd.initialize = function(callback) {
|
|||
timerTableRow.append(alarmTimerTableData);
|
||||
|
||||
$timers.append($timerConfig);
|
||||
}
|
||||
|
||||
// Post flight statistics
|
||||
$('.stats-container').show();
|
||||
|
@ -3036,7 +2898,7 @@ osd.initialize = function(callback) {
|
|||
insertOrdered($warningFields, $field);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!(OSD.data.state.haveMax7456Configured || OSD.data.state.isMspDevice)) {
|
||||
|
|
|
@ -25,10 +25,37 @@ setup.initialize = function (callback) {
|
|||
|
||||
MSP.send_message(MSPCodes.MSP_ACC_TRIM, false, false, load_status);
|
||||
|
||||
function experimentalBackupRestore() {
|
||||
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 (CONFIGURATOR.virtualMode) {
|
||||
// saving and uploading an imaginary config to hardware is a bad idea
|
||||
backupButton.addClass('disabled');
|
||||
} else {
|
||||
restoreButton.addClass('disabled');
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||
$('.backupRestore').hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function process_html() {
|
||||
// translate to user-selected language
|
||||
i18n.localizePage();
|
||||
|
||||
experimentalBackupRestore();
|
||||
|
||||
// initialize 3D Model
|
||||
self.initModel();
|
||||
|
||||
|
@ -160,8 +187,6 @@ setup.initialize = function (callback) {
|
|||
pitch_e = $('dd.pitch'),
|
||||
heading_e = $('dd.heading');
|
||||
|
||||
arming_disable_flags_e.hide();
|
||||
|
||||
// DISARM FLAGS
|
||||
// We add all the arming/disarming flags available, and show/hide them if needed.
|
||||
const prepareDisarmFlags = function() {
|
||||
|
@ -232,7 +257,9 @@ setup.initialize = function (callback) {
|
|||
|
||||
function get_slow_data() {
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function() {
|
||||
MSP.send_message(MSPCodes.MSP_STATUS_EX, false, false, function() {
|
||||
|
||||
console.log(FC.CONFIG.armingDisableFlags);
|
||||
|
||||
$('#initialSetupArmingAllowed').toggle(FC.CONFIG.armingDisableFlags == 0);
|
||||
|
||||
|
|
|
@ -44,25 +44,18 @@ class EscProtocols
|
|||
EscProtocols.PROTOCOL_ONESHOT125,
|
||||
EscProtocols.PROTOCOL_ONESHOT42,
|
||||
EscProtocols.PROTOCOL_MULTISHOT,
|
||||
EscProtocols.PROTOCOL_BRUSHED,
|
||||
EscProtocols.PROTOCOL_DSHOT150,
|
||||
EscProtocols.PROTOCOL_DSHOT300,
|
||||
EscProtocols.PROTOCOL_DSHOT600,
|
||||
];
|
||||
|
||||
if (semver.gte(apiVersion, "1.20.0")) {
|
||||
escProtocols.push(EscProtocols.PROTOCOL_BRUSHED);
|
||||
}
|
||||
|
||||
if (semver.gte(apiVersion, API_VERSION_1_31)) {
|
||||
escProtocols.push(EscProtocols.PROTOCOL_DSHOT150);
|
||||
escProtocols.push(EscProtocols.PROTOCOL_DSHOT300);
|
||||
escProtocols.push(EscProtocols.PROTOCOL_DSHOT600);
|
||||
|
||||
if (semver.lt(apiVersion, API_VERSION_1_42)) {
|
||||
escProtocols.push(EscProtocols.PROTOCOL_DSHOT1200);
|
||||
}
|
||||
}
|
||||
|
||||
if (semver.gte(apiVersion, API_VERSION_1_36)) {
|
||||
escProtocols.push(EscProtocols.PROTOCOL_PROSHOT1000);
|
||||
}
|
||||
|
||||
if (semver.gte(apiVersion, API_VERSION_1_43)) {
|
||||
escProtocols.push(EscProtocols.PROTOCOL_DISABLED);
|
||||
|
@ -73,22 +66,7 @@ class EscProtocols
|
|||
|
||||
static ReorderPwmProtocols(apiVersion, protocolIndex)
|
||||
{
|
||||
let result = protocolIndex;
|
||||
|
||||
if (semver.lt(apiVersion, "1.26.0")) {
|
||||
switch (protocolIndex) {
|
||||
case 5:
|
||||
result = 7;
|
||||
break;
|
||||
case 7:
|
||||
result = 5;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return protocolIndex;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,21 +44,19 @@ export function checkChromeRuntimeError() {
|
|||
}
|
||||
|
||||
const majorFirmwareVersions = {
|
||||
"1.45": "4.4.*",
|
||||
"1.44": "4.3.*",
|
||||
"1.43": "4.2.*",
|
||||
"1.42": "4.1.*",
|
||||
"1.41": "4.0.*",
|
||||
"1.40": "3.5.*",
|
||||
"1.39": "3.4.*",
|
||||
"1.37": "3.3.0",
|
||||
"1.36": "3.2.*",
|
||||
"1.31": "3.1.0",
|
||||
};
|
||||
|
||||
export function generateVirtualApiVersions() {
|
||||
const firmwareVersionDropdown = document.getElementById("firmware-version-dropdown");
|
||||
const max = semver.minor(CONFIGURATOR.API_VERSION_MAX_SUPPORTED);
|
||||
const min = semver.minor(CONFIGURATOR.API_VERSION_ACCEPTED);
|
||||
|
||||
for (let i = max; i > 0; i--) {
|
||||
for (let i = max; i >= min; i--) {
|
||||
const option = document.createElement("option");
|
||||
const verNum = `1.${i}`;
|
||||
option.value = `${verNum}.0`;
|
||||
|
@ -73,13 +71,9 @@ export function generateVirtualApiVersions() {
|
|||
firmwareVersionDropdown.appendChild(option);
|
||||
}
|
||||
}
|
||||
export function getMixerImageSrc(mixerIndex, reverseMotorDir, apiVersion)
|
||||
{
|
||||
let reverse = "";
|
||||
|
||||
if (semver.gte(apiVersion, API_VERSION_1_36)) {
|
||||
reverse = reverseMotorDir ? "_reversed" : "";
|
||||
}
|
||||
export function getMixerImageSrc(mixerIndex, reverseMotorDir) {
|
||||
const reverse = reverseMotorDir ? "_reversed" : "";
|
||||
|
||||
return `./resources/motor_order/${mixerList[mixerIndex - 1].image}${reverse}.svg`;
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
<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>
|
||||
|
|
|
@ -152,6 +152,22 @@
|
|||
</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>
|
||||
|
|
Loading…
Reference in New Issue