1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-17 13:25:24 +03:00

Merge pull request #1955 from fgiudice98/rpm-filters-defaults

This commit is contained in:
Michael Keller 2020-07-06 18:09:32 +12:00 committed by GitHub
commit 05b7e73fa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 107 additions and 6 deletions

View file

@ -1468,7 +1468,15 @@
"configurationButtonSave": { "configurationButtonSave": {
"message": "Save and Reboot" "message": "Save and Reboot"
}, },
"dialogDynFiltersChangeTitle": {
"message": "Dynamic Notch values change"
},
"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."
},
"dialogDynFiltersConfirm": {
"message": "OK"
},
"portsIdentifier": { "portsIdentifier": {
"message": "Identifier" "message": "Identifier"
}, },

View file

@ -581,6 +581,10 @@ var FC = {
dterm_notch_cutoff: 160, dterm_notch_cutoff: 160,
dterm_notch_hz: 260, dterm_notch_hz: 260,
yaw_lowpass_hz: 100, yaw_lowpass_hz: 100,
dyn_notch_q: 120,
dyn_notch_width_percent: 8,
dyn_notch_q_rpm: 250, // default with rpm filtering
dyn_notch_width_percent_rpm: 0,
}; };
DEFAULT_PIDS = [ DEFAULT_PIDS = [

View file

@ -760,3 +760,15 @@ 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();
});
}
}

View file

@ -2,12 +2,18 @@
TABS.configuration = { TABS.configuration = {
SHOW_OLD_BATTERY_CONFIG: false, SHOW_OLD_BATTERY_CONFIG: false,
previousDshotBidir: null,
previousFilterDynQ: null,
previousFilterDynWidth: null,
analyticsChanges: {}, analyticsChanges: {},
}; };
TABS.configuration.initialize = function (callback, scrollPosition) { TABS.configuration.initialize = function (callback, scrollPosition) {
var self = this; var self = this;
// Update filtering defaults based on API version
const FILTER_DEFAULT = FC.getFilterDefaults();
if (GUI.active_tab != 'configuration') { if (GUI.active_tab != 'configuration') {
GUI.active_tab = 'configuration'; GUI.active_tab = 'configuration';
GUI.configuration_loaded = true; GUI.configuration_loaded = true;
@ -171,7 +177,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
function load_rx_config() { function load_rx_config() {
var next_callback = load_html; const next_callback = load_filter_config;
if (semver.gte(CONFIG.apiVersion, "1.31.0")) { if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, next_callback); MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, next_callback);
} else { } else {
@ -179,6 +185,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
} }
function load_filter_config() {
const next_callback = load_html;
if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
MSP.send_message(MSPCodes.MSP_FILTER_CONFIG, false, false, next_callback);
} else {
next_callback();
}
}
function load_html() { function load_html() {
$('#content').load("./tabs/configuration.html", process_html); $('#content').load("./tabs/configuration.html", process_html);
} }
@ -497,6 +512,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
let dshotBidirectional_e = $('input[id="dshotBidir"]'); let dshotBidirectional_e = $('input[id="dshotBidir"]');
dshotBidirectional_e.prop('checked', MOTOR_CONFIG.use_dshot_telemetry).change(); dshotBidirectional_e.prop('checked', MOTOR_CONFIG.use_dshot_telemetry).change();
self.previousDshotBidir = MOTOR_CONFIG.use_dshot_telemetry;
self.previousFilterDynQ = FILTER_CONFIG.dyn_notch_q;
self.previousFilterDynWidth = FILTER_CONFIG.dyn_notch_width_percent;
dshotBidirectional_e.change(function () { dshotBidirectional_e.change(function () {
let value = $(this).prop('checked'); let value = $(this).prop('checked');
@ -507,6 +526,23 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
self.analyticsChanges['BidirectionalDshot'] = newValue; self.analyticsChanges['BidirectionalDshot'] = newValue;
MOTOR_CONFIG.use_dshot_telemetry = value; MOTOR_CONFIG.use_dshot_telemetry = value;
FILTER_CONFIG.dyn_notch_width_percent = self.previousFilterDynWidth;
FILTER_CONFIG.dyn_notch_q = self.previousFilterDynQ;
if (FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0) { // if rpm filter is active
if (value && !self.previousDshotBidir) {
FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent_rpm;
FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q_rpm;
} else if (!value && self.previousDshotBidir) {
FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent;
FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q;
}
}
if (FILTER_CONFIG.dyn_notch_width_percent !== self.previousFilterDynWidth) {
showDialogDynFiltersChange();
}
}); });
$('input[name="motorPoles"]').val(MOTOR_CONFIG.motor_poles); $('input[name="motorPoles"]').val(MOTOR_CONFIG.motor_poles);
@ -1391,7 +1427,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
function save_rx_config() { function save_rx_config() {
var next_callback = save_to_eeprom; const next_callback = save_filter_config;
if (semver.gte(CONFIG.apiVersion, "1.20.0")) { if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, next_callback); MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, next_callback);
} else { } else {
@ -1399,6 +1435,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
} }
function save_filter_config() {
const next_callback = save_to_eeprom;
if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
MSP.send_message(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG), false, next_callback);
} else {
next_callback();
}
}
function save_to_eeprom() { function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, reboot); MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, reboot);
} }

View file

@ -359,6 +359,9 @@ TABS.pid_tuning.initialize = function (callback) {
} }
if (semver.gte(CONFIG.apiVersion, "1.42.0")) { if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
const dynamicNotchWidthPercent_e = $('.pid_filter input[name="dynamicNotchWidthPercent"]');
const dynamicNotchQ_e = $('.pid_filter input[name="dynamicNotchQ"]');
$('.smartfeedforward').hide(); $('.smartfeedforward').hide();
if (FEATURE_CONFIG.features.isEnabled('DYNAMIC_FILTER')) { if (FEATURE_CONFIG.features.isEnabled('DYNAMIC_FILTER')) {
@ -368,8 +371,8 @@ TABS.pid_tuning.initialize = function (callback) {
} }
$('.dynamicNotchRange').toggle(semver.lt(CONFIG.apiVersion, API_VERSION_1_43)); $('.dynamicNotchRange').toggle(semver.lt(CONFIG.apiVersion, API_VERSION_1_43));
$('.pid_filter select[name="dynamicNotchRange"]').val(FILTER_CONFIG.dyn_notch_range); $('.pid_filter select[name="dynamicNotchRange"]').val(FILTER_CONFIG.dyn_notch_range);
$('.pid_filter input[name="dynamicNotchWidthPercent"]').val(FILTER_CONFIG.dyn_notch_width_percent); dynamicNotchWidthPercent_e.val(FILTER_CONFIG.dyn_notch_width_percent);
$('.pid_filter input[name="dynamicNotchQ"]').val(FILTER_CONFIG.dyn_notch_q); dynamicNotchQ_e.val(FILTER_CONFIG.dyn_notch_q);
$('.pid_filter input[name="dynamicNotchMinHz"]').val(FILTER_CONFIG.dyn_notch_min_hz); $('.pid_filter input[name="dynamicNotchMinHz"]').val(FILTER_CONFIG.dyn_notch_min_hz);
if (semver.gte(CONFIG.apiVersion, API_VERSION_1_43)) { if (semver.gte(CONFIG.apiVersion, API_VERSION_1_43)) {
$('.pid_filter input[name="dynamicNotchMinHz"]').attr("max","250"); $('.pid_filter input[name="dynamicNotchMinHz"]').attr("max","250");
@ -394,7 +397,25 @@ TABS.pid_tuning.initialize = function (callback) {
if (harmonics == 0) { if (harmonics == 0) {
$('.pid_filter input[name="rpmFilterHarmonics"]').val(FILTER_DEFAULT.gyro_rpm_notch_harmonics); $('.pid_filter input[name="rpmFilterHarmonics"]').val(FILTER_DEFAULT.gyro_rpm_notch_harmonics);
} }
if (checked !== (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);
dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q_rpm);
} else {
dynamicNotchWidthPercent_e.val(FILTER_DEFAULT.dyn_notch_width_percent);
dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q);
}
showDialogDynFiltersChange();
} else { // same value, return saved values
dynamicNotchWidthPercent_e.val(FILTER_CONFIG.dyn_notch_width_percent);
dynamicNotchQ_e.val(FILTER_CONFIG.dyn_notch_q);
}
}).prop('checked', FILTER_CONFIG.gyro_rpm_notch_harmonics != 0).change(); }).prop('checked', FILTER_CONFIG.gyro_rpm_notch_harmonics != 0).change();
} else { } else {
$('.itermRelaxCutoff').hide(); $('.itermRelaxCutoff').hide();
$('.dynamicNotch').hide(); $('.dynamicNotch').hide();

View file

@ -413,6 +413,17 @@
</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>

View file

@ -1605,7 +1605,7 @@
<a href="#" class="dialogCopyProfile-cancelbtn regular-button" i18n="dialogCopyProfileClose"></a> <a href="#" class="dialogCopyProfile-cancelbtn regular-button" i18n="dialogCopyProfileClose"></a>
</div> </div>
</dialog> </dialog>
<dialog class="dialogRatesType"> <dialog class="dialogRatesType">
<h3 i18n="dialogRatesTypeTitle"></h3> <h3 i18n="dialogRatesTypeTitle"></h3>
<div class="content"> <div class="content">