aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-09-09 14:16:42 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-09-09 14:21:30 -0400
commitfc85675145c858e2817d6c10f73029fd4aab4b9e (patch)
treecf5fe2b3ad8c6398ff8e0aa8c38a4ecb032ebee8 /klippy/extras
parent13ee6032ae28a4a8dfc1e194c2b5c73e66674df3 (diff)
downloadkutter-fc85675145c858e2817d6c10f73029fd4aab4b9e.tar.gz
kutter-fc85675145c858e2817d6c10f73029fd4aab4b9e.tar.xz
kutter-fc85675145c858e2817d6c10f73029fd4aab4b9e.zip
gcode_button: Add support for analog buttons
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras')
-rw-r--r--klippy/extras/gcode_button.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/klippy/extras/gcode_button.py b/klippy/extras/gcode_button.py
index 2f723cac..764ba4a9 100644
--- a/klippy/extras/gcode_button.py
+++ b/klippy/extras/gcode_button.py
@@ -12,7 +12,17 @@ class GCodeButton:
self.pin = config.get('pin')
self.last_state = 0
buttons = self.printer.load_object(config, "buttons")
- buttons.register_buttons([self.pin], self.button_callback)
+ analog_range = config.get('analog_range', None)
+ if analog_range is None:
+ buttons.register_buttons([self.pin], self.button_callback)
+ else:
+ try:
+ amin, amax = map(float, analog_range.split(','))
+ except:
+ raise config.error("Unable to parse analog_range")
+ pullup = config.getfloat('analog_pullup_resistor', 4700., above=0.)
+ buttons.register_adc_button(self.pin, amin, amax, pullup,
+ self.button_callback)
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,