mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-11-03 20:05:49 +01:00
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>
This commit is contained in:
committed by
GitHub
parent
06d65ef5ac
commit
272e815522
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user