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

Rpm defaults fix

Change dialog

sonar fixes

sonar fix

fix text

no values change if not dialog shows

typo
This commit is contained in:
Asizon 2021-12-25 20:40:21 +01:00
parent 90f15faf79
commit b7085a5926
6 changed files with 40 additions and 53 deletions

View file

@ -1512,10 +1512,7 @@
"message": "Dynamic Notch values change" "message": "Dynamic Notch values change"
}, },
"dialogDynFiltersChangeNote": { "dialogDynFiltersChangeNote": {
"message": "<span class=\"message-negative\"><b>WARNING: Some dynamic notch values have been changed to default values</b></span> because the RPM filtering has been activated/deactivated.<br> Please, check before flying." "message": "<span class=\"message-negative\"><b>WARNING: This change will enable/disable RPM filtering, increasing/decreasing filter delay/effectiveness.</b></span><br><br>Reset the dynamic notch filters to recommended values?"
},
"dialogDynFiltersConfirm": {
"message": "OK"
}, },
"portsIdentifier": { "portsIdentifier": {
"message": "Identifier" "message": "Identifier"

View file

@ -642,8 +642,7 @@ const FC = {
dyn_notch_q: 120, dyn_notch_q: 120,
dyn_notch_width_percent: 8, dyn_notch_width_percent: 8,
dyn_notch_count: 3, dyn_notch_count: 3,
dyn_notch_q_rpm: 250, // default with rpm filtering dyn_notch_q_rpm: 500, // default with rpm filtering
dyn_notch_width_percent_rpm: 0,
dyn_notch_count_rpm: 1, 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,
@ -858,7 +857,6 @@ const FC = {
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)) { if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_44)) {
versionFilterDefaults.dyn_notch_q_rpm = 500;
versionFilterDefaults.dyn_notch_q = 300; versionFilterDefaults.dyn_notch_q = 300;
versionFilterDefaults.gyro_lowpass_hz = 250; versionFilterDefaults.gyro_lowpass_hz = 250;
versionFilterDefaults.gyro_lowpass_dyn_min_hz = 250; versionFilterDefaults.gyro_lowpass_dyn_min_hz = 250;

View file

@ -725,21 +725,8 @@ function showErrorDialog(message) {
dialog.showModal(); dialog.showModal();
} }
function showDialogDynFiltersChange() {
const dialogDynFiltersChange = $('.dialogDynFiltersChange')[0];
if (!dialogDynFiltersChange.hasAttribute('open')) {
dialogDynFiltersChange.showModal();
$('.dialogDynFiltersChange-confirmbtn').click(function() {
dialogDynFiltersChange.close();
});
}
}
// TODO: all of these are used as globals in other parts. // TODO: all of these are used as globals in other parts.
// once moved to modules extract to own module. // once moved to modules extract to own module.
window.showDialogDynFiltersChange = showDialogDynFiltersChange;
window.googleAnalytics = analytics; window.googleAnalytics = analytics;
window.analytics = null; window.analytics = null;
window.showErrorDialog = showErrorDialog; window.showErrorDialog = showErrorDialog;

View file

@ -3,7 +3,6 @@
TABS.motors = { TABS.motors = {
previousDshotBidir: null, previousDshotBidir: null,
previousFilterDynQ: null, previousFilterDynQ: null,
previousFilterDynWidth: null,
previousFilterDynCount: null, previousFilterDynCount: null,
analyticsChanges: {}, analyticsChanges: {},
configHasChanged: false, configHasChanged: false,
@ -666,41 +665,47 @@ TABS.motors.initialize = function (callback) {
unsyncedPWMSwitchElement.prop('checked', FC.PID_ADVANCED_CONFIG.use_unsyncedPwm !== 0).trigger("change"); unsyncedPWMSwitchElement.prop('checked', FC.PID_ADVANCED_CONFIG.use_unsyncedPwm !== 0).trigger("change");
$('input[name="unsyncedpwmfreq"]').val(FC.PID_ADVANCED_CONFIG.motor_pwm_rate); $('input[name="unsyncedpwmfreq"]').val(FC.PID_ADVANCED_CONFIG.motor_pwm_rate);
$('input[name="digitalIdlePercent"]').val(FC.PID_ADVANCED_CONFIG.digitalIdlePercent); $('input[name="digitalIdlePercent"]').val(FC.PID_ADVANCED_CONFIG.digitalIdlePercent);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
dshotBidirElement.prop('checked', FC.MOTOR_CONFIG.use_dshot_telemetry).trigger("change"); dshotBidirElement.prop('checked', FC.MOTOR_CONFIG.use_dshot_telemetry).trigger("change");
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.previousFilterDynCount = FC.FILTER_CONFIG.dyn_notch_count; 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');
const newValue = (value !== FC.MOTOR_CONFIG.use_dshot_telemetry) ? 'On' : 'Off'; const newValue = (value !== FC.MOTOR_CONFIG.use_dshot_telemetry) ? 'On' : 'Off';
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_count = self.previousFilterDynCount; 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 const dialogSettings = {
title: i18n.getMessage("dialogDynFiltersChangeTitle"),
text: i18n.getMessage("dialogDynFiltersChangeNote"),
buttonYesText: i18n.getMessage("presetsWarningDialogYesButton"),
buttonNoText: i18n.getMessage("presetsWarningDialogNoButton"),
buttonYesCallback: () => _dynFilterChange(),
buttonNoCallback: null,
};
const _dynFilterChange = function() {
if (value && !self.previousDshotBidir) { if (value && !self.previousDshotBidir) {
FC.FILTER_CONFIG.dyn_notch_count = FILTER_DEFAULT.dyn_notch_count_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_count = FILTER_DEFAULT.dyn_notch_count; 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;
} }
} };
const dynFilterNeedChange = (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) ? (FC.FILTER_CONFIG.dyn_notch_count !== self.previousFilterDynCount) : if (FC.MOTOR_CONFIG.use_dshot_telemetry !== self.previousDshotBidir) { // if rpmFilterEnabled is not the same value as saved in the fc
(FC.FILTER_CONFIG.dyn_notch_width_percent !== self.previousFilterDynWidth); GUI.showYesNoDialog(dialogSettings);
} else {
if (dynFilterNeedChange) { FC.FILTER_CONFIG.dyn_notch_count = self.previousFilterDynCount;
showDialogDynFiltersChange(); FC.FILTER_CONFIG.dyn_notch_q = self.previousFilterDynQ;
} }
}); });

View file

@ -5,6 +5,8 @@ TABS.pid_tuning = {
showAllPids: false, showAllPids: false,
updating: true, updating: true,
dirty: false, dirty: false,
previousFilterDynQ: null,
previousFilterDynCount: null,
currentProfile: null, currentProfile: null,
currentRateProfile: null, currentRateProfile: null,
currentRatesType: null, currentRatesType: null,
@ -446,28 +448,37 @@ TABS.pid_tuning.initialize = function (callback) {
rpmFilterHarmonics_e.attr('disabled', !checked); rpmFilterHarmonics_e.attr('disabled', !checked);
rpmFilterMinHz_e.attr('disabled', !checked); rpmFilterMinHz_e.attr('disabled', !checked);
self.previousFilterDynQ = FC.FILTER_CONFIG.dyn_notch_q;
self.previousFilterDynCount = FC.FILTER_CONFIG.dyn_notch_count;
if (harmonics == 0) { if (harmonics == 0) {
rpmFilterHarmonics_e.val(FILTER_DEFAULT.gyro_rpm_notch_harmonics); rpmFilterHarmonics_e.val(FILTER_DEFAULT.gyro_rpm_notch_harmonics);
} }
if (checked !== (FC.FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0)) { // if rpmFilterEnabled is not the same value as saved in the fc const dialogSettings = {
title: i18n.getMessage("dialogDynFiltersChangeTitle"),
text: i18n.getMessage("dialogDynFiltersChangeNote"),
buttonYesText: i18n.getMessage("presetsWarningDialogYesButton"),
buttonNoText: i18n.getMessage("presetsWarningDialogNoButton"),
buttonYesCallback: () => _dynFilterChange(),
buttonNoCallback: null,
};
const _dynFilterChange = function() {
if (checked) { if (checked) {
dynamicNotchCount_e.val(FILTER_DEFAULT.dyn_notch_count_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 {
dynamicNotchCount_e.val(FILTER_DEFAULT.dyn_notch_count); 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(); if (checked !== (FC.FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0)) { // if rpmFilterEnabled is not the same value as saved in the fc
GUI.showYesNoDialog(dialogSettings);
} else { // same value, return saved values } else {
dynamicNotchCount_e.val(FC.FILTER_CONFIG.dyn_notch_count); dynamicNotchCount_e.val(self.previousFilterDynCount);
dynamicNotchQ_e.val(FC.FILTER_CONFIG.dyn_notch_q); dynamicNotchQ_e.val(self.previousFilterDynQ);
dynamicNotchWidthPercent_e.val(FC.FILTER_CONFIG.dyn_notch_width_percent);
} }
$('.rpmFilter span.suboption').toggle(checked); $('.rpmFilter span.suboption').toggle(checked);

View file

@ -459,17 +459,6 @@
</div> </div>
</dialog> </dialog>
<dialog class="dialogDynFiltersChange">
<h3 i18n="dialogDynFiltersChangeTitle"></h3>
<div class="content">
<div i18n="dialogDynFiltersChangeNote" style="margin-top: 10px"></div>
</div>
<div class="buttons">
<a href="#" class="dialogDynFiltersChange-confirmbtn regular-button" i18n="dialogDynFiltersConfirm"></a>
</div>
</dialog>
<ul class="hidden"> <!-- Sonar says so --> <ul class="hidden"> <!-- Sonar says so -->
<li id="dialogReportProblems-listItemTemplate" class="dialogReportProblems-listItem"></li> <li id="dialogReportProblems-listItemTemplate" class="dialogReportProblems-listItem"></li>
</ul> </ul>