@@ -382,114 +382,120 @@ TABS.pid_tuning.initialize = function (callback) {
382382 $ ( 'input[id="gyroNotch1Enabled"]' ) . change ( function ( ) {
383383 var checked = $ ( this ) . is ( ':checked' ) ;
384384 var hz = FILTER_CONFIG . gyro_notch_hz > 0 ? FILTER_CONFIG . gyro_notch_hz : FILTER_DEFAULT . gyro_notch_hz ;
385- var cutoff = FILTER_CONFIG . gyro_notch_cutoff > 0 ? FILTER_CONFIG . gyro_notch_cutoff : FILTER_DEFAULT . gyro_notch_cutoff ;
386385
387386 $ ( '.pid_filter input[name="gyroNotch1Frequency"]' ) . val ( checked ? hz : 0 ) . attr ( 'disabled' , ! checked )
388387 . attr ( "min" , checked ? 1 : 0 ) . change ( ) ;
389- $ ( '.pid_filter input[name="gyroNotch1Cutoff"]' ) . val ( checked ? cutoff : 0 ) . attr ( 'disabled' , ! checked ) . change ( ) ;
388+ $ ( '.pid_filter input[name="gyroNotch1Cutoff"]' ) . attr ( 'disabled' , ! checked ) . change ( ) ;
390389 } ) ;
391390
392391 $ ( 'input[id="gyroNotch2Enabled"]' ) . change ( function ( ) {
393392 var checked = $ ( this ) . is ( ':checked' ) ;
394393 var hz = FILTER_CONFIG . gyro_notch2_hz > 0 ? FILTER_CONFIG . gyro_notch2_hz : FILTER_DEFAULT . gyro_notch2_hz ;
395- var cutoff = FILTER_CONFIG . gyro_notch2_cutoff > 0 ? FILTER_CONFIG . gyro_notch2_cutoff : FILTER_DEFAULT . gyro_notch2_cutoff ;
396394
397395 $ ( '.pid_filter input[name="gyroNotch2Frequency"]' ) . val ( checked ? hz : 0 ) . attr ( 'disabled' , ! checked )
398396 . attr ( "min" , checked ? 1 : 0 ) . change ( ) ;
399- $ ( '.pid_filter input[name="gyroNotch2Cutoff"]' ) . val ( checked ? cutoff : 0 ) . attr ( 'disabled' , ! checked ) . change ( ) ;
397+ $ ( '.pid_filter input[name="gyroNotch2Cutoff"]' ) . attr ( 'disabled' , ! checked ) . change ( ) ;
400398 } ) ;
401399
402400 $ ( 'input[id="dtermNotchEnabled"]' ) . change ( function ( ) {
403401 var checked = $ ( this ) . is ( ':checked' ) ;
404402 var hz = FILTER_CONFIG . dterm_notch_hz > 0 ? FILTER_CONFIG . dterm_notch_hz : FILTER_DEFAULT . dterm_notch_hz ;
405- var cutoff = FILTER_CONFIG . dterm_notch_cutoff > 0 ? FILTER_CONFIG . dterm_notch_cutoff : FILTER_DEFAULT . dterm_notch_cutoff ;
406403
407404 $ ( '.pid_filter input[name="dTermNotchFrequency"]' ) . val ( checked ? hz : 0 ) . attr ( 'disabled' , ! checked )
408405 . attr ( "min" , checked ? 1 : 0 ) . change ( ) ;
409- $ ( '.pid_filter input[name="dTermNotchCutoff"]' ) . val ( checked ? cutoff : 0 ) . attr ( 'disabled' , ! checked ) . change ( ) ;
406+ $ ( '.pid_filter input[name="dTermNotchCutoff"]' ) . attr ( 'disabled' , ! checked ) . change ( ) ;
410407 } ) ;
411408
412409 $ ( 'input[id="gyroLowpassEnabled"]' ) . change ( function ( ) {
413410 var checked = $ ( this ) . is ( ':checked' ) ;
411+ var disabledByDynamicLowpass = $ ( 'input[id="gyroLowpassDynEnabled"]' ) . is ( ':checked' ) ;
412+
414413 var cutoff = FILTER_CONFIG . gyro_lowpass_hz > 0 ? FILTER_CONFIG . gyro_lowpass_hz : FILTER_DEFAULT . gyro_lowpass_hz ;
415- var type = FILTER_CONFIG . gyro_lowpass_type > 0 ? FILTER_CONFIG . gyro_lowpass_type : FILTER_DEFAULT . gyro_lowpass_type ;
414+ var type = FILTER_CONFIG . gyro_lowpass_hz > 0 ? FILTER_CONFIG . gyro_lowpass_type : FILTER_DEFAULT . gyro_lowpass_type ;
416415
417- $ ( '.pid_filter input[name="gyroLowpassFrequency"]' ) . val ( checked ? cutoff : 0 ) . attr ( 'disabled' , ! checked ) ;
418- $ ( '.pid_filter select[name="gyroLowpassType"]' ) . val ( checked ? type : 0 ) . attr ( 'disabled' , ! checked ) ;
416+ $ ( '.pid_filter input[name="gyroLowpassFrequency"]' ) . val ( ( checked || disabledByDynamicLowpass ) ? cutoff : 0 ) . attr ( 'disabled' , ! checked ) ;
417+ $ ( '.pid_filter select[name="gyroLowpassType"]' ) . val ( type ) . attr ( 'disabled' , ! checked ) ;
419418
420419 if ( checked ) {
421420 $ ( 'input[id="gyroLowpassDynEnabled"]' ) . prop ( 'checked' , false ) . change ( ) ;
422421 }
423-
422+ self . updateFilterWarning ( ) ;
424423 } ) ;
425424
426425 $ ( 'input[id="gyroLowpassDynEnabled"]' ) . change ( function ( ) {
427426 var checked = $ ( this ) . is ( ':checked' ) ;
428427 var cutoff_min = FILTER_DEFAULT . gyro_lowpass_dyn_min_hz ;
429- var cutoff_max = FILTER_DEFAULT . gyro_lowpass_dyn_max_hz ;
428+ var type = FILTER_DEFAULT . gyro_lowpass_type ;
430429 if ( FILTER_CONFIG . gyro_lowpass_dyn_min_hz > 0 && FILTER_CONFIG . gyro_lowpass_dyn_min_hz < FILTER_CONFIG . gyro_lowpass_dyn_max_hz ) {
431430 cutoff_min = FILTER_CONFIG . gyro_lowpass_dyn_min_hz ;
432- cutoff_max = FILTER_CONFIG . gyro_lowpass_dyn_max_hz ;
431+ type = FILTER_CONFIG . gyro_lowpass_type ;
433432 }
434- var type = FILTER_CONFIG . gyro_lowpass_type > 0 ? FILTER_CONFIG . gyro_lowpass_type : FILTER_DEFAULT . gyro_lowpass_type ;
435433
436434 $ ( '.pid_filter input[name="gyroLowpassDynMinFrequency"]' ) . val ( checked ? cutoff_min : 0 ) . attr ( 'disabled' , ! checked ) ;
437435 $ ( '.pid_filter input[name="gyroLowpassDynMaxFrequency"]' ) . attr ( 'disabled' , ! checked ) ;
438- $ ( '.pid_filter select[name="gyroLowpassDynType"]' ) . val ( checked ? type : 0 ) . attr ( 'disabled' , ! checked ) ;
436+ $ ( '.pid_filter select[name="gyroLowpassDynType"]' ) . val ( type ) . attr ( 'disabled' , ! checked ) ;
439437
440438 if ( checked ) {
441439 $ ( 'input[id="gyroLowpassEnabled"]' ) . prop ( 'checked' , false ) . change ( ) ;
440+ } else if ( FILTER_CONFIG . gyro_lowpass_hz > 0 && ! $ ( 'input[id="gyroLowpassEnabled"]' ) . is ( ':checked' ) ) {
441+ $ ( 'input[id="gyroLowpassEnabled"]' ) . prop ( 'checked' , true ) . change ( ) ;
442442 }
443+ self . updateFilterWarning ( ) ;
443444 } ) ;
444445
445446 $ ( 'input[id="gyroLowpass2Enabled"]' ) . change ( function ( ) {
446447 var checked = $ ( this ) . is ( ':checked' ) ;
447448 var cutoff = FILTER_CONFIG . gyro_lowpass2_hz > 0 ? FILTER_CONFIG . gyro_lowpass2_hz : FILTER_DEFAULT . gyro_lowpass2_hz ;
448- var type = FILTER_CONFIG . gyro_lowpass2_type > 0 ? FILTER_CONFIG . gyro_lowpass2_type : FILTER_DEFAULT . gyro_lowpass2_type ;
449+ var type = FILTER_CONFIG . gyro_lowpass2_hz > 0 ? FILTER_CONFIG . gyro_lowpass2_type : FILTER_DEFAULT . gyro_lowpass2_type ;
449450
450451 $ ( '.pid_filter input[name="gyroLowpass2Frequency"]' ) . val ( checked ? cutoff : 0 ) . attr ( 'disabled' , ! checked ) ;
451- $ ( '.pid_filter select[name="gyroLowpass2Type"]' ) . val ( checked ? type : 0 ) . attr ( 'disabled' , ! checked ) ;
452+ $ ( '.pid_filter select[name="gyroLowpass2Type"]' ) . val ( type ) . attr ( 'disabled' , ! checked ) ;
452453 } ) ;
453454
454455 $ ( 'input[id="dtermLowpassEnabled"]' ) . change ( function ( ) {
455456 var checked = $ ( this ) . is ( ':checked' ) ;
457+ var disabledByDynamicLowpass = $ ( 'input[id="dtermLowpassDynEnabled"]' ) . is ( ':checked' ) ;
458+
456459 var cutoff = FILTER_CONFIG . dterm_lowpass_hz > 0 ? FILTER_CONFIG . dterm_lowpass_hz : FILTER_DEFAULT . dterm_lowpass_hz ;
457- var type = FILTER_CONFIG . dterm_lowpass_type > 0 ? FILTER_CONFIG . dterm_lowpass_type : FILTER_DEFAULT . dterm_lowpass_type ;
460+ var type = FILTER_CONFIG . dterm_lowpass_hz > 0 ? FILTER_CONFIG . dterm_lowpass_type : FILTER_DEFAULT . dterm_lowpass_type ;
458461
459- $ ( '.pid_filter input[name="dtermLowpassFrequency"]' ) . val ( checked ? cutoff : 0 ) . attr ( 'disabled' , ! checked ) ;
460- $ ( '.pid_filter select[name="dtermLowpassType"]' ) . val ( checked ? type : 0 ) . attr ( 'disabled' , ! checked ) ;
462+ $ ( '.pid_filter input[name="dtermLowpassFrequency"]' ) . val ( ( checked || disabledByDynamicLowpass ) ? cutoff : 0 ) . attr ( 'disabled' , ! checked ) ;
463+ $ ( '.pid_filter select[name="dtermLowpassType"]' ) . val ( type ) . attr ( 'disabled' , ! checked ) ;
461464
462465 if ( checked ) {
463466 $ ( 'input[id="dtermLowpassDynEnabled"]' ) . prop ( 'checked' , false ) . change ( ) ;
464467 }
468+ self . updateFilterWarning ( ) ;
465469 } ) ;
466470
467471 $ ( 'input[id="dtermLowpassDynEnabled"]' ) . change ( function ( ) {
468472 var checked = $ ( this ) . is ( ':checked' ) ;
469473 var cutoff_min = FILTER_DEFAULT . dterm_lowpass_dyn_min_hz ;
470- var cutoff_max = FILTER_DEFAULT . dterm_lowpass_dyn_max_hz ;
474+ var type = FILTER_DEFAULT . dterm_lowpass_type ;
471475 if ( FILTER_CONFIG . dterm_lowpass_dyn_min_hz > 0 && FILTER_CONFIG . dterm_lowpass_dyn_min_hz < FILTER_CONFIG . dterm_lowpass_dyn_max_hz ) {
472476 cutoff_min = FILTER_CONFIG . dterm_lowpass_dyn_min_hz ;
473- cutoff_max = FILTER_CONFIG . dterm_lowpass_dyn_max_hz ;
477+ type = FILTER_CONFIG . dterm_lowpass_type ;
474478 }
475- var type = FILTER_CONFIG . dterm_lowpass_type > 0 ? FILTER_CONFIG . dterm_lowpass_type : FILTER_DEFAULT . dterm_lowpass_type ;
476479
477480 $ ( '.pid_filter input[name="dtermLowpassDynMinFrequency"]' ) . val ( checked ? cutoff_min : 0 ) . attr ( 'disabled' , ! checked ) ;
478- $ ( '.pid_filter input[name="dtermLowpassDynMaxFrequency"]' ) . val ( checked ? cutoff_max : 0 ) . attr ( 'disabled' , ! checked ) ;
479- $ ( '.pid_filter select[name="dtermLowpassDynType"]' ) . val ( checked ? type : 0 ) . attr ( 'disabled' , ! checked ) ;
481+ $ ( '.pid_filter input[name="dtermLowpassDynMaxFrequency"]' ) . attr ( 'disabled' , ! checked ) ;
482+ $ ( '.pid_filter select[name="dtermLowpassDynType"]' ) . val ( type ) . attr ( 'disabled' , ! checked ) ;
480483
481484 if ( checked ) {
482485 $ ( 'input[id="dtermLowpassEnabled"]' ) . prop ( 'checked' , false ) . change ( ) ;
486+ } else if ( FILTER_CONFIG . dterm_lowpass_hz > 0 && ! $ ( 'input[id="dtermLowpassEnabled"]' ) . is ( ':checked' ) ) {
487+ $ ( 'input[id="dtermLowpassEnabled"]' ) . prop ( 'checked' , true ) . change ( ) ;
483488 }
489+ self . updateFilterWarning ( ) ;
484490 } ) ;
485491
486492 $ ( 'input[id="dtermLowpass2Enabled"]' ) . change ( function ( ) {
487493 var checked = $ ( this ) . is ( ':checked' ) ;
488494 var cutoff = FILTER_CONFIG . dterm_lowpass2_hz > 0 ? FILTER_CONFIG . dterm_lowpass2_hz : FILTER_DEFAULT . dterm_lowpass2_hz ;
489- var type = FILTER_CONFIG . dterm_lowpass2_type > 0 ? FILTER_CONFIG . dterm_lowpass2_type : FILTER_DEFAULT . dterm_lowpass2_type ;
495+ var type = FILTER_CONFIG . dterm_lowpass2_hz > 0 ? FILTER_CONFIG . dterm_lowpass2_type : FILTER_DEFAULT . dterm_lowpass2_type ;
490496
491497 $ ( '.pid_filter input[name="dtermLowpass2Frequency"]' ) . val ( checked ? cutoff : 0 ) . attr ( 'disabled' , ! checked ) ;
492- $ ( '.pid_filter select[name="dtermLowpass2Type"]' ) . val ( checked ? type : 0 ) . attr ( 'disabled' , ! checked ) ;
498+ $ ( '.pid_filter select[name="dtermLowpass2Type"]' ) . val ( type ) . attr ( 'disabled' , ! checked ) ;
493499 } ) ;
494500
495501 $ ( 'input[id="yawLowpassEnabled"]' ) . change ( function ( ) {
@@ -1759,3 +1765,16 @@ TABS.pid_tuning.updateRatesLabels = function() {
17591765 }
17601766 }
17611767} ;
1768+
1769+ TABS . pid_tuning . updateFilterWarning = function ( ) {
1770+ var gyroDynamicLowpassEnabled = $ ( 'input[id="gyroLowpassDynEnabled"]' ) . is ( ':checked' ) ;
1771+ var gyroLowpass1Enabled = $ ( 'input[id="gyroLowpassEnabled"]' ) . is ( ':checked' ) ;
1772+ var dtermDynamicLowpassEnabled = $ ( 'input[id="dtermLowpassDynEnabled"]' ) . is ( ':checked' ) ;
1773+ var dtermLowpass1Enabled = $ ( 'input[id="dtermLowpassEnabled"]' ) . is ( ':checked' ) ;
1774+ var warning_e = $ ( '#pid-tuning .filterWarning' ) ;
1775+ if ( ! ( gyroDynamicLowpassEnabled || gyroLowpass1Enabled ) || ! ( dtermDynamicLowpassEnabled || dtermLowpass1Enabled ) ) {
1776+ warning_e . show ( ) ;
1777+ } else {
1778+ warning_e . hide ( ) ;
1779+ }
1780+ }
0 commit comments