Adjustable ADC debounce delay (#16264)
This commit is contained in:
parent
7481563bd9
commit
2d7f94cae1
@ -1379,6 +1379,13 @@
|
|||||||
//#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
|
//#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// ADC Button Debounce
|
||||||
|
//
|
||||||
|
#if HAS_ADC_BUTTONS
|
||||||
|
#define ADC_BUTTON_DEBOUNCE_DELAY 16 // (ms) Increase if buttons bounce or repeat too fast
|
||||||
|
#endif
|
||||||
|
|
||||||
// @section safety
|
// @section safety
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2509,3 +2509,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
|
|||||||
#error "SHOW_REMAINING_TIME currently requires a Graphical LCD."
|
#error "SHOW_REMAINING_TIME currently requires a Graphical LCD."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAS_ADC_BUTTONS && defined(ADC_BUTTON_DEBOUNCE_DELAY) && !WITHIN(ADC_BUTTON_DEBOUNCE_DELAY, 16, 255)
|
||||||
|
#error "ADC_BUTTON_DEBOUNCE_DELAY must be an integer from 16 to 255."
|
||||||
|
#endif
|
||||||
|
@ -2712,11 +2712,14 @@ void Temperature::tick() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_ADC_BUTTONS
|
#if HAS_ADC_BUTTONS
|
||||||
|
#ifndef ADC_BUTTON_DEBOUNCE_DELAY
|
||||||
|
#define ADC_BUTTON_DEBOUNCE_DELAY 16
|
||||||
|
#endif
|
||||||
case Prepare_ADC_KEY: HAL_START_ADC(ADC_KEYPAD_PIN); break;
|
case Prepare_ADC_KEY: HAL_START_ADC(ADC_KEYPAD_PIN); break;
|
||||||
case Measure_ADC_KEY:
|
case Measure_ADC_KEY:
|
||||||
if (!HAL_ADC_READY())
|
if (!HAL_ADC_READY())
|
||||||
next_sensor_state = adc_sensor_state; // redo this state
|
next_sensor_state = adc_sensor_state; // redo this state
|
||||||
else if (ADCKey_count < 16) {
|
else if (ADCKey_count < ADC_BUTTON_DEBOUNCE_DELAY) {
|
||||||
raw_ADCKey_value = HAL_READ_ADC();
|
raw_ADCKey_value = HAL_READ_ADC();
|
||||||
if (raw_ADCKey_value <= 900UL * HAL_ADC_RANGE / 1024UL) {
|
if (raw_ADCKey_value <= 900UL * HAL_ADC_RANGE / 1024UL) {
|
||||||
NOMORE(current_ADCKey_raw, raw_ADCKey_value);
|
NOMORE(current_ADCKey_raw, raw_ADCKey_value);
|
||||||
@ -2730,9 +2733,9 @@ void Temperature::tick() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ADCKey_count == 16) ADCKey_pressed = true;
|
if (ADCKey_count == ADC_BUTTON_DEBOUNCE_DELAY) ADCKey_pressed = true;
|
||||||
break;
|
break;
|
||||||
#endif // ADC_KEYPAD
|
#endif // HAS_ADC_BUTTONS
|
||||||
|
|
||||||
case StartupDelay: break;
|
case StartupDelay: break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user