From 272e815522b0bc8e0806e052b73a5cc1af979cd7 Mon Sep 17 00:00:00 2001 From: Gareth Farrington Date: Thu, 20 Mar 2025 16:55:33 -0700 Subject: buttons: Debounce gcode_button and filament_switch_sensor (#6848) Add `debounce_delay` config option which sets the debounce time, defaults to 0 Signed-off-by: Gareth Farrington --- klippy/extras/gcode_button.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'klippy/extras/gcode_button.py') diff --git a/klippy/extras/gcode_button.py b/klippy/extras/gcode_button.py index 669edfb4..de280c98 100644 --- a/klippy/extras/gcode_button.py +++ b/klippy/extras/gcode_button.py @@ -5,6 +5,7 @@ # This file may be distributed under the terms of the GNU GPLv3 license. import logging + class GCodeButton: def __init__(self, config): self.printer = config.get_printer() @@ -13,12 +14,13 @@ class GCodeButton: self.last_state = 0 buttons = self.printer.load_object(config, "buttons") if config.get('analog_range', None) is None: - buttons.register_buttons([self.pin], self.button_callback) + buttons.register_debounce_button(self.pin, self.button_callback + , config) else: amin, amax = config.getfloatlist('analog_range', count=2) pullup = config.getfloat('analog_pullup_resistor', 4700., above=0.) - buttons.register_adc_button(self.pin, amin, amax, pullup, - self.button_callback) + buttons.register_debounce_adc_button(self.pin, amin, amax, pullup, + self.button_callback, config) gcode_macro = self.printer.load_object(config, 'gcode_macro') self.press_template = gcode_macro.load_template(config, 'press_gcode') self.release_template = gcode_macro.load_template(config, -- cgit v1.2.3-70-g09d2