diff --git a/locales/en/messages.json b/locales/en/messages.json index 285faf36..c9d53645 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -3587,6 +3587,9 @@ "pidTuningDTermLowpassDynType": { "message": "D Term Lowpass 1 Dynamic Filter Type" }, + "pidTuningDTermLowpassDynExpo": { + "message": "D Term Lowpass 1 Dynamic Curve Expo" + }, "pidTuningDTermNotchFiltersGroup": { "message": "D Term Notch Filters" }, diff --git a/src/js/fc.js b/src/js/fc.js index 2913d824..8e09edc6 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -405,6 +405,7 @@ var FC = { dterm_lowpass_type: 0, dterm_lowpass2_hz: 0, dterm_lowpass2_type: 0, + dyn_lpf_curve_expo: 0, dterm_notch_hz: 0, dterm_notch_cutoff: 0, yaw_lowpass_hz: 0, @@ -568,6 +569,7 @@ var FC = { dterm_lowpass_hz: 100, dterm_lowpass_dyn_min_hz: 150, dterm_lowpass_dyn_max_hz: 250, + dyn_lpf_curve_expo: 5, dterm_lowpass_type: FC.FILTER_TYPE_FLAGS.PT1, dterm_lowpass2_hz: 150, dterm_lowpass2_type: FC.FILTER_TYPE_FLAGS.BIQUAD, diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index c7d64813..df870f9d 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -1083,6 +1083,9 @@ MspHelper.prototype.process_data = function(dataHandler) { if (semver.gte(CONFIG.apiVersion, API_VERSION_1_43)) { FILTER_CONFIG.dyn_notch_max_hz = data.readU16(); } + if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) { + FILTER_CONFIG.dyn_lpf_curve_expo = data.readU8(); + } } } } @@ -2017,6 +2020,9 @@ MspHelper.prototype.crunch = function(code) { if (semver.gte(CONFIG.apiVersion, API_VERSION_1_43)) { buffer.push16(FILTER_CONFIG.dyn_notch_max_hz); } + if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) { + buffer.push8(FILTER_CONFIG.dyn_lpf_curve_expo); + } } break; case MSPCodes.MSP_SET_PID_ADVANCED: diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index 1abee7a3..423036c0 100644 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -330,6 +330,9 @@ TABS.pid_tuning.initialize = function (callback) { $('.pid_filter input[name="dtermLowpassDynMinFrequency"]').val(FILTER_CONFIG.dterm_lowpass_dyn_min_hz); $('.pid_filter input[name="dtermLowpassDynMaxFrequency"]').val(FILTER_CONFIG.dterm_lowpass_dyn_max_hz); $('.pid_filter select[name="dtermLowpassDynType"]').val(FILTER_CONFIG.dterm_lowpass_type); + if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) { + $('.pid_filter input[name="dtermLowpassDynExpo"]').val(FILTER_CONFIG.dyn_lpf_curve_expo); + } $('.pid_tuning input[name="dMinRoll"]').val(ADVANCED_TUNING.dMinRoll); $('.pid_tuning input[name="dMinPitch"]').val(ADVANCED_TUNING.dMinPitch); @@ -613,10 +616,18 @@ TABS.pid_tuning.initialize = function (callback) { $('input[id="dtermLowpassEnabled"]').prop('checked', false).change(); } else if (FILTER_CONFIG.dterm_lowpass_hz > 0 && !$('input[id="dtermLowpassEnabled"]').is(':checked')) { $('input[id="dtermLowpassEnabled"]').prop('checked', true).change(); + $('.pid_filter input[id="dtermLowpassDynExpoEnabled"]').prop('checked', false).change(); } self.updateFilterWarning(); }); + $('input[id="dtermLowpassDynExpoEnabled"]').change(function() { + var checked = $(this).is(':checked'); + var curveExpo = FILTER_CONFIG.dyn_lpf_curve_expo > 0 ? FILTER_CONFIG.dyn_lpf_curve_expo : FILTER_DEFAULT.dyn_lpf_curve_expo; + + $('.pid_filter input[name="dtermLowpassDynExpo"]').val(checked ? curveExpo : 0).attr('disabled', !checked); + }); + $('input[id="dtermLowpass2Enabled"]').change(function() { var checked = $(this).is(':checked'); var cutoff = FILTER_CONFIG.dterm_lowpass2_hz > 0 ? FILTER_CONFIG.dterm_lowpass2_hz : FILTER_DEFAULT.dterm_lowpass2_hz; @@ -664,6 +675,7 @@ TABS.pid_tuning.initialize = function (callback) { $('input[id="dtermNotchEnabled"]').prop('checked', FILTER_CONFIG.dterm_notch_hz != 0).change(); $('input[id="gyroLowpassEnabled"]').prop('checked', FILTER_CONFIG.gyro_lowpass_hz != 0).change(); $('input[id="gyroLowpassDynEnabled"]').prop('checked', FILTER_CONFIG.gyro_lowpass_dyn_min_hz != 0 && FILTER_CONFIG.gyro_lowpass_dyn_min_hz < FILTER_CONFIG.gyro_lowpass_dyn_max_hz).change(); + $('input[id="dtermLowpassDynExpoEnabled"]').prop('checked', FILTER_CONFIG.dyn_lpf_curve_expo != 0).change(); $('input[id="gyroLowpass2Enabled"]').prop('checked', FILTER_CONFIG.gyro_lowpass2_hz != 0).change(); $('input[id="dtermLowpassEnabled"]').prop('checked', FILTER_CONFIG.dterm_lowpass_hz != 0).change(); $('input[id="dtermLowpassDynEnabled"]').prop('checked', FILTER_CONFIG.dterm_lowpass_dyn_min_hz != 0 && FILTER_CONFIG.dterm_lowpass_dyn_min_hz < FILTER_CONFIG.dterm_lowpass_dyn_max_hz).change(); @@ -885,6 +897,9 @@ TABS.pid_tuning.initialize = function (callback) { RC_tuning.rates_type = selectedRatesType; } + if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) { + FILTER_CONFIG.dyn_lpf_curve_expo = parseInt($('.pid_filter input[name="dtermLowpassDynExpo"]').val()); + } } function showAllPids() { diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index 94de2d03..983bae1b 100644 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -1345,6 +1345,22 @@ + + + + + + + + +
+ +
+ + +