From 51ed2ddb51f3823d158ccceb6de428ecb8953dda Mon Sep 17 00:00:00 2001 From: haslinghuis Date: Tue, 17 Jan 2023 13:27:22 +0100 Subject: [PATCH] Enable dynamic notch warning (#3253) --- locales/en/messages.json | 3 +++ src/css/tabs/pid_tuning.less | 3 +++ src/js/tabs/pid_tuning.js | 29 +++++++---------------------- src/tabs/pid_tuning.html | 3 +++ 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index c850a32f..34baf62a 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -4027,6 +4027,9 @@ "pidTuningDynamicNotchFilterDisabledWarning": { "message": "Notice: The dynamic notch filter is disabled. In order to configure and use it, please enable the 'DYNAMIC_FILTER' feature in the '$t(configurationFeatures.message)' section of the '$t(tabConfiguration.message)' tab. Also make sure the PID looprate is at least 2kHz." }, + "pidTuningDynamicNotchFilterNyquistWarning": { + "message": "The dynamic notch filter is disabled. In order to use it, please make sure the PID loop frequency is set to at least 2Khz in the '$t(tabConfiguration.message)' tab." + }, "pidTuningDynamicNotchRange": { "message": "Dynamic Notch Filter Range" }, diff --git a/src/css/tabs/pid_tuning.less b/src/css/tabs/pid_tuning.less index 4ce3e6a8..a4764cfa 100644 --- a/src/css/tabs/pid_tuning.less +++ b/src/css/tabs/pid_tuning.less @@ -747,6 +747,9 @@ padding-top: 2px; padding-bottom: 2px; } + .dynamicNotchNyquistWarningNote { + margin: 0; + } .note-button { td { &:nth-child(n) { diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index 73db7a4e..56de094c 100644 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -67,14 +67,8 @@ pid_tuning.initialize = function (callback) { mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.PID_PROFILE_NAME)) : true) .then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.RATE_PROFILE_NAME)) : true) - .then(() => { - let promise; - if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) { - promise = MSP.promise(MSPCodes.MSP_SIMPLIFIED_TUNING); - } - - return promise; - }) + .then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44) ? MSP.promise(MSPCodes.MSP_SIMPLIFIED_TUNING) : true) + .then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44) ? MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG) : true) .then(() => MSP.send_message(MSPCodes.MSP_MIXER_CONFIG, false, false, load_html)); function load_html() { @@ -2704,20 +2698,11 @@ pid_tuning.updateFilterWarning = function() { const dtermLowpass1Enabled = !dtermLowpassFilterMode; const warningE = $('#pid-tuning .filterWarning'); const warningDynamicNotchE = $('#pid-tuning .dynamicNotchWarning'); - if (!(gyroDynamicLowpassEnabled || gyroLowpass1Enabled) || !(dtermDynamicLowpassEnabled || dtermLowpass1Enabled)) { - warningE.show(); - } else { - warningE.hide(); - } - if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44)) { - if (FC.FEATURE_CONFIG.features.isEnabled('DYNAMIC_FILTER')) { - warningDynamicNotchE.hide(); - } else { - warningDynamicNotchE.show(); - } - } else { - warningDynamicNotchE.hide(); - } + const warningDynamicNotchNyquistE = $('#pid-tuning .dynamicNotchNyquistWarningNote'); + + warningE.toggle(!(gyroDynamicLowpassEnabled || gyroLowpass1Enabled) || !(dtermDynamicLowpassEnabled || dtermLowpass1Enabled)); + warningDynamicNotchNyquistE.toggle(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44) && (FC.CONFIG.sampleRateHz / FC.PID_ADVANCED_CONFIG.pid_process_denom < 2000)); + warningDynamicNotchE.toggle(FC.FEATURE_CONFIG.features.isEnabled('DYNAMIC_FILTER') && (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44))); }; pid_tuning.updatePIDColors = function(clear = false) { diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index 3118e881..93fb23d1 100644 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -1518,6 +1518,9 @@
+
+

+