From b6fdc0ea0683ff810d36e3bd4f6bd7c63274c07d Mon Sep 17 00:00:00 2001 From: Miguel Angel Mulero Martinez Date: Sat, 9 Jun 2018 19:59:27 +0200 Subject: [PATCH] Fix max cutoff when reactivating notch --- src/js/tabs/pid_tuning.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index a698327b..d123c50e 100755 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -303,8 +303,9 @@ TABS.pid_tuning.initialize = function (callback) { var checked = $(this).is(':checked'); var hz = FILTER_CONFIG.gyro_notch_hz > 0 ? FILTER_CONFIG.gyro_notch_hz : DEFAULT.gyro_notch_hz; var cutoff = FILTER_CONFIG.gyro_notch_cutoff > 0 ? FILTER_CONFIG.gyro_notch_cutoff : DEFAULT.gyro_notch_cutoff; - - $('.pid_filter input[name="gyroNotch1Frequency"]').val(checked ? hz : 0).attr('disabled', !checked); + + $('.pid_filter input[name="gyroNotch1Frequency"]').val(checked ? hz : 0).attr('disabled', !checked) + .attr("min", checked ? 1 : 0).change(); $('.pid_filter input[name="gyroNotch1Cutoff"]').attr('disabled', !checked); }); @@ -313,7 +314,8 @@ TABS.pid_tuning.initialize = function (callback) { var hz = FILTER_CONFIG.gyro_notch2_hz > 0 ? FILTER_CONFIG.gyro_notch2_hz : DEFAULT.gyro_notch2_hz; var cutoff = FILTER_CONFIG.gyro_notch2_cutoff > 0 ? FILTER_CONFIG.gyro_notch2_cutoff : DEFAULT.gyro_notch2_cutoff; - $('.pid_filter input[name="gyroNotch2Frequency"]').val(checked ? hz : 0).attr('disabled', !checked); + $('.pid_filter input[name="gyroNotch2Frequency"]').val(checked ? hz : 0).attr('disabled', !checked) + .attr("min", checked ? 1 : 0).change(); $('.pid_filter input[name="gyroNotch2Cutoff"]').attr('disabled', !checked); }); @@ -322,7 +324,8 @@ TABS.pid_tuning.initialize = function (callback) { var hz = FILTER_CONFIG.dterm_notch_hz > 0 ? FILTER_CONFIG.dterm_notch_hz : DEFAULT.dterm_notch_hz; var cutoff = FILTER_CONFIG.dterm_notch_cutoff > 0 ? FILTER_CONFIG.dterm_notch_cutoff : DEFAULT.dterm_notch_cutoff; - $('.pid_filter input[name="dTermNotchFrequency"]').val(checked ? hz : 0).attr('disabled', !checked); + $('.pid_filter input[name="dTermNotchFrequency"]').val(checked ? hz : 0).attr('disabled', !checked) + .attr("min", checked ? 1 : 0).change(); $('.pid_filter input[name="dTermNotchCutoff"]').attr('disabled', !checked); }); @@ -373,9 +376,10 @@ TABS.pid_tuning.initialize = function (callback) { var cutoff = $(".pid_filter input[name='" + cutoffName + "']").val(); // Change the max and refresh the value if needed - $(".pid_filter input[name='" + cutoffName + "']").attr("max",frecuency - 1); + var maxCutoff = frecuency == 0 ? 0 : frecuency - 1; + $(".pid_filter input[name='" + cutoffName + "']").attr("max", maxCutoff); if (cutoff >= frecuency) { - $(".pid_filter input[name='" + cutoffName + "']").val(frecuency - 1); + $(".pid_filter input[name='" + cutoffName + "']").val(maxCutoff); } }