From 8f85786b3fc0341b966a127406e21b32d98338d3 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 19 Aug 2021 15:01:55 -0400 Subject: [PATCH] gcode_button: Use config.getfloatlist() for analog_range config option Signed-off-by: Kevin O'Connor --- klippy/extras/gcode_button.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/klippy/extras/gcode_button.py b/klippy/extras/gcode_button.py index 764ba4a9..669edfb4 100644 --- a/klippy/extras/gcode_button.py +++ b/klippy/extras/gcode_button.py @@ -12,14 +12,10 @@ class GCodeButton: self.pin = config.get('pin') self.last_state = 0 buttons = self.printer.load_object(config, "buttons") - analog_range = config.get('analog_range', None) - if analog_range is None: + if config.get('analog_range', None) 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") + 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)