gcode_button: Use config.getfloatlist() for analog_range config option
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
7f82dcb442
commit
8f85786b3f
|
@ -12,14 +12,10 @@ class GCodeButton:
|
||||||
self.pin = config.get('pin')
|
self.pin = config.get('pin')
|
||||||
self.last_state = 0
|
self.last_state = 0
|
||||||
buttons = self.printer.load_object(config, "buttons")
|
buttons = self.printer.load_object(config, "buttons")
|
||||||
analog_range = config.get('analog_range', None)
|
if config.get('analog_range', None) is None:
|
||||||
if analog_range is None:
|
|
||||||
buttons.register_buttons([self.pin], self.button_callback)
|
buttons.register_buttons([self.pin], self.button_callback)
|
||||||
else:
|
else:
|
||||||
try:
|
amin, amax = config.getfloatlist('analog_range', count=2)
|
||||||
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.)
|
pullup = config.getfloat('analog_pullup_resistor', 4700., above=0.)
|
||||||
buttons.register_adc_button(self.pin, amin, amax, pullup,
|
buttons.register_adc_button(self.pin, amin, amax, pullup,
|
||||||
self.button_callback)
|
self.button_callback)
|
||||||
|
|
Loading…
Reference in New Issue