diff --git a/locales/en/messages.json b/locales/en/messages.json
index 7e34bf84..40f5a8a6 100644
--- a/locales/en/messages.json
+++ b/locales/en/messages.json
@@ -1468,6 +1468,14 @@
"configurationButtonSave": {
"message": "Save and Reboot"
},
+ "dialogDynFiltersChangeTitle": {
+ "message": "Dynamic Notch values change"
+ },
+ "dialogDynFiltersChangeNote": {
+ "message": "WARNING: Some dynamic notch values have been changed to default values because the RPM filtering has been activated/deactivated.
Please, check before flying"
+ },
+ "dialogDynFiltersConfirm": {
+ "message": "OK",
"portsIdentifier": {
"message": "Identifier"
diff --git a/src/js/fc.js b/src/js/fc.js
index d0cc3151..404a25c2 100644
--- a/src/js/fc.js
+++ b/src/js/fc.js
@@ -579,6 +579,10 @@ var FC = {
dterm_notch_cutoff: 160,
dterm_notch_hz: 260,
yaw_lowpass_hz: 100,
+ dyn_notch_q: 120,
+ dyn_notch_width_percent: 8,
+ dyn_notch_q_rpm: 250, // default with rpm filtering
+ dyn_notch_width_percent_rpm: 0,
};
DEFAULT_PIDS = [
diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js
index 26d4f2ca..fd6c0f03 100644
--- a/src/js/tabs/configuration.js
+++ b/src/js/tabs/configuration.js
@@ -2,12 +2,18 @@
TABS.configuration = {
SHOW_OLD_BATTERY_CONFIG: false,
+ previousDshotBidir: null,
+ previousFilterDynQ: null,
+ previousFilterDynWidth: null,
analyticsChanges: {},
};
TABS.configuration.initialize = function (callback, scrollPosition) {
var self = this;
+ // Update filtering defaults based on API version
+ const FILTER_DEFAULT = FC.getFilterDefaults();
+
if (GUI.active_tab != 'configuration') {
GUI.active_tab = 'configuration';
GUI.configuration_loaded = true;
@@ -171,7 +177,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_rx_config() {
- var next_callback = load_html;
+ const next_callback = load_filter_config;
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, next_callback);
} else {
@@ -179,6 +185,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
+ function load_filter_config() {
+ const next_callback = load_html;
+ if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
+ MSP.send_message(MSPCodes.MSP_FILTER_CONFIG, false, false, next_callback);
+ } else {
+ next_callback();
+ }
+ }
+
function load_html() {
$('#content').load("./tabs/configuration.html", process_html);
}
@@ -497,6 +512,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
let dshotBidirectional_e = $('input[id="dshotBidir"]');
dshotBidirectional_e.prop('checked', MOTOR_CONFIG.use_dshot_telemetry).change();
+ self.previousDshotBidir = MOTOR_CONFIG.use_dshot_telemetry;
+ self.previousFilterDynQ = FILTER_CONFIG.dyn_notch_q;
+ self.previousFilterDynWidth = FILTER_CONFIG.dyn_notch_width_percent;
+
dshotBidirectional_e.change(function () {
let value = $(this).prop('checked');
@@ -507,6 +526,31 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
self.analyticsChanges['BidirectionalDshot'] = newValue;
MOTOR_CONFIG.use_dshot_telemetry = value;
+
+ FILTER_CONFIG.dyn_notch_width_percent = self.previousFilterDynWidth;
+ FILTER_CONFIG.dyn_notch_q = self.previousFilterDynQ;
+
+ if (FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0) { // if rpm filter is active
+ if (value && !self.previousDshotBidir) {
+ FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent_rpm;
+ FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q_rpm;
+ } else if (!value && self.previousDshotBidir) {
+ FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent;
+ FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q;
+ }
+ }
+
+ if (FILTER_CONFIG.dyn_notch_width_percent !== self.previousFilterDynWidth) {
+ const dialogDynFiltersChange = $('.dialogDynFiltersChange')[0];
+
+ if (!dialogDynFiltersChange.hasAttribute('open')) {
+ dialogDynFiltersChange.showModal();
+
+ $('.dialogDynFiltersChange-confirmbtn').click(function() {
+ dialogDynFiltersChange.close();
+ });
+ }
+ }
});
$('input[name="motorPoles"]').val(MOTOR_CONFIG.motor_poles);
@@ -1391,7 +1435,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_rx_config() {
- var next_callback = save_to_eeprom;
+ const next_callback = save_filter_config;
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, next_callback);
} else {
@@ -1399,6 +1443,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
+ function save_filter_config() {
+ const next_callback = save_to_eeprom;
+ if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
+ MSP.send_message(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG), false, next_callback);
+ } else {
+ next_callback();
+ }
+ }
+
function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, reboot);
}
diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js
index 106e2720..e4e3b898 100644
--- a/src/js/tabs/pid_tuning.js
+++ b/src/js/tabs/pid_tuning.js
@@ -359,6 +359,9 @@ TABS.pid_tuning.initialize = function (callback) {
}
if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
+ const dynamicNotchWidthPercent_e = $('.pid_filter input[name="dynamicNotchWidthPercent"]');
+ const dynamicNotchQ_e = $('.pid_filter input[name="dynamicNotchQ"]');
+
$('.smartfeedforward').hide();
if (FEATURE_CONFIG.features.isEnabled('DYNAMIC_FILTER')) {
@@ -368,8 +371,8 @@ TABS.pid_tuning.initialize = function (callback) {
}
$('.dynamicNotchRange').toggle(semver.lt(CONFIG.apiVersion, API_VERSION_1_43));
$('.pid_filter select[name="dynamicNotchRange"]').val(FILTER_CONFIG.dyn_notch_range);
- $('.pid_filter input[name="dynamicNotchWidthPercent"]').val(FILTER_CONFIG.dyn_notch_width_percent);
- $('.pid_filter input[name="dynamicNotchQ"]').val(FILTER_CONFIG.dyn_notch_q);
+ dynamicNotchWidthPercent_e.val(FILTER_CONFIG.dyn_notch_width_percent);
+ dynamicNotchQ_e.val(FILTER_CONFIG.dyn_notch_q);
$('.pid_filter input[name="dynamicNotchMinHz"]').val(FILTER_CONFIG.dyn_notch_min_hz);
if (semver.gte(CONFIG.apiVersion, API_VERSION_1_43)) {
$('.pid_filter input[name="dynamicNotchMinHz"]').attr("max","250");
@@ -394,7 +397,33 @@ TABS.pid_tuning.initialize = function (callback) {
if (harmonics == 0) {
$('.pid_filter input[name="rpmFilterHarmonics"]').val(FILTER_DEFAULT.gyro_rpm_notch_harmonics);
}
+
+ if (checked !== (FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0)) { // if rpmFilterEnabled is not the same value as saved in the fc
+ if (checked) {
+ dynamicNotchWidthPercent_e.val(FILTER_DEFAULT.dyn_notch_width_percent_rpm);
+ dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q_rpm);
+ } else {
+ dynamicNotchWidthPercent_e.val(FILTER_DEFAULT.dyn_notch_width_percent);
+ dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q);
+ }
+
+ const dialogDynFiltersChange = $('.dialogDynFiltersChange')[0];
+
+ if (!dialogDynFiltersChange.hasAttribute('open')) {
+ dialogDynFiltersChange.showModal();
+
+ $('.dialogDynFiltersChange-confirmbtn').click(function() {
+ dialogDynFiltersChange.close();
+ });
+ }
+
+ } else { // same value, return saved values
+ dynamicNotchWidthPercent_e.val(FILTER_CONFIG.dyn_notch_width_percent);
+ dynamicNotchQ_e.val(FILTER_CONFIG.dyn_notch_q);
+ }
+
}).prop('checked', FILTER_CONFIG.gyro_rpm_notch_harmonics != 0).change();
+
} else {
$('.itermRelaxCutoff').hide();
$('.dynamicNotch').hide();
diff --git a/src/tabs/configuration.html b/src/tabs/configuration.html
index cce43d6e..0e47998d 100644
--- a/src/tabs/configuration.html
+++ b/src/tabs/configuration.html
@@ -774,4 +774,15 @@
+
+
diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html
index c3e04544..576b32ca 100644
--- a/src/tabs/pid_tuning.html
+++ b/src/tabs/pid_tuning.html
@@ -1590,7 +1590,7 @@
-
+
+
+