1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-16 12:55:14 +03:00

Added Dynamic Lpf Dterm Curve Expo to UI

This commit is contained in:
Asizon 2020-06-17 21:22:18 +02:00
parent a52efd7ec8
commit dcdc15c5e3
5 changed files with 42 additions and 0 deletions

View file

@ -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"
},

View file

@ -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,

View file

@ -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:

View file

@ -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() {

View file

@ -1345,6 +1345,22 @@
</td>
</tr>
<tr class="dtermLowpassDyn">
<td>
<span class="groupSwitchValue">
<span class="inputSwitch"><input type="checkbox" id="dtermLowpassDynExpoEnabled" class="toggle" /></span>
<span class="inputValue"><input type="number" name="dtermLowpassDynExpo" step="1" min="1" max="10"/></span>
</span>
</td>
<td>
<div>
<label>
<span i18n="pidTuningDTermLowpassDynExpo"></span>
</label>
</div>
</td>
</tr>
<tr>
<td>
<span class="groupSwitchValue">