1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-17 21:35:33 +03:00

Defaults when switching rpm filtering

Added warning popup
This commit is contained in:
fgiudice98 2020-04-10 22:56:44 +02:00 committed by mikeller
parent 4a1b68a64a
commit 69603ee46b
6 changed files with 121 additions and 5 deletions

View file

@ -1468,6 +1468,14 @@
"configurationButtonSave": {
"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": {
"message": "Identifier"

View file

@ -579,6 +579,10 @@ var FC = {
dterm_notch_cutoff: 160,
dterm_notch_hz: 260,
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 = [

View file

@ -2,12 +2,18 @@
TABS.configuration = {
SHOW_OLD_BATTERY_CONFIG: false,
previousDshotBidir: null,
previousFilterDynQ: null,
previousFilterDynWidth: null,
analyticsChanges: {},
};
TABS.configuration.initialize = function (callback, scrollPosition) {
var self = this;
// Update filtering defaults based on API version
const FILTER_DEFAULT = FC.getFilterDefaults();
if (GUI.active_tab != 'configuration') {
GUI.active_tab = 'configuration';
GUI.configuration_loaded = true;
@ -171,7 +177,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_rx_config() {
var next_callback = load_html;
const next_callback = load_filter_config;
if (semver.gte(CONFIG.apiVersion, "1.31.0")) {
MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, next_callback);
} 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() {
$('#content').load("./tabs/configuration.html", process_html);
}
@ -497,6 +512,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
let dshotBidirectional_e = $('input[id="dshotBidir"]');
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 () {
let value = $(this).prop('checked');
@ -507,6 +526,31 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
self.analyticsChanges['BidirectionalDshot'] = newValue;
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) {
const dialogDynFiltersChange = $('.dialogDynFiltersChange')[0];
if (!dialogDynFiltersChange.hasAttribute('open')) {
dialogDynFiltersChange.showModal();
$('.dialogDynFiltersChange-confirmbtn').click(function() {
dialogDynFiltersChange.close();
});
}
}
});
$('input[name="motorPoles"]').val(MOTOR_CONFIG.motor_poles);
@ -1391,7 +1435,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_rx_config() {
var next_callback = save_to_eeprom;
const next_callback = save_filter_config;
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);
} else {
@ -1399,6 +1443,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() {
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")) {
const dynamicNotchWidthPercent_e = $('.pid_filter input[name="dynamicNotchWidthPercent"]');
const dynamicNotchQ_e = $('.pid_filter input[name="dynamicNotchQ"]');
$('.smartfeedforward').hide();
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));
$('.pid_filter select[name="dynamicNotchRange"]').val(FILTER_CONFIG.dyn_notch_range);
$('.pid_filter input[name="dynamicNotchWidthPercent"]').val(FILTER_CONFIG.dyn_notch_width_percent);
$('.pid_filter input[name="dynamicNotchQ"]').val(FILTER_CONFIG.dyn_notch_q);
dynamicNotchWidthPercent_e.val(FILTER_CONFIG.dyn_notch_width_percent);
dynamicNotchQ_e.val(FILTER_CONFIG.dyn_notch_q);
$('.pid_filter input[name="dynamicNotchMinHz"]').val(FILTER_CONFIG.dyn_notch_min_hz);
if (semver.gte(CONFIG.apiVersion, API_VERSION_1_43)) {
$('.pid_filter input[name="dynamicNotchMinHz"]').attr("max","250");
@ -394,7 +397,33 @@ TABS.pid_tuning.initialize = function (callback) {
if (harmonics == 0) {
$('.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);
}
const dialogDynFiltersChange = $('.dialogDynFiltersChange')[0];
if (!dialogDynFiltersChange.hasAttribute('open')) {
dialogDynFiltersChange.showModal();
$('.dialogDynFiltersChange-confirmbtn').click(function() {
dialogDynFiltersChange.close();
});
}
} 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();
} else {
$('.itermRelaxCutoff').hide();
$('.dynamicNotch').hide();

View file

@ -774,4 +774,15 @@
</div>
</div>
</div>
<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>
</div>

View file

@ -1590,7 +1590,7 @@
<a href="#" class="dialogCopyProfile-cancelbtn regular-button" i18n="dialogCopyProfileClose"></a>
</div>
</dialog>
<dialog class="dialogRatesType">
<h3 i18n="dialogRatesTypeTitle"></h3>
<div class="content">
@ -1602,4 +1602,15 @@
<a href="#" class="dialogRatesType-cancelbtn regular-button" i18n="cancel"></a>
</div>
</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>
</div>