diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 74efbfa3..4395599e 100755 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -270,26 +270,29 @@ TABS.pid_tuning.initialize = function (callback) { $('input[id="gyroNotch1Enabled"]').change(function() { var checked = $(this).is(':checked'); - $('.pid_filter input[name="gyroNotch1Frequency"]').val(checked ? DEFAULT.gyro_soft_notch_hz_1 : 0) - .attr('disabled', !checked); - $('.pid_filter input[name="gyroNotch1Cutoff"]').val(checked ? DEFAULT.gyro_soft_notch_cutoff_1 : 0) - .attr('disabled', !checked); + var hz = FILTER_CONFIG.gyro_soft_notch_hz_1 > 0 ? FILTER_CONFIG.gyro_soft_notch_hz_1 : DEFAULT.gyro_soft_notch_hz_1; + var cutoff = FILTER_CONFIG.gyro_soft_notch_cutoff_1 > 0 ? FILTER_CONFIG.gyro_soft_notch_cutoff_1 : DEFAULT.gyro_soft_notch_cutoff_1; + + $('.pid_filter input[name="gyroNotch1Frequency"]').val(checked ? hz : 0).attr('disabled', !checked); + $('.pid_filter input[name="gyroNotch1Cutoff"]').val(checked ? cutoff : 0).attr('disabled', !checked); }); $('input[id="gyroNotch2Enabled"]').change(function() { var checked = $(this).is(':checked'); - $('.pid_filter input[name="gyroNotch2Frequency"]').val(checked ? DEFAULT.gyro_soft_notch_hz_2 : 0) - .attr('disabled', !checked); - $('.pid_filter input[name="gyroNotch2Cutoff"]').val(checked ? DEFAULT.gyro_soft_notch_cutoff_2 : 0) - .attr('disabled', !checked); + var hz = FILTER_CONFIG.gyro_soft_notch_hz_2 > 0 ? FILTER_CONFIG.gyro_soft_notch_hz_2 : DEFAULT.gyro_soft_notch_hz_2; + var cutoff = FILTER_CONFIG.gyro_soft_notch_cutoff_2 > 0 ? FILTER_CONFIG.gyro_soft_notch_cutoff_2 : DEFAULT.gyro_soft_notch_cutoff_2; + + $('.pid_filter input[name="gyroNotch2Frequency"]').val(checked ? hz : 0).attr('disabled', !checked); + $('.pid_filter input[name="gyroNotch2Cutoff"]').val(checked ? cutoff : 0).attr('disabled', !checked); }); $('input[id="dtermNotchEnabled"]').change(function() { var checked = $(this).is(':checked'); - $('.pid_filter input[name="dTermNotchFrequency"]').val(checked ? DEFAULT.dterm_notch_hz : 0) - .attr('disabled', !checked); - $('.pid_filter input[name="dTermNotchCutoff"]').val(checked ? DEFAULT.dterm_notch_cutoff : 0) - .attr('disabled', !checked); + 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="dTermNotchCutoff"]').val(checked ? cutoff : 0).attr('disabled', !checked); }); $('input[id="gyroNotch1Enabled"]').prop('checked', FILTER_CONFIG.gyro_soft_notch_cutoff_1 != 0).change();