aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/gcode_button.py
diff options
context:
space:
mode:
authorGareth Farrington <gareth@waves.ky>2025-03-20 16:55:33 -0700
committerGitHub <noreply@github.com>2025-03-20 19:55:33 -0400
commit272e815522b0bc8e0806e052b73a5cc1af979cd7 (patch)
tree8cbf07cad71d2113a55c45d53900ac3ad15ba8e2 /klippy/extras/gcode_button.py
parent06d65ef5ac139e2c84e7381c190ee2b1e4ec4237 (diff)
downloadkutter-272e815522b0bc8e0806e052b73a5cc1af979cd7.tar.gz
kutter-272e815522b0bc8e0806e052b73a5cc1af979cd7.tar.xz
kutter-272e815522b0bc8e0806e052b73a5cc1af979cd7.zip
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 <gareth@waves.ky>
Diffstat (limited to 'klippy/extras/gcode_button.py')
-rw-r--r--klippy/extras/gcode_button.py8
1 files changed, 5 insertions, 3 deletions
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,