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

Update Dshot Bidir autodefaults and dynamic values

Missing semicolon

Added MSP workaround

Code smells fix

added missing indent
This commit is contained in:
Asizon 2021-06-06 11:47:58 +02:00
parent 517393a289
commit 0096a03782
6 changed files with 29 additions and 35 deletions

View file

@ -3732,9 +3732,6 @@
"pidTuningDynamicNotchCount": { "pidTuningDynamicNotchCount": {
"message": "Dynamic Notch Count" "message": "Dynamic Notch Count"
}, },
"pidTuningDynamicNotchBandwidthHz": {
"message": "Dynamic Notch Bandwidth Frequency [Hz]"
},
"pidTuningDynamicNotchRangeHelp": { "pidTuningDynamicNotchRangeHelp": {
"message": "The dynamic notch has three frequency ranges in which it can operate: LOW(80-330hz) for lower revving quads like 6+ inches, MEDIUM(140-550hz) for a normal 5 inch quad, HIGH(230-800hz) for very high revving 2.5-3 inch quads. AUTO option selects the range depending on the value of the Gyro Dynamic Lowpass 1 Filter's max cutoff frequency." "message": "The dynamic notch has three frequency ranges in which it can operate: LOW(80-330hz) for lower revving quads like 6+ inches, MEDIUM(140-550hz) for a normal 5 inch quad, HIGH(230-800hz) for very high revving 2.5-3 inch quads. AUTO option selects the range depending on the value of the Gyro Dynamic Lowpass 1 Filter's max cutoff frequency."
}, },
@ -3753,9 +3750,6 @@
"pidTuningDynamicNotchCountHelp": { "pidTuningDynamicNotchCountHelp": {
"message": "Sets the number of dynamic notches per axis. With RPM filter enabled a value of 1 or 2 is recommended. Without RPM filter a value of 4 or 5 is recommended. Lower numbers will reduce filter delay, however it may increase motor temperature." "message": "Sets the number of dynamic notches per axis. With RPM filter enabled a value of 1 or 2 is recommended. Without RPM filter a value of 4 or 5 is recommended. Lower numbers will reduce filter delay, however it may increase motor temperature."
}, },
"pidTuningDynamicNotchBandwidthHzHelp": {
"message": "Bandwidth in Hz adjusts how narrow or wide every dynamic notch will be. Higher values makes it wider and broader. Lower values makes it narrower and more precise, however it may increase motor temperature. Having a really high value will increase filter delay."
},
"pidTuningRpmFilterGroup": { "pidTuningRpmFilterGroup": {
"message": "Gyro RPM Filter", "message": "Gyro RPM Filter",
"description": "Header text for the RPM Filter group" "description": "Header text for the RPM Filter group"

View file

@ -464,6 +464,7 @@ const FC = {
dyn_notch_q: 0, dyn_notch_q: 0,
dyn_notch_min_hz: 0, dyn_notch_min_hz: 0,
dyn_notch_max_hz: 0, dyn_notch_max_hz: 0,
dyn_notch_count: 0,
gyro_rpm_notch_harmonics: 0, gyro_rpm_notch_harmonics: 0,
gyro_rpm_notch_min_hz: 0, gyro_rpm_notch_min_hz: 0,
}; };
@ -628,7 +629,7 @@ const FC = {
dterm_lowpass_hz: 100, dterm_lowpass_hz: 100,
dterm_lowpass_dyn_min_hz: 150, dterm_lowpass_dyn_min_hz: 150,
dterm_lowpass_dyn_max_hz: 250, 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_lowpass_type: this.FILTER_TYPE_FLAGS.PT1,
dterm_lowpass2_hz: 150, dterm_lowpass2_hz: 150,
dterm_lowpass2_type: this.FILTER_TYPE_FLAGS.BIQUAD, dterm_lowpass2_type: this.FILTER_TYPE_FLAGS.BIQUAD,
@ -637,8 +638,10 @@ const FC = {
yaw_lowpass_hz: 100, yaw_lowpass_hz: 100,
dyn_notch_q: 120, dyn_notch_q: 120,
dyn_notch_width_percent: 8, dyn_notch_width_percent: 8,
dyn_notch_count: 3,
dyn_notch_q_rpm: 250, // default with rpm filtering dyn_notch_q_rpm: 250, // default with rpm filtering
dyn_notch_width_percent_rpm: 0, dyn_notch_width_percent_rpm: 0,
dyn_notch_count_rpm: 1,
dyn_notch_min_hz: 150, dyn_notch_min_hz: 150,
dyn_notch_max_hz: 600, dyn_notch_max_hz: 600,
}; };
@ -822,6 +825,10 @@ const FC = {
versionFilterDefaults.dterm_lowpass2_hz = 150; versionFilterDefaults.dterm_lowpass2_hz = 150;
versionFilterDefaults.dterm_lowpass2_type = this.FILTER_TYPE_FLAGS.PT1; 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; return versionFilterDefaults;
}, },

View file

@ -1101,7 +1101,6 @@ MspHelper.prototype.process_data = function(dataHandler) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
FC.FILTER_CONFIG.dyn_lpf_curve_expo = data.readU8(); FC.FILTER_CONFIG.dyn_lpf_curve_expo = data.readU8();
FC.FILTER_CONFIG.dyn_notch_count = 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)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
buffer.push8(FC.FILTER_CONFIG.dyn_lpf_curve_expo) buffer.push8(FC.FILTER_CONFIG.dyn_lpf_curve_expo)
.push8(FC.FILTER_CONFIG.dyn_notch_count) .push8(FC.FILTER_CONFIG.dyn_notch_count);
.push16(FC.FILTER_CONFIG.dyn_notch_bandwidth_hz);
} }
} }
break; break;

View file

@ -4,6 +4,7 @@ TABS.motors = {
previousDshotBidir: null, previousDshotBidir: null,
previousFilterDynQ: null, previousFilterDynQ: null,
previousFilterDynWidth: null, previousFilterDynWidth: null,
previousFilterDynCount: null,
analyticsChanges: {}, analyticsChanges: {},
configHasChanged: false, configHasChanged: false,
configChanges: {}, configChanges: {},
@ -635,6 +636,7 @@ TABS.motors.initialize = function (callback) {
self.previousDshotBidir = FC.MOTOR_CONFIG.use_dshot_telemetry; self.previousDshotBidir = FC.MOTOR_CONFIG.use_dshot_telemetry;
self.previousFilterDynQ = FC.FILTER_CONFIG.dyn_notch_q; self.previousFilterDynQ = FC.FILTER_CONFIG.dyn_notch_q;
self.previousFilterDynWidth = FC.FILTER_CONFIG.dyn_notch_width_percent; self.previousFilterDynWidth = FC.FILTER_CONFIG.dyn_notch_width_percent;
self.previousFilterDynCount = FC.FILTER_CONFIG.dyn_notch_count;
dshotBidirElement.on("change", function () { dshotBidirElement.on("change", function () {
const value = $(this).prop('checked'); const value = $(this).prop('checked');
@ -642,20 +644,26 @@ TABS.motors.initialize = function (callback) {
self.analyticsChanges['BidirectionalDshot'] = newValue; self.analyticsChanges['BidirectionalDshot'] = newValue;
FC.MOTOR_CONFIG.use_dshot_telemetry = value; 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_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 (FC.FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0) { // if rpm filter is active
if (value && !self.previousDshotBidir) { 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_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) { } 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_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(); showDialogDynFiltersChange();
} }
}); });

View file

@ -373,6 +373,7 @@ TABS.pid_tuning.initialize = function (callback) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
const dynamicNotchWidthPercent_e = $('.pid_filter input[name="dynamicNotchWidthPercent"]'); const dynamicNotchWidthPercent_e = $('.pid_filter input[name="dynamicNotchWidthPercent"]');
const dynamicNotchQ_e = $('.pid_filter input[name="dynamicNotchQ"]'); const dynamicNotchQ_e = $('.pid_filter input[name="dynamicNotchQ"]');
const dynamicNotchCount_e = $('.pid_filter input[name="dynamicNotchCount"]');
$('.smartfeedforward').hide(); $('.smartfeedforward').hide();
@ -385,8 +386,7 @@ TABS.pid_tuning.initialize = function (callback) {
$('.pid_filter select[name="dynamicNotchRange"]').val(FC.FILTER_CONFIG.dyn_notch_range); $('.pid_filter select[name="dynamicNotchRange"]').val(FC.FILTER_CONFIG.dyn_notch_range);
dynamicNotchWidthPercent_e.val(FC.FILTER_CONFIG.dyn_notch_width_percent); dynamicNotchWidthPercent_e.val(FC.FILTER_CONFIG.dyn_notch_width_percent);
dynamicNotchQ_e.val(FC.FILTER_CONFIG.dyn_notch_q); dynamicNotchQ_e.val(FC.FILTER_CONFIG.dyn_notch_q);
$('.pid_filter input[name="dynamicNotchCount"]').val(FC.FILTER_CONFIG.dyn_notch_count); dynamicNotchCount_e.val(FC.FILTER_CONFIG.dyn_notch_count);
$('.pid_filter input[name="dynamicNotchBandwidthHz"]').val(FC.FILTER_CONFIG.dyn_notch_bandwidth_hz);
$('.pid_filter input[name="dynamicNotchMinHz"]').val(FC.FILTER_CONFIG.dyn_notch_min_hz); $('.pid_filter input[name="dynamicNotchMinHz"]').val(FC.FILTER_CONFIG.dyn_notch_min_hz);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
$('.pid_filter input[name="dynamicNotchMinHz"]').attr("max","250"); $('.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)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
$('.dynamicNotchHelp').attr('title', i18n.getMessage('pidTuningMultiDynamicNotchFilterHelp')); $('.dynamicNotchHelp').attr('title', i18n.getMessage('pidTuningMultiDynamicNotchFilterHelp'));
$('.dynamicNotchWidthPercent').hide(); $('.dynamicNotchWidthPercent').hide();
$('.dynamicNotchQ').hide();
} else { } else {
$('.dynamicNotchCount').hide(); $('.dynamicNotchCount').hide();
$('.dynamicNotchBandwidthHz').hide();
} }
$('.rpmFilter').toggle(FC.MOTOR_CONFIG.use_dshot_telemetry); $('.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 !== (FC.FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0)) { // if rpmFilterEnabled is not the same value as saved in the fc
if (checked) { 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); dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q_rpm);
dynamicNotchWidthPercent_e.val(FILTER_DEFAULT.dyn_notch_width_percent_rpm);
} else { } 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); dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q);
dynamicNotchWidthPercent_e.val(FILTER_DEFAULT.dyn_notch_width_percent);
} }
showDialogDynFiltersChange(); showDialogDynFiltersChange();
} else { // same value, return saved values } 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); 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(); }).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.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.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_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)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {

View file

@ -1390,19 +1390,6 @@
</div> </div>
</td> </td>
</tr> </tr>
<tr class="newFilter dynamicNotch dynamicNotchBandwidthHz">
<td>
<input type="number" name="dynamicNotchBandwidthHz" step="1" min="6" max="500"/>
</td>
<td>
<div>
<label>
<span i18n="pidTuningDynamicNotchBandwidthHz"></span>
</label>
<div class="helpicon cf_tip" i18n_title="pidTuningDynamicNotchBandwidthHzHelp" ></div>
</div>
</td>
</tr>
<tr class="newFilter dynamicNotch"> <tr class="newFilter dynamicNotch">
<td> <td>
<input type="number" name="dynamicNotchMinHz" step="1" min="60" max="1000"/> <input type="number" name="dynamicNotchMinHz" step="1" min="60" max="1000"/>