1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 00:05:22 +03:00

Auto merged - #2504 at Tue, 22 Jun 2021 20:25:12 GMT

Update Dshot Bidir autodefaults and dynamic notch options
This commit is contained in:
J Blackman 2021-06-23 06:25:12 +10:00 committed by GitHub
commit 676b284c5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 35 deletions

View file

@ -464,6 +464,7 @@ const FC = {
dyn_notch_q: 0,
dyn_notch_min_hz: 0,
dyn_notch_max_hz: 0,
dyn_notch_count: 0,
gyro_rpm_notch_harmonics: 0,
gyro_rpm_notch_min_hz: 0,
};
@ -628,7 +629,7 @@ const FC = {
dterm_lowpass_hz: 100,
dterm_lowpass_dyn_min_hz: 150,
dterm_lowpass_dyn_max_hz: 250,
dyn_lpf_curve_expo: 5,
dyn_lpf_curve_expo: 5,
dterm_lowpass_type: this.FILTER_TYPE_FLAGS.PT1,
dterm_lowpass2_hz: 150,
dterm_lowpass2_type: this.FILTER_TYPE_FLAGS.BIQUAD,
@ -637,8 +638,10 @@ const FC = {
yaw_lowpass_hz: 100,
dyn_notch_q: 120,
dyn_notch_width_percent: 8,
dyn_notch_count: 3,
dyn_notch_q_rpm: 250, // default with rpm filtering
dyn_notch_width_percent_rpm: 0,
dyn_notch_count_rpm: 1,
dyn_notch_min_hz: 150,
dyn_notch_max_hz: 600,
};
@ -822,6 +825,10 @@ const FC = {
versionFilterDefaults.dterm_lowpass2_hz = 150;
versionFilterDefaults.dterm_lowpass2_type = this.FILTER_TYPE_FLAGS.PT1;
}
if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_44)) {
versionFilterDefaults.dyn_notch_q_rpm = 500;
versionFilterDefaults.dyn_notch_q = 300;
}
}
return versionFilterDefaults;
},

View file

@ -1101,7 +1101,6 @@ MspHelper.prototype.process_data = function(dataHandler) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
FC.FILTER_CONFIG.dyn_lpf_curve_expo = data.readU8();
FC.FILTER_CONFIG.dyn_notch_count = data.readU8();
FC.FILTER_CONFIG.dyn_notch_bandwidth_hz = data.readU16();
}
}
}
@ -2074,8 +2073,7 @@ MspHelper.prototype.crunch = function(code) {
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
buffer.push8(FC.FILTER_CONFIG.dyn_lpf_curve_expo)
.push8(FC.FILTER_CONFIG.dyn_notch_count)
.push16(FC.FILTER_CONFIG.dyn_notch_bandwidth_hz);
.push8(FC.FILTER_CONFIG.dyn_notch_count);
}
}
break;

View file

@ -4,6 +4,7 @@ TABS.motors = {
previousDshotBidir: null,
previousFilterDynQ: null,
previousFilterDynWidth: null,
previousFilterDynCount: null,
analyticsChanges: {},
configHasChanged: false,
configChanges: {},
@ -635,6 +636,7 @@ TABS.motors.initialize = function (callback) {
self.previousDshotBidir = FC.MOTOR_CONFIG.use_dshot_telemetry;
self.previousFilterDynQ = FC.FILTER_CONFIG.dyn_notch_q;
self.previousFilterDynWidth = FC.FILTER_CONFIG.dyn_notch_width_percent;
self.previousFilterDynCount = FC.FILTER_CONFIG.dyn_notch_count;
dshotBidirElement.on("change", function () {
const value = $(this).prop('checked');
@ -642,20 +644,26 @@ TABS.motors.initialize = function (callback) {
self.analyticsChanges['BidirectionalDshot'] = newValue;
FC.MOTOR_CONFIG.use_dshot_telemetry = value;
FC.FILTER_CONFIG.dyn_notch_width_percent = self.previousFilterDynWidth;
FC.FILTER_CONFIG.dyn_notch_count = self.previousFilterDynCount;
FC.FILTER_CONFIG.dyn_notch_q = self.previousFilterDynQ;
FC.FILTER_CONFIG.dyn_notch_width_percent = self.previousFilterDynWidth;
if (FC.FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0) { // if rpm filter is active
if (value && !self.previousDshotBidir) {
FC.FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent_rpm;
FC.FILTER_CONFIG.dyn_notch_count = FILTER_DEFAULT.dyn_notch_count_rpm;
FC.FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q_rpm;
FC.FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent_rpm;
} else if (!value && self.previousDshotBidir) {
FC.FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent;
FC.FILTER_CONFIG.dyn_notch_count = FILTER_DEFAULT.dyn_notch_count;
FC.FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q;
FC.FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent;
}
}
if (FC.FILTER_CONFIG.dyn_notch_width_percent !== self.previousFilterDynWidth) {
const dynFilterNeedChange = (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) ? (FC.FILTER_CONFIG.dyn_notch_count !== self.previousFilterDynCount) :
(FC.FILTER_CONFIG.dyn_notch_width_percent !== self.previousFilterDynWidth);
if (dynFilterNeedChange) {
showDialogDynFiltersChange();
}
});

View file

@ -373,6 +373,7 @@ TABS.pid_tuning.initialize = function (callback) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
const dynamicNotchWidthPercent_e = $('.pid_filter input[name="dynamicNotchWidthPercent"]');
const dynamicNotchQ_e = $('.pid_filter input[name="dynamicNotchQ"]');
const dynamicNotchCount_e = $('.pid_filter input[name="dynamicNotchCount"]');
$('.smartfeedforward').hide();
@ -385,8 +386,7 @@ TABS.pid_tuning.initialize = function (callback) {
$('.pid_filter select[name="dynamicNotchRange"]').val(FC.FILTER_CONFIG.dyn_notch_range);
dynamicNotchWidthPercent_e.val(FC.FILTER_CONFIG.dyn_notch_width_percent);
dynamicNotchQ_e.val(FC.FILTER_CONFIG.dyn_notch_q);
$('.pid_filter input[name="dynamicNotchCount"]').val(FC.FILTER_CONFIG.dyn_notch_count);
$('.pid_filter input[name="dynamicNotchBandwidthHz"]').val(FC.FILTER_CONFIG.dyn_notch_bandwidth_hz);
dynamicNotchCount_e.val(FC.FILTER_CONFIG.dyn_notch_count);
$('.pid_filter input[name="dynamicNotchMinHz"]').val(FC.FILTER_CONFIG.dyn_notch_min_hz);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
$('.pid_filter input[name="dynamicNotchMinHz"]').attr("max","250");
@ -397,10 +397,8 @@ TABS.pid_tuning.initialize = function (callback) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
$('.dynamicNotchHelp').attr('title', i18n.getMessage('pidTuningMultiDynamicNotchFilterHelp'));
$('.dynamicNotchWidthPercent').hide();
$('.dynamicNotchQ').hide();
} else {
$('.dynamicNotchCount').hide();
$('.dynamicNotchBandwidthHz').hide();
}
$('.rpmFilter').toggle(FC.MOTOR_CONFIG.use_dshot_telemetry);
@ -422,18 +420,21 @@ TABS.pid_tuning.initialize = function (callback) {
if (checked !== (FC.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);
dynamicNotchCount_e.val(FILTER_DEFAULT.dyn_notch_count_rpm);
dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q_rpm);
dynamicNotchWidthPercent_e.val(FILTER_DEFAULT.dyn_notch_width_percent_rpm);
} else {
dynamicNotchWidthPercent_e.val(FILTER_DEFAULT.dyn_notch_width_percent);
dynamicNotchCount_e.val(FILTER_DEFAULT.dyn_notch_count);
dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q);
dynamicNotchWidthPercent_e.val(FILTER_DEFAULT.dyn_notch_width_percent);
}
showDialogDynFiltersChange();
} else { // same value, return saved values
dynamicNotchWidthPercent_e.val(FC.FILTER_CONFIG.dyn_notch_width_percent);
dynamicNotchCount_e.val(FC.FILTER_CONFIG.dyn_notch_count);
dynamicNotchQ_e.val(FC.FILTER_CONFIG.dyn_notch_q);
dynamicNotchWidthPercent_e.val(FC.FILTER_CONFIG.dyn_notch_width_percent);
}
}).prop('checked', FC.FILTER_CONFIG.gyro_rpm_notch_harmonics != 0).change();
@ -1002,7 +1003,6 @@ TABS.pid_tuning.initialize = function (callback) {
FC.ADVANCED_TUNING.vbat_sag_compensation = $('input[id="vbatSagCompensation"]').is(':checked') ? parseInt($('input[name="vbatSagValue"]').val()) : 0;
FC.ADVANCED_TUNING.thrustLinearization = $('input[id="thrustLinearization"]').is(':checked') ? parseInt($('input[name="thrustLinearValue"]').val()) : 0;
FC.FILTER_CONFIG.dyn_notch_count = parseInt($('.pid_filter input[name="dynamicNotchCount"]').val());
FC.FILTER_CONFIG.dyn_notch_bandwidth_hz = parseInt($('.pid_filter input[name="dynamicNotchBandwidthHz"]').val());
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {