Skip to content

Commit f6d818d

Browse files
committed
Refactor left panel
1 parent 2601582 commit f6d818d

File tree

5 files changed

+189
-203
lines changed

5 files changed

+189
-203
lines changed

locales/en/messages.json

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3779,25 +3779,34 @@
37793779
"message": "Gyro Lowpass Filters"
37803780
},
37813781
"pidTuningGyroLowpassFrequency": {
3782-
"message": "Gyro Lowpass 1 Static Cutoff Frequency [Hz]"
3782+
"message": "Cutoff Frequency [Hz]"
3783+
},
3784+
"pidTuningGyroLowpass": {
3785+
"message": "Gyro Lowpass 1"
3786+
},
3787+
"pidTuningGyroLowpassMode": {
3788+
"message": "Mode"
37833789
},
37843790
"pidTuningGyroLowpassType": {
37853791
"message": "Gyro Lowpass 1 Filter Type"
37863792
},
37873793
"pidTuningGyroLowpassDynMinFrequency": {
3788-
"message": "Gyro Lowpass 1 Dynamic Min Cutoff Frequency [Hz]"
3794+
"message": "Min Cutoff Frequency [Hz]"
37893795
},
37903796
"pidTuningGyroLowpassDynMaxFrequency": {
3791-
"message": "Gyro Lowpass 1 Dynamic Max Cutoff Frequency [Hz]"
3797+
"message": "Max Cutoff Frequency [Hz]"
37923798
},
37933799
"pidTuningGyroLowpassDynType": {
3794-
"message": "Gyro Lowpass 1 Dynamic Filter Type"
3800+
"message": "Filter Type"
3801+
},
3802+
"pidTuningGyroLowpass2": {
3803+
"message": "Gyro Lowpass 2"
37953804
},
37963805
"pidTuningGyroLowpass2Frequency": {
3797-
"message": "Gyro Lowpass 2 Static Cutoff Frequency [Hz]"
3806+
"message": "Cutoff Frequency [Hz]"
37983807
},
37993808
"pidTuningGyroLowpass2Type": {
3800-
"message": "Gyro Lowpass 2 Filter Type"
3809+
"message": "Filter Type"
38013810
},
38023811
"pidTuningGyroLowpassFilterHelp": {
38033812
"message": "Gyro lowpass filters attenuate higher frequency noise to keep it out of the PID loop. There are two independently configurable gyro filters; by default both are active.<br /><br />The first D lowpass can be static (fixed cutoff) or dynamic; the second D lowpass is always static. When a lowpass is in dynamic mode, filter will be stronger at low throttle, and the cutoff will go higher (less filtering) as throttle increases.<br /><br />Without RPM filtering, both PT1 filters should be enabled at default (or stronger) cutoffs, with lowpass 1 in dynamic mode.<br /><br />With RPM filtering, the gyro filter slider can often be moved some way to the right. On clean quads it can go all the way right, or alternatively a single static gyro lowpass filter at 500hz may be sufficient.<br /><br />A quad will have less propwash with the least gyro filter delay (sliders to the right, higher cutoff values).<br /><br />Always check for motor heat when shifting to less gyro filtering (sliders to the right). With minimal gyro filtering, it is essential to have enough D filtering! Take care!"
@@ -3808,6 +3817,12 @@
38083817
"pidTuningGyroNotchFiltersGroup": {
38093818
"message": "Gyro Notch Filters"
38103819
},
3820+
"pidTuningGyroNotchFilter": {
3821+
"message": "Gyro Notch Filter 1"
3822+
},
3823+
"pidTuningGyroNotchFilter2": {
3824+
"message": "Gyro Notch Filter 2"
3825+
},
38113826
"pidTuningGyroNotch1Frequency": {
38123827
"message": "Gyro Notch Filter 1 Center Frequency [Hz]"
38133828
},
@@ -3898,6 +3913,12 @@
38983913
"pidTuningFilterSettings": {
38993914
"message": "Profile dependent Filter Settings"
39003915
},
3916+
"pidTuningLowPassStatic": {
3917+
"message": "STATIC"
3918+
},
3919+
"pidTuningLowPassDynamic": {
3920+
"message": "DYN"
3921+
},
39013922
"pidTuningDTermLowpassFiltersGroup": {
39023923
"message": "D Term Lowpass Filters"
39033924
},

src/css/tabs/pid_tuning.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,6 @@
909909
table-layout: auto;
910910
}
911911

912-
.tab-pid_tuning table.filterTable td:first-child {
913-
width: 25%;
914-
}
915-
916912
@media only screen and (max-width: 1205px) {
917913

918914
.tab-pid_tuning .subtab-pid .spacer_left {

src/js/TuningSliders.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,9 @@ TuningSliders.updateFilterSlidersDisplay = function() {
451451
Math.floor(this.FILTER_DEFAULT.gyro_lowpass_hz * this.sliderGyroFilterMultiplier);
452452
const lp2Changed = parseInt($('.pid_filter input[name="gyroLowpass2Frequency"]').val()) !==
453453
Math.floor(this.FILTER_DEFAULT.gyro_lowpass2_hz * this.sliderGyroFilterMultiplier);
454-
const lp1Enabled = parseInt($('.pid_filter input[name="gyroLowpassDynMinFrequency"]').val());
455-
const lp1StaticEnabled = parseInt($('.pid_filter input[name="gyroLowpassFrequency"]').val());
456-
const lp2Enabled = parseInt($('.pid_filter input[name="gyroLowpass2Frequency"]').val());
454+
const lp1Enabled = parseInt($('.pid_filter input[name="gyroLowpassDynMinFrequency"]').val()) > 0;
455+
const lp1StaticEnabled = parseInt($('.pid_filter input[name="gyroLowpassFrequency"]').val()) > 0;
456+
const lp2Enabled = parseInt($('.pid_filter input[name="gyroLowpass2Frequency"]').val()) > 0;
457457

458458
const lpDynMaxChanged = parseInt($('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').val()) !==
459459
Math.floor(this.FILTER_DEFAULT.gyro_lowpass_dyn_max_hz * this.sliderGyroFilterMultiplier);
@@ -465,6 +465,13 @@ TuningSliders.updateFilterSlidersDisplay = function() {
465465

466466
const lpxOffAndChanged = lpxChanged && lpxDisabled;
467467

468+
const lpMode = parseInt($('.pid_filter select[name="gyroLowpassMode"]').val());
469+
470+
$('.pid_filter .gyroLowpass .suboption.gyroLowpassMode').toggle(lp1Enabled || lp1StaticEnabled);
471+
$('.pid_filter .gyroLowpass .suboption.gyroLowpassDyn').toggle(lp1Enabled && lpMode === 1 && !lp1Changed);
472+
$('.pid_filter .gyroLowpass .suboption.gyroLowpass').toggle(lp1StaticEnabled && lpMode === 2 && !lp1StaticChanged);
473+
$('.pid_filter .gyroLowpass2 .suboption').toggle(lp2Enabled && !lp2Changed);
474+
468475
if ((lp1Changed || lp1StaticChanged || lpDynMaxChanged || lpfDynTypeChanged || lp2Changed || lp2TypeChanged) && lpxOffAndChanged) {
469476
this.GyroSliderUnavailable = true;
470477
this.sliderGyroFilter = 0;

src/js/tabs/pid_tuning.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ TABS.pid_tuning.initialize = function (callback) {
680680
$('.pid_filter input[name="gyroNotch1Frequency"]').val(checked ? hz : 0).attr('disabled', !checked)
681681
.attr("min", checked ? 1 : 0).change();
682682
$('.pid_filter input[name="gyroNotch1Cutoff"]').attr('disabled', !checked).change();
683+
684+
$('.gyroNotch1 span.suboption').toggle(checked);
683685
});
684686

685687
$('input[id="gyroNotch2Enabled"]').change(function() {
@@ -689,6 +691,8 @@ TABS.pid_tuning.initialize = function (callback) {
689691
$('.pid_filter input[name="gyroNotch2Frequency"]').val(checked ? hz : 0).attr('disabled', !checked)
690692
.attr("min", checked ? 1 : 0).change();
691693
$('.pid_filter input[name="gyroNotch2Cutoff"]').attr('disabled', !checked).change();
694+
695+
$('.gyroNotch2 span.suboption').toggle(checked);
692696
});
693697

694698
$('input[id="dtermNotchEnabled"]').change(function() {
@@ -715,9 +719,10 @@ TABS.pid_tuning.initialize = function (callback) {
715719
$('input[id="gyroLowpassDynEnabled"]').prop('checked', false).change();
716720
}
717721
self.updateFilterWarning();
722+
TuningSliders.updateFilterSlidersDisplay();
718723
});
719724

720-
$('input[id="gyroLowpassDynEnabled"]').change(function() {
725+
$('input[id="gyroLowpassEnabled"]').change(function() {
721726
const checked = $(this).is(':checked');
722727
let cutoffMin = FILTER_DEFAULT.gyro_lowpass_dyn_min_hz;
723728
const cutoffMax = FC.FILTER_CONFIG.gyro_lowpass_dyn_max_hz;
@@ -727,17 +732,14 @@ TABS.pid_tuning.initialize = function (callback) {
727732
type = FC.FILTER_CONFIG.gyro_lowpass_type;
728733
}
729734

735+
console.log(checked);
730736
$('.pid_filter input[name="gyroLowpassDynMinFrequency"]').val(checked ? cutoffMin : 0).attr('disabled', !checked);
731737
$('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').val(checked ? cutoffMax : 0).attr('disabled', !checked);
732738
$('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').attr('disabled', !checked);
733739
$('.pid_filter select[name="gyroLowpassDynType"]').val(type).attr('disabled', !checked);
734740

735-
if (checked) {
736-
$('input[id="gyroLowpassEnabled"]').prop('checked', false).change();
737-
} else if (FC.FILTER_CONFIG.gyro_lowpass_hz > 0 && !$('input[id="gyroLowpassEnabled"]').is(':checked')) {
738-
$('input[id="gyroLowpassEnabled"]').prop('checked', true).change();
739-
}
740741
self.updateFilterWarning();
742+
TuningSliders.updateFilterSlidersDisplay();
741743
});
742744

743745
$('input[id="gyroLowpass2Enabled"]').change(function() {
@@ -756,10 +758,12 @@ TABS.pid_tuning.initialize = function (callback) {
756758
}
757759

758760
$('.pid_filter select[name="gyroLowpass2Type"]').val(type).attr('disabled', !checked);
761+
self.updateFilterWarning();
762+
TuningSliders.updateFilterSlidersDisplay();
759763
});
760764

761-
$('.pid_filter input[name="gyroLowpassDynMinFrequency"]').on('input', () => $('input[id="gyroLowpassDynEnabled"]').prop('checked', false).trigger('change'));
762-
$('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').on('input', () => $('input[id="gyroLowpassDynEnabled"]').prop('checked', false).trigger('change'));
765+
$('.pid_filter input[name="gyroLowpassDynMinFrequency"]').on('input', () => $('input[id="gyroLowpassEnabled"]').prop('checked', false).trigger('change'));
766+
$('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').on('input', () => $('input[id="gyroLowpassEnabled"]').prop('checked', false).trigger('change'));
763767
$('.pid_filter input[name="gyroLowpassFrequency"]').on('input', () => $('input[id="gyroLowpassEnabled"]').prop('checked', false).trigger('change'));
764768
$('.pid_filter input[name="gyroLowpass2Frequency"]').on('input', () => $('input[id="gyroLowpass2Enabled"]').prop('checked', false).trigger('change'));
765769

@@ -771,7 +775,7 @@ TABS.pid_tuning.initialize = function (callback) {
771775
const cutoff = FC.FILTER_CONFIG.dterm_lowpass_hz > 0 ? FC.FILTER_CONFIG.dterm_lowpass_hz : FILTER_DEFAULT.dterm_lowpass_hz;
772776
const type = FC.FILTER_CONFIG.dterm_lowpass_hz > 0 ? FC.FILTER_CONFIG.dterm_lowpass_type : FILTER_DEFAULT.dterm_lowpass_type;
773777

774-
$('.pid_filter input[name="dtermLowpassFrequency"]').val((checked /*|| disabledByDynamicLowpass*/) ? cutoff : 0);
778+
$('.pid_filter input[name="dtermLowpassFrequency"]').val((checked || disabledByDynamicLowpass) ? cutoff : 0);
775779
$('.pid_filter input[name="dtermLowpassFrequency"]').attr('disabled', !checked);
776780
$('.pid_filter select[name="dtermLowpassType"]').val(type).attr('disabled', !checked);
777781

@@ -802,7 +806,6 @@ TABS.pid_tuning.initialize = function (callback) {
802806
$('.pid_filter input[name="dtermLowpassDynMinFrequency"]').val(checked ? cutoffMin : 0);
803807
$('.pid_filter input[name="dtermLowpassDynMaxFrequency"]').val(checked ? cutoffMax : 0);
804808

805-
// conditional ternary operator does somehow not work when setting val here so we have to write it like this to set value to 0 instead of 1
806809
if (checked) {
807810
$('input[id="dtermLowpassEnabled"]').prop('checked', false).change();
808811
} else if (FC.FILTER_CONFIG.dterm_lowpass_hz > 0 && !$('input[id="dtermLowpassEnabled"]').is(':checked')) {

0 commit comments

Comments
 (0)