diff --git a/js/configurator_main.js b/js/configurator_main.js
index ce2e56345..4ca94c2d6 100644
--- a/js/configurator_main.js
+++ b/js/configurator_main.js
@@ -24,6 +24,7 @@ const update = require('./globalUpdates');
const appUpdater = require('./appUpdater');
const CliAutoComplete = require('./CliAutoComplete');
const { SITLProcess } = require('./sitl');
+const settingsCache = require('./settingsCache');
process.on('uncaughtException', function (error) {
if (process.env.NODE_ENV !== 'development') {
@@ -385,6 +386,9 @@ $(function() {
$('#demoModeReset').on('click', function () {
SITLProcess.deleteEepromFile('demo.bin');
});
+ $('#maintenanceFlushSettingsCache').on('click', function () {
+ settingsCache.flush();
+ });
function close_and_cleanup(e) {
if (e.type == 'click' && !$.contains($('div#options-window')[0], e.target) || e.type == 'keyup' && e.keyCode == 27) {
$(document).unbind('click keyup', close_and_cleanup);
diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js
index da345350a..06557eb70 100644
--- a/js/defaults_dialog.js
+++ b/js/defaults_dialog.js
@@ -11,6 +11,10 @@ const periodicStatusUpdater = require('./periodicStatusUpdater');
const { mixer } = require('./model');
const jBox = require('./libraries/jBox/jBox.min');
const i18n = require('./localization');
+const defaultsDialogData = require('./defaults_dialog_entries.js');
+const Settings = require('./settings.js');
+const wizardUiBindings = require('./wizard_ui_bindings');
+const wizardSaveFramework = require('./wizard_save_framework');
var savingDefaultsModal;
@@ -21,877 +25,7 @@ var defaultsDialog = (function () {
let $container;
- let data = [
- {
- "title": 'Mini Quad with 3" propellers',
- "id": 6,
- "notRecommended": false,
- "reboot": true,
- "mixerToApply": 3,
- "settings": [
- {
- key: "model_preview_type",
- value: 3
- },
- /*
- System
- */
- {
- key: "gyro_hardware_lpf",
- value: "256HZ"
- },
- {
- key: "looptime",
- value: 500
- },
- {
- key: "motor_pwm_protocol",
- value: "DSHOT300"
- },
- /*
- Ez Tune setup
- */
- {
- key: "ez_enabled",
- value: "ON"
- },
- {
- key: "ez_filter_hz",
- value: 90
- },
- {
- key: "ez_axis_ratio",
- value: 116
- },
- {
- key: "ez_response",
- value: 71
- },
- {
- key: "ez_damping",
- value: 103
- },
- {
- key: "ez_stability",
- value: 105
- },
- {
- key: "ez_aggressiveness",
- value: 100
- },
- {
- key: "ez_rate",
- value: 134
- },
- {
- key: "ez_expo",
- value: 118
- },
- /*
- Mechanics
- */
- {
- key: "airmode_type",
- value: "THROTTLE_THRESHOLD"
- },
- {
- key: "airmode_throttle_threshold",
- value: 1150
- },
- {
- key: "mc_iterm_relax",
- value: "RP"
- },
- {
- key: "d_boost_min",
- value: 1.0
- },
- {
- key: "d_boost_max",
- value: 1.0
- },
- {
- key: "antigravity_gain",
- value: 2
- },
- {
- key: "antigravity_accelerator",
- value: 5
- },
- /*
- * TPA
- */
- {
- key: "tpa_rate",
- value: 20
- },
- {
- key: "tpa_breakpoint",
- value: 1200
- },
- {
- key: "platform_type",
- value: "MULTIROTOR"
- },
- {
- key: "applied_defaults",
- value: 6
- },
- {
- key: "failsafe_procedure",
- value: "DROP"
- }
- ]
- },
- {
- "title": 'Mini Quad with 5" propellers',
- "id": 2,
- "notRecommended": false,
- "reboot": true,
- "mixerToApply": 3,
- "settings": [
- {
- key: "model_preview_type",
- value: 3
- },
- /*
- System
- */
- {
- key: "gyro_hardware_lpf",
- value: "256HZ"
- },
- {
- key: "looptime",
- value: 500
- },
- {
- key: "motor_pwm_protocol",
- value: "DSHOT300"
- },
- /*
- Ez Tune setup
- */
- {
- key: "ez_enabled",
- value: "ON"
- },
- {
- key: "ez_filter_hz",
- value: 110
- },
- {
- key: "ez_axis_ratio",
- value: 110
- },
- {
- key: "ez_response",
- value: 92
- },
- {
- key: "ez_damping",
- value: 108
- },
- {
- key: "ez_stability",
- value: 110
- },
- {
- key: "ez_aggressiveness",
- value: 80
- },
- {
- key: "ez_rate",
- value: 134
- },
- {
- key: "ez_expo",
- value: 118
- },
- /*
- Dynamic gyro LPF
- */
- {
- key: "gyro_use_dyn_lpf",
- value: "ON"
- },
- {
- key: "gyro_dyn_lpf_min_hz",
- value: 85
- },
- {
- key: "gyro_dyn_lpf_max_hz",
- value: 300
- },
- {
- key: "gyro_dyn_lpf_curve_expo",
- value: 3
- },
- /*
- Mechanics
- */
- {
- key: "airmode_type",
- value: "THROTTLE_THRESHOLD"
- },
- {
- key: "airmode_throttle_threshold",
- value: 1150
- },
- {
- key: "mc_iterm_relax",
- value: "RP"
- },
- {
- key: "d_boost_min",
- value: 1.0
- },
- {
- key: "d_boost_max",
- value: 1.0
- },
- {
- key: "antigravity_gain",
- value: 2
- },
- {
- key: "antigravity_accelerator",
- value: 5
- },
- /*
- * TPA
- */
- {
- key: "tpa_rate",
- value: 20
- },
- {
- key: "tpa_breakpoint",
- value: 1200
- },
- {
- key: "platform_type",
- value: "MULTIROTOR"
- },
- {
- key: "applied_defaults",
- value: 2
- },
- {
- key: "failsafe_procedure",
- value: "DROP"
- }
- ]
- },
- {
- "title": 'Mini Quad with 7" propellers',
- "id": 5,
- "notRecommended": false,
- "reboot": true,
- "mixerToApply": 3,
- "settings": [
- {
- key: "model_preview_type",
- value: 3
- },
- /*
- System
- */
- {
- key: "gyro_hardware_lpf",
- value: "256HZ"
- },
- {
- key: "looptime",
- value: 500
- },
- {
- key: "motor_pwm_protocol",
- value: "DSHOT300"
- },
- /*
- Ez Tune setup
- */
- {
- key: "ez_enabled",
- value: "ON"
- },
- {
- key: "ez_filter_hz",
- value: 90
- },
- {
- key: "ez_axis_ratio",
- value: 110
- },
- {
- key: "ez_response",
- value: 101
- },
- {
- key: "ez_damping",
- value: 115
- },
- {
- key: "ez_stability",
- value: 100
- },
- {
- key: "ez_aggressiveness",
- value: 100
- },
- {
- key: "ez_rate",
- value: 134
- },
- {
- key: "ez_expo",
- value: 118
- },
- /*
- Mechanics
- */
- {
- key: "airmode_type",
- value: "THROTTLE_THRESHOLD"
- },
- {
- key: "airmode_throttle_threshold",
- value: 1150
- },
- {
- key: "mc_iterm_relax",
- value: "RPY"
- },
- {
- key: "d_boost_min",
- value: 0.8
- },
- {
- key: "d_boost_max",
- value: 1.2
- },
- {
- key: "antigravity_gain",
- value: 2
- },
- {
- key: "antigravity_accelerator",
- value: 5
- },
- /*
- * TPA
- */
- {
- key: "tpa_rate",
- value: 20
- },
- {
- key: "tpa_breakpoint",
- value: 1200
- },
- {
- key: "platform_type",
- value: "MULTIROTOR"
- },
- {
- key: "applied_defaults",
- value: 5
- },
- {
- key: "failsafe_procedure",
- value: "DROP"
- }
- ]
- },
- {
- "title": 'Airplane with a Tail',
- "notRecommended": false,
- "id": 3,
- "reboot": true,
- "mixerToApply": 14,
- "settings": [
- {
- key: "model_preview_type",
- value: 14
- },
- {
- key: "platform_type",
- value: "AIRPLANE"
- },
- {
- key: "applied_defaults",
- value: 3
- },
- {
- key: "gyro_hardware_lpf",
- value: "256HZ"
- },
- {
- key: "gyro_main_lpf_hz",
- value: 25
- },
- {
- key: "dterm_lpf_hz",
- value: 10
- },
- {
- key: "d_boost_min",
- value: 1
- },
- {
- key: "d_boost_max",
- value: 1
- },
- {
- key: "dynamic_gyro_notch_enabled",
- value: "ON"
- },
- {
- key: "dynamic_gyro_notch_q",
- value: 250
- },
- {
- key: "dynamic_gyro_notch_min_hz",
- value: 30
- },
- {
- key: "motor_pwm_protocol",
- value: "STANDARD"
- },
- {
- key: "ahrs_inertia_comp_method",
- value: "ADAPTIVE"
- },
- {
- key: "throttle_idle",
- value: 5.0
- },
- {
- key: "rc_yaw_expo",
- value: 30
- },
- {
- key: "rc_expo",
- value: 30
- },
- {
- key: "roll_rate",
- value: 18
- },
- {
- key: "pitch_rate",
- value: 9
- },
- {
- key: "yaw_rate",
- value: 3
- },
- {
- key: "nav_fw_pos_z_p",
- value: 25
- },
- {
- key: "nav_fw_pos_z_i",
- value: 5
- },
- {
- key: "nav_fw_pos_z_d",
- value: 8
- },
- {
- key: "nav_fw_pos_xy_p",
- value: 55
- },
- {
- key: "fw_turn_assist_pitch_gain",
- value: 0.4
- },
- {
- key: "max_angle_inclination_rll",
- value: 450
- },
- {
- key: "nav_fw_bank_angle",
- value: 35
- },
- {
- key: "fw_p_pitch",
- value: 15
- },
- {
- key: "fw_i_pitch",
- value: 5
- },
- {
- key: "fw_d_pitch",
- value: 5
- },
- {
- key: "fw_ff_pitch",
- value: 80
- },
- {
- key: "fw_p_roll",
- value: 15
- },
- {
- key: "fw_i_roll",
- value: 3
- },
- {
- key: "fw_d_roll",
- value: 7
- },
- {
- key: "fw_ff_roll",
- value: 50
- },
- {
- key: "fw_p_yaw",
- value: 50
- },
- {
- key: "fw_i_yaw",
- value: 0
- },
- {
- key: "fw_d_yaw",
- value: 20
- },
- {
- key: "fw_ff_yaw",
- value: 255
- },
- {
- key: "airmode_type",
- value: "STICK_CENTER_ONCE"
- },
- {
- key: "small_angle",
- value: 180
- },
- {
- key: "nav_fw_control_smoothness",
- value: 2
- },
- {
- key: "nav_rth_allow_landing",
- value: "FS_ONLY"
- },
- {
- key: "nav_rth_altitude",
- value: 5000
- },
- {
- key: "nav_wp_radius",
- value: 800
- },
- {
- key: "nav_wp_max_safe_distance",
- value: 500
- },
- {
- key: "nav_fw_launch_max_angle",
- value: 45
- },
- {
- key: "nav_fw_launch_motor_delay",
- value: 100
- },
- {
- key: "nav_fw_launch_max_altitude",
- value: 5000
- },
- {
- key: "nav_fw_launch_climb_angle",
- value: 25
- },
- ],
- },
- {
- "title": 'Airplane without a Tail (Wing, Delta, etc)',
- "notRecommended": false,
- "id": 4,
- "reboot": true,
- "mixerToApply": 8,
- "settings": [
- {
- key: "model_preview_type",
- value: 8
- },
- {
- key: "platform_type",
- value: "AIRPLANE"
- },
- {
- key: "applied_defaults",
- value: 4
- },
- {
- key: "gyro_hardware_lpf",
- value: "256HZ"
- },
- {
- key: "gyro_main_lpf_hz",
- value: 25
- },
- {
- key: "dterm_lpf_hz",
- value: 10
- },
- {
- key: "d_boost_min",
- value: 1
- },
- {
- key: "d_boost_max",
- value: 1
- },
- {
- key: "dynamic_gyro_notch_enabled",
- value: "ON"
- },
- {
- key: "dynamic_gyro_notch_q",
- value: 250
- },
- {
- key: "dynamic_gyro_notch_min_hz",
- value: 30
- },
- {
- key: "motor_pwm_protocol",
- value: "STANDARD"
- },
- {
- key: "ahrs_inertia_comp_method",
- value: "ADAPTIVE"
- },
- {
- key: "throttle_idle",
- value: 5.0
- },
- {
- key: "rc_yaw_expo",
- value: 30
- },
- {
- key: "rc_expo",
- value: 30
- },
- {
- key: "roll_rate",
- value: 18
- },
- {
- key: "pitch_rate",
- value: 9
- },
- {
- key: "yaw_rate",
- value: 3
- },
- {
- key: "nav_fw_pos_z_p",
- value: 35
- },
- {
- key: "nav_fw_pos_z_i",
- value: 5
- },
- {
- key: "nav_fw_pos_z_d",
- value: 10
- },
- {
- key: "nav_fw_pos_xy_p",
- value: 70
- },
- {
- key: "fw_turn_assist_pitch_gain",
- value: 0.3
- },
- {
- key: "max_angle_inclination_rll",
- value: 550
- },
- {
- key: "nav_fw_bank_angle",
- value: 45
- },
- {
- key: "fw_p_pitch",
- value: 15
- },
- {
- key: "fw_i_pitch",
- value: 5
- },
- {
- key: "fw_d_pitch",
- value: 5
- },
- {
- key: "fw_ff_pitch",
- value: 70
- },
- {
- key: "fw_p_roll",
- value: 15
- },
- {
- key: "fw_i_roll",
- value: 3
- },
- {
- key: "fw_d_roll",
- value: 7
- },
- {
- key: "fw_ff_roll",
- value: 50
- },
- {
- key: "fw_p_yaw",
- value: 20
- },
- {
- key: "fw_i_yaw",
- value: 0
- },
- {
- key: "fw_d_yaw",
- value: 0
- },
- {
- key: "fw_ff_yaw",
- value: 100
- },
- {
- key: "airmode_type",
- value: "STICK_CENTER_ONCE"
- },
- {
- key: "small_angle",
- value: 180
- },
- {
- key: "nav_fw_control_smoothness",
- value: 2
- },
- {
- key: "nav_rth_allow_landing",
- value: "FS_ONLY"
- },
- {
- key: "nav_rth_altitude",
- value: 5000
- },
- {
- key: "nav_wp_radius",
- value: 1000
- },
- {
- key: "nav_wp_max_safe_distance",
- value: 500
- },
- {
- key: "nav_fw_launch_max_angle",
- value: 75
- },
- {
- key: "nav_fw_launch_motor_delay",
- value: 100
- },
- {
- key: "nav_fw_launch_max_altitude",
- value: 5000
- },
- {
- key: "nav_fw_launch_climb_angle",
- value: 25
- },
- ],
- },
- {
- "title": 'Rovers & Boats',
- "id": 1,
- "notRecommended": false,
- "reboot": true,
- "mixerToApply": 31,
- "settings": [
- {
- key: "model_preview_type",
- value: 31
- },
- {
- key: "gyro_hardware_lpf",
- value: "256HZ"
- },
- {
- key: "gyro_main_lpf_hz",
- value: 10
- },
- {
- key: "motor_pwm_protocol",
- value: "STANDARD"
- },
- {
- key: "applied_defaults",
- value: 1
- },
- {
- key: "failsafe_procedure",
- value: "DROP"
- },
- {
- key: "platform_type",
- value: "ROVER"
- },
- {
- key: "nav_wp_max_safe_distance",
- value: 500
- },
- {
- key: "nav_fw_loiter_radius",
- value: 100
- },
- {
- key: "nav_fw_yaw_deadband",
- value: 5
- },
- {
- key: "pidsum_limit_yaw",
- value: 500
- },
- {
- key: "nav_fw_pos_hdg_p",
- value: 60
- },
- {
- key: "nav_fw_pos_hdg_i",
- value: 2
- },
- {
- key: "nav_fw_pos_hdg_d",
- value: 0
- }
- ]
- },
- {
- "title": 'Keep current settings (Not recommended)',
- "id": 0,
- "notRecommended": true,
- "reboot": false,
- "settings": [
- {
- key: "applied_defaults",
- value: 1
- }
- ]
- }
- ]
+ privateScope.wizardSettings = [];
publicScope.init = function () {
mspHelper.getSetting("applied_defaults").then(privateScope.onInitSettingReturned);
@@ -919,26 +53,121 @@ var defaultsDialog = (function () {
}
};
- privateScope.finalize = function (selectedDefaultPreset) {
- mspHelper.saveToEeprom(function () {
- //noinspection JSUnresolvedVariable
- GUI.log(i18n.getMessage('configurationEepromSaved'));
+ privateScope.saveWizardStep = function (selectedDefaultPreset, wizardStep) {
+ const steps = selectedDefaultPreset.wizardPages;
+ const stepName = steps[wizardStep];
+
+ if (stepName == "receiver") {
+ let $receiverPort = $container.find('#wizard-receiver-port');
+ let receiverPort = $receiverPort.val();
+
+ if (receiverPort != "-1") {
+ privateScope.wizardSettings.push({
+ name: "receiverPort",
+ value: receiverPort
+ });
+ }
+
+ privateScope.wizardSettings.push({
+ name: "receiverProtocol",
+ value: $container.find('#wizard-receiver-protocol option:selected').text()
+ });
+ }
+
+ privateScope.wizard(selectedDefaultPreset, wizardStep + 1);
+ };
+
+ privateScope.wizard = function (selectedDefaultPreset, wizardStep) {
+
+ const steps = selectedDefaultPreset.wizardPages;
+ const stepsCount = selectedDefaultPreset.wizardPages.length;
+ const stepName = steps[wizardStep];
+
+ if (wizardStep >= stepsCount) {
+ //This is the last step, time to finalize
+ $container.hide();
+
+ wizardSaveFramework.persist(privateScope.wizardSettings, function () {
+ mspHelper.saveToEeprom(function () {
+ //noinspection JSUnresolvedVariable
+ GUI.log(i18n.getMessage('configurationEepromSaved'));
+ if (selectedDefaultPreset.reboot) {
+ privateScope.reboot();
+ }
+ });
+ });
+ } else {
+ const $content = $container.find('.defaults-dialog__wizard');
+
+ $content.unbind();
+
+ $.get("./wizard/" + stepName + ".html", function (data) {
+ $content.html("");
+ $(data).appendTo($content);
+
+ $.get("./wizard/buttons.html", function (data) {
+ $(data).appendTo($content);
+
+ $content.on('click', '#wizard-next', function () {
+ privateScope.saveWizardStep(selectedDefaultPreset, wizardStep);
+ });
+
+ $content.on('click', '#wizard-skip', function () {
+ privateScope.wizard(selectedDefaultPreset, wizardStep + 1);
+ });
+
+ if (stepName == "receiver") {
+ /**
+ * Bindings executed when the receiver wizard tab is loaded
+ */
+ wizardUiBindings.receiver($content);
+ }
+
+ Settings.configureInputs().then(
+ function () {
+ console.log('configure done');
+ $container.find('.defaults-dialog__content').hide();
+ $container.find('.defaults-dialog__wizard').show();
- if (selectedDefaultPreset.reboot) {
- GUI.tab_switch_cleanup(function () {
- MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
- //noinspection JSUnresolvedVariable
- if (typeof savingDefaultsModal !== 'undefined') {
savingDefaultsModal.close();
+ $container.show();
}
- GUI.log(i18n.getMessage('deviceRebooting'));
- GUI.handleReconnect();
- });
+ );
});
- }
+ });
+ }
+
+ };
+
+ privateScope.reboot = function () {
+
+ GUI.tab_switch_cleanup(function () {
+ MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
+ //noinspection JSUnresolvedVariable
+ if (typeof savingDefaultsModal !== 'undefined') {
+ savingDefaultsModal.close();
+ }
+ GUI.log(i18n.getMessage('deviceRebooting'));
+ GUI.handleReconnect();
+ });
});
};
+ privateScope.finalize = function (selectedDefaultPreset) {
+
+ if (selectedDefaultPreset.wizardPages) {
+ privateScope.wizard(selectedDefaultPreset, 0);
+ } else {
+ mspHelper.saveToEeprom(function () {
+ //noinspection JSUnresolvedVariable
+ GUI.log(i18n.getMessage('configurationEepromSaved'));
+ if (selectedDefaultPreset.reboot) {
+ privateScope.reboot();
+ }
+ });
+ }
+ };
+
privateScope.setSettings = function (selectedDefaultPreset) {
periodicStatusUpdater.stop();
@@ -1076,28 +305,30 @@ var defaultsDialog = (function () {
$container.hide();
- let selectedDefaultPreset = data[$(event.currentTarget).data("index")];
+ let selectedDefaultPreset = defaultsDialogData[$(event.currentTarget).data("index")];
if (selectedDefaultPreset && selectedDefaultPreset.settings) {
if (selectedDefaultPreset.id == 0) {
// Close applying preset dialog if keeping current settings.
- savingDefaultsModal.close();
+ savingDefaultsModal.close();
}
mspHelper.loadFeatures(function () {
privateScope.setFeaturesBits(selectedDefaultPreset)
});
} else {
- savingDefaultsModal.close();
+ savingDefaultsModal.close();
}
};
privateScope.render = function () {
+ $container.find('.defaults-dialog__content').show();
+ $container.find('.defaults-dialog__wizard').hide();
let $place = $container.find('.defaults-dialog__options');
$place.html("");
- for (let i in data) {
- if (data.hasOwnProperty(i)) {
- let preset = data[i];
+ for (let i in defaultsDialogData) {
+ if (defaultsDialogData.hasOwnProperty(i)) {
+ let preset = defaultsDialogData[i];
let $element = $("
")
@@ -1114,6 +345,7 @@ var defaultsDialog = (function () {
}
privateScope.onInitSettingReturned = function (promise) {
+
if (promise.value > 0) {
return; //Defaults were applied, we can just ignore
}
diff --git a/js/defaults_dialog_entries.js b/js/defaults_dialog_entries.js
new file mode 100644
index 000000000..7bc3d0eea
--- /dev/null
+++ b/js/defaults_dialog_entries.js
@@ -0,0 +1,881 @@
+'use strict';
+
+var defaultsDialogData = [
+ {
+ "title": 'Mini Quad with 3" propellers',
+ "id": 6,
+ "notRecommended": false,
+ "reboot": true,
+ "mixerToApply": 3,
+ "wizardPages": ['receiver'],
+ "settings": [
+ {
+ key: "model_preview_type",
+ value: 3
+ },
+ /*
+ System
+ */
+ {
+ key: "gyro_hardware_lpf",
+ value: "256HZ"
+ },
+ {
+ key: "looptime",
+ value: 500
+ },
+ {
+ key: "motor_pwm_protocol",
+ value: "DSHOT300"
+ },
+ /*
+ Ez Tune setup
+ */
+ {
+ key: "ez_enabled",
+ value: "ON"
+ },
+ {
+ key: "ez_filter_hz",
+ value: 90
+ },
+ {
+ key: "ez_axis_ratio",
+ value: 116
+ },
+ {
+ key: "ez_response",
+ value: 71
+ },
+ {
+ key: "ez_damping",
+ value: 103
+ },
+ {
+ key: "ez_stability",
+ value: 105
+ },
+ {
+ key: "ez_aggressiveness",
+ value: 100
+ },
+ {
+ key: "ez_rate",
+ value: 134
+ },
+ {
+ key: "ez_expo",
+ value: 118
+ },
+ /*
+ Mechanics
+ */
+ {
+ key: "airmode_type",
+ value: "THROTTLE_THRESHOLD"
+ },
+ {
+ key: "airmode_throttle_threshold",
+ value: 1150
+ },
+ {
+ key: "mc_iterm_relax",
+ value: "RP"
+ },
+ {
+ key: "d_boost_min",
+ value: 1.0
+ },
+ {
+ key: "d_boost_max",
+ value: 1.0
+ },
+ {
+ key: "antigravity_gain",
+ value: 2
+ },
+ {
+ key: "antigravity_accelerator",
+ value: 5
+ },
+ /*
+ * TPA
+ */
+ {
+ key: "tpa_rate",
+ value: 20
+ },
+ {
+ key: "tpa_breakpoint",
+ value: 1200
+ },
+ {
+ key: "platform_type",
+ value: "MULTIROTOR"
+ },
+ {
+ key: "applied_defaults",
+ value: 6
+ },
+ {
+ key: "failsafe_procedure",
+ value: "DROP"
+ }
+ ]
+ },
+ {
+ "title": 'Mini Quad with 5" propellers',
+ "id": 2,
+ "notRecommended": false,
+ "reboot": true,
+ "mixerToApply": 3,
+ "wizardPages": ['receiver'],
+ "settings": [
+ {
+ key: "model_preview_type",
+ value: 3
+ },
+ /*
+ System
+ */
+ {
+ key: "gyro_hardware_lpf",
+ value: "256HZ"
+ },
+ {
+ key: "looptime",
+ value: 500
+ },
+ {
+ key: "motor_pwm_protocol",
+ value: "DSHOT300"
+ },
+ /*
+ Ez Tune setup
+ */
+ {
+ key: "ez_enabled",
+ value: "ON"
+ },
+ {
+ key: "ez_filter_hz",
+ value: 110
+ },
+ {
+ key: "ez_axis_ratio",
+ value: 110
+ },
+ {
+ key: "ez_response",
+ value: 92
+ },
+ {
+ key: "ez_damping",
+ value: 108
+ },
+ {
+ key: "ez_stability",
+ value: 110
+ },
+ {
+ key: "ez_aggressiveness",
+ value: 80
+ },
+ {
+ key: "ez_rate",
+ value: 134
+ },
+ {
+ key: "ez_expo",
+ value: 118
+ },
+ /*
+ Dynamic gyro LPF
+ */
+ {
+ key: "gyro_use_dyn_lpf",
+ value: "ON"
+ },
+ {
+ key: "gyro_dyn_lpf_min_hz",
+ value: 85
+ },
+ {
+ key: "gyro_dyn_lpf_max_hz",
+ value: 300
+ },
+ {
+ key: "gyro_dyn_lpf_curve_expo",
+ value: 3
+ },
+ /*
+ Mechanics
+ */
+ {
+ key: "airmode_type",
+ value: "THROTTLE_THRESHOLD"
+ },
+ {
+ key: "airmode_throttle_threshold",
+ value: 1150
+ },
+ {
+ key: "mc_iterm_relax",
+ value: "RP"
+ },
+ {
+ key: "d_boost_min",
+ value: 1.0
+ },
+ {
+ key: "d_boost_max",
+ value: 1.0
+ },
+ {
+ key: "antigravity_gain",
+ value: 2
+ },
+ {
+ key: "antigravity_accelerator",
+ value: 5
+ },
+ /*
+ * TPA
+ */
+ {
+ key: "tpa_rate",
+ value: 20
+ },
+ {
+ key: "tpa_breakpoint",
+ value: 1200
+ },
+ {
+ key: "platform_type",
+ value: "MULTIROTOR"
+ },
+ {
+ key: "applied_defaults",
+ value: 2
+ },
+ {
+ key: "failsafe_procedure",
+ value: "DROP"
+ }
+ ]
+ },
+ {
+ "title": 'Mini Quad with 7" propellers',
+ "id": 5,
+ "notRecommended": false,
+ "reboot": true,
+ "mixerToApply": 3,
+ "wizardPages": ['receiver'],
+ "settings": [
+ {
+ key: "model_preview_type",
+ value: 3
+ },
+ /*
+ System
+ */
+ {
+ key: "gyro_hardware_lpf",
+ value: "256HZ"
+ },
+ {
+ key: "looptime",
+ value: 500
+ },
+ {
+ key: "motor_pwm_protocol",
+ value: "DSHOT300"
+ },
+ /*
+ Ez Tune setup
+ */
+ {
+ key: "ez_enabled",
+ value: "ON"
+ },
+ {
+ key: "ez_filter_hz",
+ value: 90
+ },
+ {
+ key: "ez_axis_ratio",
+ value: 110
+ },
+ {
+ key: "ez_response",
+ value: 101
+ },
+ {
+ key: "ez_damping",
+ value: 115
+ },
+ {
+ key: "ez_stability",
+ value: 100
+ },
+ {
+ key: "ez_aggressiveness",
+ value: 100
+ },
+ {
+ key: "ez_rate",
+ value: 134
+ },
+ {
+ key: "ez_expo",
+ value: 118
+ },
+ /*
+ Mechanics
+ */
+ {
+ key: "airmode_type",
+ value: "THROTTLE_THRESHOLD"
+ },
+ {
+ key: "airmode_throttle_threshold",
+ value: 1150
+ },
+ {
+ key: "mc_iterm_relax",
+ value: "RPY"
+ },
+ {
+ key: "d_boost_min",
+ value: 0.8
+ },
+ {
+ key: "d_boost_max",
+ value: 1.2
+ },
+ {
+ key: "antigravity_gain",
+ value: 2
+ },
+ {
+ key: "antigravity_accelerator",
+ value: 5
+ },
+ /*
+ * TPA
+ */
+ {
+ key: "tpa_rate",
+ value: 20
+ },
+ {
+ key: "tpa_breakpoint",
+ value: 1200
+ },
+ {
+ key: "platform_type",
+ value: "MULTIROTOR"
+ },
+ {
+ key: "applied_defaults",
+ value: 5
+ },
+ {
+ key: "failsafe_procedure",
+ value: "DROP"
+ }
+ ]
+ },
+ {
+ "title": 'Airplane with a Tail',
+ "notRecommended": false,
+ "id": 3,
+ "reboot": true,
+ "mixerToApply": 14,
+ "wizardPages": ['receiver'],
+ "settings": [
+ {
+ key: "model_preview_type",
+ value: 14
+ },
+ {
+ key: "platform_type",
+ value: "AIRPLANE"
+ },
+ {
+ key: "applied_defaults",
+ value: 3
+ },
+ {
+ key: "gyro_hardware_lpf",
+ value: "256HZ"
+ },
+ {
+ key: "gyro_main_lpf_hz",
+ value: 25
+ },
+ {
+ key: "dterm_lpf_hz",
+ value: 10
+ },
+ {
+ key: "d_boost_min",
+ value: 1
+ },
+ {
+ key: "d_boost_max",
+ value: 1
+ },
+ {
+ key: "dynamic_gyro_notch_enabled",
+ value: "ON"
+ },
+ {
+ key: "dynamic_gyro_notch_q",
+ value: 250
+ },
+ {
+ key: "dynamic_gyro_notch_min_hz",
+ value: 30
+ },
+ {
+ key: "motor_pwm_protocol",
+ value: "STANDARD"
+ },
+ {
+ key: "ahrs_inertia_comp_method",
+ value: "ADAPTIVE"
+ },
+ {
+ key: "throttle_idle",
+ value: 5.0
+ },
+ {
+ key: "rc_yaw_expo",
+ value: 30
+ },
+ {
+ key: "rc_expo",
+ value: 30
+ },
+ {
+ key: "roll_rate",
+ value: 18
+ },
+ {
+ key: "pitch_rate",
+ value: 9
+ },
+ {
+ key: "yaw_rate",
+ value: 3
+ },
+ {
+ key: "nav_fw_pos_z_p",
+ value: 25
+ },
+ {
+ key: "nav_fw_pos_z_i",
+ value: 5
+ },
+ {
+ key: "nav_fw_pos_z_d",
+ value: 8
+ },
+ {
+ key: "nav_fw_pos_xy_p",
+ value: 55
+ },
+ {
+ key: "fw_turn_assist_pitch_gain",
+ value: 0.4
+ },
+ {
+ key: "max_angle_inclination_rll",
+ value: 450
+ },
+ {
+ key: "nav_fw_bank_angle",
+ value: 35
+ },
+ {
+ key: "fw_p_pitch",
+ value: 15
+ },
+ {
+ key: "fw_i_pitch",
+ value: 5
+ },
+ {
+ key: "fw_d_pitch",
+ value: 5
+ },
+ {
+ key: "fw_ff_pitch",
+ value: 80
+ },
+ {
+ key: "fw_p_roll",
+ value: 15
+ },
+ {
+ key: "fw_i_roll",
+ value: 3
+ },
+ {
+ key: "fw_d_roll",
+ value: 7
+ },
+ {
+ key: "fw_ff_roll",
+ value: 50
+ },
+ {
+ key: "fw_p_yaw",
+ value: 50
+ },
+ {
+ key: "fw_i_yaw",
+ value: 0
+ },
+ {
+ key: "fw_d_yaw",
+ value: 20
+ },
+ {
+ key: "fw_ff_yaw",
+ value: 255
+ },
+ {
+ key: "airmode_type",
+ value: "STICK_CENTER_ONCE"
+ },
+ {
+ key: "small_angle",
+ value: 180
+ },
+ {
+ key: "nav_fw_control_smoothness",
+ value: 2
+ },
+ {
+ key: "nav_rth_allow_landing",
+ value: "FS_ONLY"
+ },
+ {
+ key: "nav_rth_altitude",
+ value: 5000
+ },
+ {
+ key: "nav_wp_radius",
+ value: 800
+ },
+ {
+ key: "nav_wp_max_safe_distance",
+ value: 500
+ },
+ {
+ key: "nav_fw_launch_max_angle",
+ value: 45
+ },
+ {
+ key: "nav_fw_launch_motor_delay",
+ value: 100
+ },
+ {
+ key: "nav_fw_launch_max_altitude",
+ value: 5000
+ },
+ {
+ key: "nav_fw_launch_climb_angle",
+ value: 25
+ },
+ ],
+ },
+ {
+ "title": 'Airplane without a Tail (Wing, Delta, etc)',
+ "notRecommended": false,
+ "id": 4,
+ "reboot": true,
+ "mixerToApply": 8,
+ "wizardPages": ['receiver'],
+ "settings": [
+ {
+ key: "model_preview_type",
+ value: 8
+ },
+ {
+ key: "platform_type",
+ value: "AIRPLANE"
+ },
+ {
+ key: "applied_defaults",
+ value: 4
+ },
+ {
+ key: "gyro_hardware_lpf",
+ value: "256HZ"
+ },
+ {
+ key: "gyro_main_lpf_hz",
+ value: 25
+ },
+ {
+ key: "dterm_lpf_hz",
+ value: 10
+ },
+ {
+ key: "d_boost_min",
+ value: 1
+ },
+ {
+ key: "d_boost_max",
+ value: 1
+ },
+ {
+ key: "dynamic_gyro_notch_enabled",
+ value: "ON"
+ },
+ {
+ key: "dynamic_gyro_notch_q",
+ value: 250
+ },
+ {
+ key: "dynamic_gyro_notch_min_hz",
+ value: 30
+ },
+ {
+ key: "motor_pwm_protocol",
+ value: "STANDARD"
+ },
+ {
+ key: "ahrs_inertia_comp_method",
+ value: "ADAPTIVE"
+ },
+ {
+ key: "throttle_idle",
+ value: 5.0
+ },
+ {
+ key: "rc_yaw_expo",
+ value: 30
+ },
+ {
+ key: "rc_expo",
+ value: 30
+ },
+ {
+ key: "roll_rate",
+ value: 18
+ },
+ {
+ key: "pitch_rate",
+ value: 9
+ },
+ {
+ key: "yaw_rate",
+ value: 3
+ },
+ {
+ key: "nav_fw_pos_z_p",
+ value: 35
+ },
+ {
+ key: "nav_fw_pos_z_i",
+ value: 5
+ },
+ {
+ key: "nav_fw_pos_z_d",
+ value: 10
+ },
+ {
+ key: "nav_fw_pos_xy_p",
+ value: 70
+ },
+ {
+ key: "fw_turn_assist_pitch_gain",
+ value: 0.3
+ },
+ {
+ key: "max_angle_inclination_rll",
+ value: 550
+ },
+ {
+ key: "nav_fw_bank_angle",
+ value: 45
+ },
+ {
+ key: "fw_p_pitch",
+ value: 15
+ },
+ {
+ key: "fw_i_pitch",
+ value: 5
+ },
+ {
+ key: "fw_d_pitch",
+ value: 5
+ },
+ {
+ key: "fw_ff_pitch",
+ value: 70
+ },
+ {
+ key: "fw_p_roll",
+ value: 15
+ },
+ {
+ key: "fw_i_roll",
+ value: 3
+ },
+ {
+ key: "fw_d_roll",
+ value: 7
+ },
+ {
+ key: "fw_ff_roll",
+ value: 50
+ },
+ {
+ key: "fw_p_yaw",
+ value: 20
+ },
+ {
+ key: "fw_i_yaw",
+ value: 0
+ },
+ {
+ key: "fw_d_yaw",
+ value: 0
+ },
+ {
+ key: "fw_ff_yaw",
+ value: 100
+ },
+ {
+ key: "airmode_type",
+ value: "STICK_CENTER_ONCE"
+ },
+ {
+ key: "small_angle",
+ value: 180
+ },
+ {
+ key: "nav_fw_control_smoothness",
+ value: 2
+ },
+ {
+ key: "nav_rth_allow_landing",
+ value: "FS_ONLY"
+ },
+ {
+ key: "nav_rth_altitude",
+ value: 5000
+ },
+ {
+ key: "nav_wp_radius",
+ value: 1000
+ },
+ {
+ key: "nav_wp_max_safe_distance",
+ value: 500
+ },
+ {
+ key: "nav_fw_launch_max_angle",
+ value: 75
+ },
+ {
+ key: "nav_fw_launch_motor_delay",
+ value: 100
+ },
+ {
+ key: "nav_fw_launch_max_altitude",
+ value: 5000
+ },
+ {
+ key: "nav_fw_launch_climb_angle",
+ value: 25
+ },
+ ],
+ },
+ {
+ "title": 'Rovers & Boats',
+ "id": 1,
+ "notRecommended": false,
+ "reboot": true,
+ "mixerToApply": 31,
+ "wizardPages": ['receiver'],
+ "settings": [
+ {
+ key: "model_preview_type",
+ value: 31
+ },
+ {
+ key: "gyro_hardware_lpf",
+ value: "256HZ"
+ },
+ {
+ key: "gyro_main_lpf_hz",
+ value: 10
+ },
+ {
+ key: "motor_pwm_protocol",
+ value: "STANDARD"
+ },
+ {
+ key: "applied_defaults",
+ value: 1
+ },
+ {
+ key: "failsafe_procedure",
+ value: "DROP"
+ },
+ {
+ key: "platform_type",
+ value: "ROVER"
+ },
+ {
+ key: "nav_wp_max_safe_distance",
+ value: 500
+ },
+ {
+ key: "nav_fw_loiter_radius",
+ value: 100
+ },
+ {
+ key: "nav_fw_yaw_deadband",
+ value: 5
+ },
+ {
+ key: "pidsum_limit_yaw",
+ value: 500
+ },
+ {
+ key: "nav_fw_pos_hdg_p",
+ value: 60
+ },
+ {
+ key: "nav_fw_pos_hdg_i",
+ value: 2
+ },
+ {
+ key: "nav_fw_pos_hdg_d",
+ value: 0
+ }
+ ]
+ },
+ {
+ "title": 'Keep current settings (Not recommended)',
+ "id": 0,
+ "notRecommended": true,
+ "reboot": false,
+ "settings": [
+ {
+ key: "applied_defaults",
+ value: 1
+ }
+ ]
+ }
+];
+
+module.exports = defaultsDialogData;
\ No newline at end of file
diff --git a/js/fc.js b/js/fc.js
index 6ecc9486d..0d5d4861b 100644
--- a/js/fc.js
+++ b/js/fc.js
@@ -14,6 +14,7 @@ const FwApproachCollection = require('./fwApproachCollection')
const { PLATFORM } = require('./model')
const VTX = require('./vtx');
const BitHelper = require('./bitHelper');
+const { FLIGHT_MODES } = require('./flightModes');
var FC = {
@@ -28,8 +29,8 @@ var FC = {
RC_MAP: null,
RC: null,
RC_tuning: null,
- AUX_CONFIG: null,
- AUX_CONFIG_IDS: null,
+ AUX_CONFIG: [],
+ AUX_CONFIG_IDS: [],
MODE_RANGES: null,
ADJUSTMENT_RANGES: null,
SERVO_CONFIG: null,
@@ -77,7 +78,6 @@ var FC = {
MIXER_CONFIG: null,
BATTERY_CONFIG: null,
OUTPUT_MAPPING: null,
- SETTINGS: null,
BRAKING_CONFIG: null,
SAFEHOMES: null,
BOARD_ALIGNMENT: null,
@@ -85,6 +85,7 @@ var FC = {
FEATURES: null,
RATE_DYNAMICS: null,
EZ_TUNE: null,
+ FLIGHT_MODES: null,
restartRequired: false,
MAX_SERVO_RATE: 125,
@@ -198,8 +199,16 @@ var FC = {
manual_yaw_rate: 0,
};
- this.AUX_CONFIG = [];
- this.AUX_CONFIG_IDS = [];
+ this.generateAuxConfig = function () {
+ console.log('Generating AUX_CONFIG');
+ this.AUX_CONFIG = [];
+ for ( let i = 0; i < this.AUX_CONFIG_IDS.length; i++ ) {
+ let found = FLIGHT_MODES.find( mode => mode.permanentId === this.AUX_CONFIG_IDS[i] );
+ if (found) {
+ this.AUX_CONFIG.push(found.boxName);
+ }
+ }
+ };
this.MODE_RANGES = [];
this.ADJUSTMENT_RANGES = [];
@@ -560,8 +569,6 @@ var FC = {
this.OUTPUT_MAPPING = new OutputMappingCollection();
- this.SETTINGS = {};
-
this.SAFEHOMES = new SafehomeCollection();
this.RATE_DYNAMICS = {
@@ -940,11 +947,13 @@ var FC = {
return this.getServoMixInputNames()[input];
},
getModeId: function (name) {
- for (var i = 0; i < this.AUX_CONFIG.length; i++) {
- if (this.AUX_CONFIG[i] == name)
- return i;
+
+ let mode = FLIGHT_MODES.find( mode => mode.boxName === name );
+ if (mode) {
+ return mode.permanentId;
+ } else {
+ return -1;
}
- return -1;
},
isModeBitSet: function (i) {
return BitHelper.bit_check(this.CONFIG.mode[Math.trunc(i / 32)], i % 32);
diff --git a/js/flightModes.js b/js/flightModes.js
new file mode 100644
index 000000000..e725dda03
--- /dev/null
+++ b/js/flightModes.js
@@ -0,0 +1,286 @@
+'use strict';
+
+var FLIGHT_MODES = [
+ {
+ boxId: 0,
+ boxName: "ARM",
+ permanentId: 0
+ },
+ {
+ boxId: 1,
+ boxName: "ANGLE",
+ permanentId: 1
+ },
+ {
+ boxId: 2,
+ boxName: "HORIZON",
+ permanentId: 2
+ },
+ {
+ boxId: 3,
+ boxName: "NAV ALTHOLD",
+ permanentId: 3
+ },
+ {
+ boxId: 4,
+ boxName: "HEADING HOLD",
+ permanentId: 5
+ },
+ {
+ boxId: 5,
+ boxName: "HEADFREE",
+ permanentId: 6
+ },
+ {
+ boxId: 6,
+ boxName: "HEADADJ",
+ permanentId: 7
+ },
+ {
+ boxId: 7,
+ boxName: "CAMSTAB",
+ permanentId: 8
+ },
+ {
+ boxId: 8,
+ boxName: "NAV RTH",
+ permanentId: 10
+ },
+ {
+ boxId: 9,
+ boxName: "NAV POSHOLD",
+ permanentId: 11
+ },
+ {
+ boxId: 10,
+ boxName: "MANUAL",
+ permanentId: 12
+ },
+ {
+ boxId: 11,
+ boxName: "BEEPER",
+ permanentId: 13
+ },
+ {
+ boxId: 12,
+ boxName: "LEDS OFF",
+ permanentId: 15
+ },
+ {
+ boxId: 13,
+ boxName: "LIGHTS",
+ permanentId: 16
+ },
+ {
+ boxId: 15,
+ boxName: "OSD OFF",
+ permanentId: 19
+ },
+ {
+ boxId: 16,
+ boxName: "TELEMETRY",
+ permanentId: 20
+ },
+ {
+ boxId: 28,
+ boxName: "AUTO TUNE",
+ permanentId: 21
+ },
+ {
+ boxId: 17,
+ boxName: "BLACKBOX",
+ permanentId: 26
+ },
+ {
+ boxId: 18,
+ boxName: "FAILSAFE",
+ permanentId: 27
+ },
+ {
+ boxId: 19,
+ boxName: "NAV WP",
+ permanentId: 28
+ },
+ {
+ boxId: 20,
+ boxName: "AIR MODE",
+ permanentId: 29
+ },
+ {
+ boxId: 21,
+ boxName: "HOME RESET",
+ permanentId: 30
+ },
+ {
+ boxId: 22,
+ boxName: "GCS NAV",
+ permanentId: 31
+ },
+ {
+ boxId: 39,
+ boxName: "FPV ANGLE MIX",
+ permanentId: 32
+ },
+ {
+ boxId: 24,
+ boxName: "SURFACE",
+ permanentId: 33
+ },
+ {
+ boxId: 25,
+ boxName: "FLAPERON",
+ permanentId: 34
+ },
+ {
+ boxId: 26,
+ boxName: "TURN ASSIST",
+ permanentId: 35
+ },
+ {
+ boxId: 14,
+ boxName: "NAV LAUNCH",
+ permanentId: 36
+ },
+ {
+ boxId: 27,
+ boxName: "SERVO AUTOTRIM",
+ permanentId: 37
+ },
+ {
+ boxId: 23,
+ boxName: "KILLSWITCH",
+ permanentId: 38
+ },
+ {
+ boxId: 29,
+ boxName: "CAMERA CONTROL 1",
+ permanentId: 39
+ },
+ {
+ boxId: 30,
+ boxName: "CAMERA CONTROL 2",
+ permanentId: 40
+ },
+ {
+ boxId: 31,
+ boxName: "CAMERA CONTROL 3",
+ permanentId: 41
+ },
+ {
+ boxId: 32,
+ boxName: "OSD ALT 1",
+ permanentId: 42
+ },
+ {
+ boxId: 33,
+ boxName: "OSD ALT 2",
+ permanentId: 43
+ },
+ {
+ boxId: 34,
+ boxName: "OSD ALT 3",
+ permanentId: 44
+ },
+ {
+ boxId: 35,
+ boxName: "NAV COURSE HOLD",
+ permanentId: 45
+ },
+ {
+ boxId: 36,
+ boxName: "MC BRAKING",
+ permanentId: 46
+ },
+ {
+ boxId: 37,
+ boxName: "USER1",
+ permanentId: 47
+ },
+ {
+ boxId: 38,
+ boxName: "USER2",
+ permanentId: 48
+ },
+ {
+ boxId: 48,
+ boxName: "USER3",
+ permanentId: 57
+ },
+ {
+ boxId: 49,
+ boxName: "USER4",
+ permanentId: 58
+ },
+ {
+ boxId: 40,
+ boxName: "LOITER CHANGE",
+ permanentId: 49
+ },
+ {
+ boxId: 41,
+ boxName: "MSP RC OVERRIDE",
+ permanentId: 50
+ },
+ {
+ boxId: 42,
+ boxName: "PREARM",
+ permanentId: 51
+ },
+ {
+ boxId: 43,
+ boxName: "TURTLE",
+ permanentId: 52
+ },
+ {
+ boxId: 44,
+ boxName: "NAV CRUISE",
+ permanentId: 53
+ },
+ {
+ boxId: 45,
+ boxName: "AUTO LEVEL TRIM",
+ permanentId: 54
+ },
+ {
+ boxId: 46,
+ boxName: "WP PLANNER",
+ permanentId: 55
+ },
+ {
+ boxId: 47,
+ boxName: "SOARING",
+ permanentId: 56
+ },
+ {
+ boxId: 50,
+ boxName: "MISSION CHANGE",
+ permanentId: 59
+ },
+ {
+ boxId: 51,
+ boxName: "BEEPER MUTE",
+ permanentId: 60
+ },
+ {
+ boxId: 52,
+ boxName: "MULTI FUNCTION",
+ permanentId: 61
+ },
+ {
+ boxId: 53,
+ boxName: "MIXER PROFILE 2",
+ permanentId: 62
+ },
+ {
+ boxId: 54,
+ boxName: "MIXER TRANSITION",
+ permanentId: 63
+ },
+ {
+ boxId: 55,
+ boxName: "ANGLE HOLD",
+ permanentId: 64
+ }
+];
+
+module.exports = {FLIGHT_MODES};
\ No newline at end of file
diff --git a/js/gui.js b/js/gui.js
index 0dc3b6cc2..175916485 100644
--- a/js/gui.js
+++ b/js/gui.js
@@ -9,6 +9,7 @@ const FC = require('./fc');
const interval = require('./intervals');
const { scaleRangeInt } = require('./helpers');
const i18n = require('./localization');
+const mspDeduplicationQueue = require("./msp/mspDeduplicationQueue");
var TABS = {}; // filled by individual tab js file
@@ -90,6 +91,7 @@ GUI_control.prototype.log = function (message) {
// default switch doesn't require callback to be set
GUI_control.prototype.tab_switch_cleanup = function (callback) {
MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive
+ mspDeduplicationQueue.flush();
interval.killAll(['global_data_refresh', 'msp-load-update', 'ltm-connection-check']);
diff --git a/js/msp/MSPCodes.js b/js/msp/MSPCodes.js
index de0de07df..613f0f6c3 100644
--- a/js/msp/MSPCodes.js
+++ b/js/msp/MSPCodes.js
@@ -84,7 +84,6 @@ var MSPCodes = {
MSP_PID: 112,
MSP_ACTIVEBOXES: 113,
MSP_MOTOR_PINS: 115,
- MSP_BOXNAMES: 116,
MSP_PIDNAMES: 117,
MSP_WP: 118,
MSP_BOXIDS: 119,
diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js
index 74328a293..1f19b2a9e 100644
--- a/js/msp/MSPHelper.js
+++ b/js/msp/MSPHelper.js
@@ -20,6 +20,7 @@ const { FwApproach } = require('./../fwApproach');
const Waypoint = require('./../waypoint');
const mspDeduplicationQueue = require('./mspDeduplicationQueue');
const mspStatistics = require('./mspStatistics');
+const settingsCache = require('./../settingsCache');
var mspHelper = (function () {
var self = {};
@@ -386,21 +387,6 @@ var mspHelper = (function () {
case MSPCodes.MSP_MOTOR_PINS:
console.log(data);
break;
- case MSPCodes.MSP_BOXNAMES:
- //noinspection JSUndeclaredVariable
- FC.AUX_CONFIG = []; // empty the array as new data is coming in
- buff = [];
- for (let i = 0; i < data.byteLength; i++) {
- if (data.getUint8(i) == 0x3B) { // ; (delimeter char)
- FC.AUX_CONFIG.push(String.fromCharCode.apply(null, buff)); // convert bytes into ASCII and save as strings
-
- // empty buffer
- buff = [];
- } else {
- buff.push(data.getUint8(i));
- }
- }
- break;
case MSPCodes.MSP_PIDNAMES:
//noinspection JSUndeclaredVariable
FC.PID_names = []; // empty the array as new data is coming in
@@ -1863,6 +1849,7 @@ var mspHelper = (function () {
break;
case MSPCodes.MSP2_SET_CF_SERIAL_CONFIG:
+ console.log('will crunch', FC.SERIAL_CONFIG);
for (let i = 0; i < FC.SERIAL_CONFIG.ports.length; i++) {
var serialPort = FC.SERIAL_CONFIG.ports[i];
@@ -3078,9 +3065,12 @@ var mspHelper = (function () {
};
self._getSetting = function (name) {
- if (FC.SETTINGS[name]) {
- return Promise.resolve(FC.SETTINGS[name]);
+
+ const storedSetting = settingsCache.get(name);
+ if (typeof storedSetting !== 'undefined') {
+ return Promise.resolve(storedSetting);
}
+
var data = [];
self._encodeSettingReference(name, null, data);
return MSP.promise(MSPCodes.MSP2_COMMON_SETTING_INFO, data).then(function (result) {
@@ -3127,7 +3117,7 @@ var mspHelper = (function () {
}
setting.table = { values: values };
}
- FC.SETTINGS[name] = setting;
+ settingsCache.set(name, setting);
return setting;
});
}
@@ -3244,7 +3234,7 @@ var mspHelper = (function () {
this.encodeSetting(name, value).then(function (data) {
return MSP.promise(MSPCodes.MSPV2_SET_SETTING, data).then(callback);
}).catch(error => {
- console.log("Invalid setting: " + name);
+ console.log("Invalid setting: " + name, error);
return Promise.resolve().then(callback);
});
};
diff --git a/js/port_handler.js b/js/port_handler.js
index 2f23678a8..182893fa8 100755
--- a/js/port_handler.js
+++ b/js/port_handler.js
@@ -8,7 +8,8 @@ const ConnectionSerial = require('./connection/connectionSerial');
var usbDevices = [
{ 'vendorId': 1155, 'productId': 57105},
- { 'vendorId': 11836, 'productId': 57105}
+ { 'vendorId': 11836, 'productId': 57105},
+ { 'vendorId': 12619, 'productId': 262}, // APM32 DFU Bootloader
];
@@ -297,4 +298,4 @@ PortHandler.flush_callbacks = function () {
return killed;
};
-module.exports = { usbDevices, PortHandler };
\ No newline at end of file
+module.exports = { usbDevices, PortHandler };
diff --git a/js/serialPortHelper.js b/js/serialPortHelper.js
index d6bdbf184..f2c7d186c 100644
--- a/js/serialPortHelper.js
+++ b/js/serialPortHelper.js
@@ -335,6 +335,7 @@ const serialPortHelper = (function () {
publicScope.clearByFunction(functionName);
let config = publicScope.getPortByIdentifier(port);
+
if (config) {
config.functions = [functionName];
diff --git a/js/serial_backend.js b/js/serial_backend.js
index 8f053ca90..0648c2768 100755
--- a/js/serial_backend.js
+++ b/js/serial_backend.js
@@ -460,27 +460,22 @@ var SerialBackend = (function () {
$('#dataflash_wrapper_global').show();
/*
- * Get BOXNAMES since it is used for some reason....
+ * Init PIDs bank with a length that depends on the version
*/
- MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, function () {
- /*
- * Init PIDs bank with a length that depends on the version
- */
- let pidCount = 11;
+ let pidCount = 11;
- for (let i = 0; i < pidCount; i++) {
- FC.PIDs.push(new Array(4));
- }
+ for (let i = 0; i < pidCount; i++) {
+ FC.PIDs.push(new Array(4));
+ }
- interval.add('msp-load-update', function () {
- $('#msp-version').text("MSP version: " + MSP.protocolVersion.toFixed(0));
- $('#msp-load').text("MSP load: " + mspQueue.getLoad().toFixed(1));
- $('#msp-roundtrip').text("MSP round trip: " + mspQueue.getRoundtrip().toFixed(0));
- $('#hardware-roundtrip').text("HW round trip: " + mspQueue.getHardwareRoundtrip().toFixed(0));
- }, 100);
+ interval.add('msp-load-update', function () {
+ $('#msp-version').text("MSP version: " + MSP.protocolVersion.toFixed(0));
+ $('#msp-load').text("MSP load: " + mspQueue.getLoad().toFixed(1));
+ $('#msp-roundtrip').text("MSP round trip: " + mspQueue.getRoundtrip().toFixed(0));
+ $('#hardware-roundtrip').text("HW round trip: " + mspQueue.getHardwareRoundtrip().toFixed(0));
+ }, 100);
- interval.add('global_data_refresh', periodicStatusUpdater.run, periodicStatusUpdater.getUpdateInterval(CONFIGURATOR.connection.bitrate), false);
- });
+ interval.add('global_data_refresh', periodicStatusUpdater.run, periodicStatusUpdater.getUpdateInterval(CONFIGURATOR.connection.bitrate), false);
});
}
diff --git a/js/settingsCache.js b/js/settingsCache.js
new file mode 100644
index 000000000..6698cea7e
--- /dev/null
+++ b/js/settingsCache.js
@@ -0,0 +1,47 @@
+'use strict';
+
+const Store = require('electron-store');
+const store = new Store();
+const FC = require('./fc');
+
+var settingsCache = (function() {
+
+ let publicScope = {};
+ let privateScope = {};
+
+ const SETTINGS_KEY = 'settings';
+
+ privateScope.getSetingKey = function(settingName) {
+ return FC.CONFIG.target + '_' + FC.CONFIG.flightControllerVersion + '_' + settingName;
+ }
+
+ publicScope.flush = function() {
+ store.delete(SETTINGS_KEY);
+ console.log('Settings cache flushed');
+ };
+
+ publicScope.get = function(settingName) {
+ let settings = store.get(SETTINGS_KEY, null);
+
+ if (settings === null) {
+ return undefined;
+ }
+ let setting = settings[privateScope.getSetingKey(settingName)];
+ return setting;
+ };
+
+ publicScope.set = function(settingName, value) {
+ let settings = store.get(SETTINGS_KEY, null);
+
+ if (settings === null) {
+ settings = {};
+ }
+
+ settings[privateScope.getSetingKey(settingName)] = value;
+ store.set(SETTINGS_KEY, settings);
+ };
+
+ return publicScope;
+}());
+
+module.exports = settingsCache;
\ No newline at end of file
diff --git a/js/wizard_save_framework.js b/js/wizard_save_framework.js
new file mode 100644
index 000000000..04dd8f59e
--- /dev/null
+++ b/js/wizard_save_framework.js
@@ -0,0 +1,58 @@
+'use strict';
+
+const mspHelper = require('./msp/MSPHelper');
+const serialPortHelper = require('./serialPortHelper');
+const FC = require('./fc');
+
+var wizardSaveFramework = (function () {
+
+ let self = {};
+
+ self.saveSetting = function (config, callback) {
+ /*
+ serialrx_provider to 2
+ serialrx_provider to 6
+ */
+
+ switch (config.name) {
+ case 'receiverPort':
+ serialPortHelper.set(config.value, 'RX_SERIAL', null);
+ mspHelper.saveSerialPorts(callback);
+ break;
+ case 'receiverProtocol':
+ mspHelper.setSetting('serialrx_provider', config.value, callback);
+ break;
+ default:
+ callback();
+ break;
+ }
+ };
+
+ self.handleSetting = function (configs, finalCallback) {
+
+ if (configs.length > 0) {
+ let setting = configs.shift();
+ self.saveSetting(setting, function () {
+ self.handleSetting(configs, finalCallback);
+ });
+ } else {
+ console.log('Nothing to save');
+ finalCallback();
+ }
+ };
+
+ self.persist = function (config, finalCallback) {
+ if (config === null || config === undefined || config.length === 0) {
+ finalCallback();
+ return;
+ }
+
+ let configCopy = Array.from(config);
+
+ self.handleSetting(configCopy, finalCallback);
+ }
+
+ return self;
+})();
+
+module.exports = wizardSaveFramework;
\ No newline at end of file
diff --git a/js/wizard_ui_bindings.js b/js/wizard_ui_bindings.js
new file mode 100644
index 000000000..8125ba3d8
--- /dev/null
+++ b/js/wizard_ui_bindings.js
@@ -0,0 +1,41 @@
+'use strict';
+
+const mspHelper = require('./msp/MSPHelper');
+const serialPortHelper = require('./serialPortHelper');
+
+const wizardUiBindings = (function () {
+
+ let self = {};
+
+ self.receiver = function ($content) {
+
+ mspHelper.loadSerialPorts(function () {
+ let $receiverPort = $content.find('#wizard-receiver-port');
+ let ports = serialPortHelper.getPortIdentifiersForFunction('RX_SERIAL');
+ let currentPort = null;
+
+ if (ports.length > 0) {
+ currentPort = ports[0];
+ }
+
+ let availablePorts = serialPortHelper.getPortList();
+
+ $receiverPort.append('
NONE ');
+ for (let i = 0; i < availablePorts.length; i++) {
+ let port = availablePorts[i];
+ $receiverPort.append('
' + port.displayName + ' ');
+ }
+
+ if (currentPort !== null) {
+ $receiverPort.val(currentPort);
+ } else {
+ $receiverPort.val(-1);
+ }
+ });
+
+ }
+
+ return self;
+})();
+
+module.exports = wizardUiBindings;
\ No newline at end of file
diff --git a/locale/en/messages.json b/locale/en/messages.json
index 3af2e7f3e..c5e53172e 100644
--- a/locale/en/messages.json
+++ b/locale/en/messages.json
@@ -1325,6 +1325,24 @@
"portsFunction_SBUS_OUTPUT": {
"message": "SBus Output"
},
+ "pidTuning_Other": {
+ "message": "Other"
+ },
+ "pidTuning_Limits": {
+ "message": "Limits"
+ },
+ "pidTuning_HeadingHold_Rate": {
+ "message": "Heading Hold Rate (°/s)"
+ },
+ "pidTuning_Max_Inclination_Angle": {
+ "message": "Max Inclination Angle"
+ },
+ "pidTuning_Max_Roll": {
+ "message": "Roll (°/10)"
+ },
+ "pidTuning_Max_Pitch": {
+ "message": "Pitch (°/10)"
+ },
"pidTuning_ShowAllPIDs": {
"message": "Show all PIDs"
},
@@ -1391,6 +1409,30 @@
"pidTuning_RatesAndExpo": {
"message": "Rates & Expo"
},
+ "pidTuning_Rates_Stabilized": {
+ "message": "Stabilized Rates"
+ },
+ "pidTuning_Rates_Roll": {
+ "message": "Roll (°/s)"
+ },
+ "pidTuning_Rates_Pitch": {
+ "message": "Pitch (°/s)"
+ },
+ "pidTuning_Rates_Yaw": {
+ "message": "Yaw (°/s)"
+ },
+ "pidTuning_Expo_Stabilized": {
+ "message": "Stabilized Expo"
+ },
+ "pidTuning_Expo_Manual": {
+ "message": "Manual Expo"
+ },
+ "pidTuning_Expo_RollPitch": {
+ "message": "Roll & Pitch (%)"
+ },
+ "pidTuning_Expo_Yaw": {
+ "message": "Yaw (%)"
+ },
"pidTuning_RateDynamics": {
"message": "Rate Dynamics"
},
@@ -1592,6 +1634,18 @@
"pidTuning_LoadedProfile": {
"message": "Loaded Profile:
$1 "
},
+ "pidTuning_Manual_Rates": {
+ "message": "Manual Rates"
+ },
+ "pidTuning_Manual_Roll": {
+ "message": "Roll (%)"
+ },
+ "pidTuning_Manual_Pitch": {
+ "message": "Pitch (%)"
+ },
+ "pidTuning_Manual_Yaw": {
+ "message": "Yaw (%)"
+ },
"pidTuning_gyro_use_dyn_lpf": {
"message": "Dynamic gyro LPF"
},
@@ -5812,5 +5866,11 @@
},
"gsTelemetrySpeed": {
"message": "Speed"
+ },
+ "maintenance": {
+ "message": "Maintenance"
+ },
+ "maintenanceFlushSettingsCache": {
+ "message": "Flush settings cache"
}
}
diff --git a/manifest.json b/manifest.json
index 8cee67714..1b82eb9b5 100644
--- a/manifest.json
+++ b/manifest.json
@@ -48,7 +48,8 @@
"alwaysOnTopWindows",
{"usbDevices": [
{"vendorId": 1155, "productId": 57105},
- {"vendorId": 11836, "productId": 57105}
+ {"vendorId": 11836, "productId": 57105},
+ {'vendorId': 12619, 'productId': 262} // APM32 DFU Bootloader
]}
],
diff --git a/src/css/defaults_dialog.css b/src/css/defaults_dialog.css
index fabf7bfd4..945a30158 100644
--- a/src/css/defaults_dialog.css
+++ b/src/css/defaults_dialog.css
@@ -9,7 +9,22 @@
z-index: 2001;
}
-.defaults-dialog__content {
+.defaults-dialog__bottom_buttons {
+ position: absolute;
+ bottom: 1em;
+ width: 500px;
+}
+
+.defaults-dialog__bottom_buttons .btn {
+ float: right;
+ margin-left: 2em;
+}
+
+.defaults-dialog__bottom_buttons {
+ font-size: 14pt !important;
+}
+
+.defaults-dialog__content, .defaults-dialog__wizard {
background-color: #efefef;
border-radius: 2px;
z-index: 2002;
@@ -25,6 +40,25 @@
padding: 1em;
}
+.defaults-dialog__wizard {
+ font-size: 1.2em;
+}
+
+.defaults-dialog__wizard > div {
+ margin-top: 1em;
+}
+
+.defaults-dialog__wizard label {
+ min-width: 30%;
+ display: inline-block;
+}
+
+.defaults-dialog__wizard p {
+ margin-top: 1em;
+ font-size: 0.9em;
+ color:#444;
+}
+
.defaults-dialog__content--wrapper {
overflow-y: auto;
}
diff --git a/src/css/tabs/pid_tuning.css b/src/css/tabs/pid_tuning.css
index 1ebf20f8b..264cfb2bc 100644
--- a/src/css/tabs/pid_tuning.css
+++ b/src/css/tabs/pid_tuning.css
@@ -410,7 +410,7 @@
.pid-slider-row span,
.pid-switch-row .label {
margin-right: 2em;
- width: 120px;
+ width: 150px;
line-height: 22px;;
}
@@ -465,4 +465,15 @@
#pid-sliders {
margin-bottom: 1em;
+}
+
+.tab-pid_tuning .expo-chart {
+ margin: 0 0px 0px 0;
+ width: 200px;
+ height: 117px;
+ border: 1px solid silver;
+ border-radius: 3px;
+ background-image: url(./../../../images/paper.jpg);
+ background-size: 200%;
+ background-position: center;
}
\ No newline at end of file
diff --git a/tabs/adjustments.js b/tabs/adjustments.js
index c8dcc1ce4..9b3246597 100644
--- a/tabs/adjustments.js
+++ b/tabs/adjustments.js
@@ -17,13 +17,7 @@ TABS.adjustments.initialize = function (callback) {
GUI.active_tab_ref = this;
GUI.active_tab = 'adjustments';
- function get_adjustment_ranges() {
- MSP.send_message(MSPCodes.MSP_ADJUSTMENT_RANGES, false, false, get_box_ids);
- }
-
- function get_box_ids() {
- MSP.send_message(MSPCodes.MSP_BOXIDS, false, false, get_rc_data);
- }
+ MSP.send_message(MSPCodes.MSP_ADJUSTMENT_RANGES, false, false, get_rc_data);
function get_rc_data() {
MSP.send_message(MSPCodes.MSP_RC, false, false, load_html);
@@ -33,8 +27,6 @@ TABS.adjustments.initialize = function (callback) {
GUI.load(path.join(__dirname, "adjustments.html"), process_html);
}
- MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, get_adjustment_ranges);
-
function addAdjustment(adjustmentIndex, adjustmentRange, auxChannelCount) {
var template = $('#tab-adjustments-templates').find('.adjustments .adjustment');
diff --git a/tabs/auxiliary.js b/tabs/auxiliary.js
index 7d66e3897..8ac2342b7 100644
--- a/tabs/auxiliary.js
+++ b/tabs/auxiliary.js
@@ -22,24 +22,26 @@ TABS.auxiliary = {};
TABS.auxiliary.initialize = function (callback) {
GUI.active_tab_ref = this;
GUI.active_tab = 'auxiliary';
- function get_mode_ranges() {
- MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_box_ids);
- }
+
+ let LOCAL_AUX_CONFIG = [];
+ let LOCAL_AUX_CONFIG_IDS = [];
+
+ MSP.send_message(MSPCodes.MSP_MODE_RANGES, false, false, get_box_ids);
function get_box_ids() {
- MSP.send_message(MSPCodes.MSP_BOXIDS, false, false, get_rc_data);
- }
+ MSP.send_message(MSPCodes.MSP_BOXIDS, false, false, function () {
+ FC.generateAuxConfig();
- function get_rc_data() {
- if (FC.SERIAL_CONFIG.ports.length == 0) {
- MSP.send_message(MSPCodes.MSP_RC, false, false, get_ports_data);
- } else {
- MSP.send_message(MSPCodes.MSP_RC, false, false, load_html);
- }
+ //Copy global settings into local ones
+ LOCAL_AUX_CONFIG = Array.from(FC.AUX_CONFIG);
+ LOCAL_AUX_CONFIG_IDS = Array.from(FC.AUX_CONFIG_IDS);
+
+ get_rc_data();
+ });
}
- function get_ports_data() {
- MSP.send_message(MSPCodes.MSP2_CF_SERIAL_CONFIG, false, false, load_html);
+ function get_rc_data() {
+ MSP.send_message(MSPCodes.MSP_RC, false, false, load_html);
}
function load_html() {
@@ -47,12 +49,10 @@ TABS.auxiliary.initialize = function (callback) {
GUI.load(path.join(__dirname, "auxiliary.html"), process_html);
}
- MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, get_mode_ranges);
-
// This object separates out the dividers. This is also used to order the modes
const modeSections = {};
modeSections["Arming"] = ["ARM", "PREARM"];
- modeSections["Flight Modes"] = ["ANGLE", "HORIZON", "MANUAL"];
+ modeSections["Flight Modes"] = ["ANGLE", "HORIZON", "MANUAL", "ANGLE HOLD"];
modeSections["Navigation Modes"] = ["NAV COURSE HOLD", "NAV CRUISE", "NAV POSHOLD", "NAV RTH", "NAV WP", "GCS NAV"];
modeSections["Flight Mode Modifiers"] = ["NAV ALTHOLD", "HEADING HOLD", "AIR MODE", "SOARING", "SURFACE", "TURN ASSIST"];
modeSections["Fixed Wing"] = ["AUTO TUNE", "SERVO AUTOTRIM", "AUTO LEVEL TRIM", "NAV LAUNCH", "LOITER CHANGE", "FLAPERON"];
@@ -68,21 +68,21 @@ TABS.auxiliary.initialize = function (callback) {
var found = false;
var sortedID = 0;
- for (let i=0; i
FC.AUX_CONFIG.length) {
+ if (tmpAUX_CONFIG.length > LOCAL_AUX_CONFIG.length) {
for (let i=0; i` + feature.get('name') + ` `
+ `lat: `+ (feature.get('data').lat / 10000000) + ` `
diff --git a/tabs/options.html b/tabs/options.html
index 303aa0103..7c21b29d2 100644
--- a/tabs/options.html
+++ b/tabs/options.html
@@ -87,5 +87,15 @@