Bladeren bron

Adjustable ADC debounce delay (#16264)

Dennis 4 jaren geleden
bovenliggende
commit
2d7f94cae1
3 gewijzigde bestanden met toevoegingen van 17 en 3 verwijderingen
  1. 7
    0
      Marlin/Configuration_adv.h
  2. 4
    0
      Marlin/src/inc/SanityCheck.h
  3. 6
    3
      Marlin/src/module/temperature.cpp

+ 7
- 0
Marlin/Configuration_adv.h Bestand weergeven

1379
   //#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
1379
   //#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
1380
 #endif
1380
 #endif
1381
 
1381
 
1382
+//
1383
+// ADC Button Debounce
1384
+//
1385
+#if HAS_ADC_BUTTONS
1386
+  #define ADC_BUTTON_DEBOUNCE_DELAY 16  // (ms) Increase if buttons bounce or repeat too fast
1387
+#endif
1388
+
1382
 // @section safety
1389
 // @section safety
1383
 
1390
 
1384
 /**
1391
 /**

+ 4
- 0
Marlin/src/inc/SanityCheck.h Bestand weergeven

2509
     #error "SHOW_REMAINING_TIME currently requires a Graphical LCD."
2509
     #error "SHOW_REMAINING_TIME currently requires a Graphical LCD."
2510
   #endif
2510
   #endif
2511
 #endif
2511
 #endif
2512
+
2513
+#if HAS_ADC_BUTTONS && defined(ADC_BUTTON_DEBOUNCE_DELAY) && !WITHIN(ADC_BUTTON_DEBOUNCE_DELAY, 16, 255)
2514
+  #error "ADC_BUTTON_DEBOUNCE_DELAY must be an integer from 16 to 255."
2515
+#endif

+ 6
- 3
Marlin/src/module/temperature.cpp Bestand weergeven

2712
     #endif
2712
     #endif
2713
 
2713
 
2714
     #if HAS_ADC_BUTTONS
2714
     #if HAS_ADC_BUTTONS
2715
+      #ifndef ADC_BUTTON_DEBOUNCE_DELAY
2716
+        #define ADC_BUTTON_DEBOUNCE_DELAY 16
2717
+      #endif
2715
       case Prepare_ADC_KEY: HAL_START_ADC(ADC_KEYPAD_PIN); break;
2718
       case Prepare_ADC_KEY: HAL_START_ADC(ADC_KEYPAD_PIN); break;
2716
       case Measure_ADC_KEY:
2719
       case Measure_ADC_KEY:
2717
         if (!HAL_ADC_READY())
2720
         if (!HAL_ADC_READY())
2718
           next_sensor_state = adc_sensor_state; // redo this state
2721
           next_sensor_state = adc_sensor_state; // redo this state
2719
-        else if (ADCKey_count < 16) {
2722
+        else if (ADCKey_count < ADC_BUTTON_DEBOUNCE_DELAY) {
2720
           raw_ADCKey_value = HAL_READ_ADC();
2723
           raw_ADCKey_value = HAL_READ_ADC();
2721
           if (raw_ADCKey_value <= 900UL * HAL_ADC_RANGE / 1024UL) {
2724
           if (raw_ADCKey_value <= 900UL * HAL_ADC_RANGE / 1024UL) {
2722
             NOMORE(current_ADCKey_raw, raw_ADCKey_value);
2725
             NOMORE(current_ADCKey_raw, raw_ADCKey_value);
2730
             }
2733
             }
2731
           }
2734
           }
2732
         }
2735
         }
2733
-        if (ADCKey_count == 16) ADCKey_pressed = true;
2736
+        if (ADCKey_count == ADC_BUTTON_DEBOUNCE_DELAY) ADCKey_pressed = true;
2734
         break;
2737
         break;
2735
-    #endif // ADC_KEYPAD
2738
+    #endif // HAS_ADC_BUTTONS
2736
 
2739
 
2737
     case StartupDelay: break;
2740
     case StartupDelay: break;
2738
 
2741
 

Laden…
Annuleren
Opslaan