From d5dc6b785d27572cee09c087417fef0ff2836af9 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 20 Apr 2018 21:41:13 -0400 Subject: gcode: Add minval/maxval/above/below options to get_X parsers Add value checking to gcode parameter parsing code. Signed-off-by: Kevin O'Connor --- klippy/extras/output_pin.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'klippy/extras/output_pin.py') diff --git a/klippy/extras/output_pin.py b/klippy/extras/output_pin.py index eda2ad2b..302e90e8 100644 --- a/klippy/extras/output_pin.py +++ b/klippy/extras/output_pin.py @@ -49,14 +49,13 @@ class PrinterOutputPin: return pin.cmd_SET_PIN(params) if self.is_static: raise self.gcode.error("Static pin can not be changed at run-time") - value = self.gcode.get_float('VALUE', params) / self.scale + value = self.gcode.get_float('VALUE', params, minval=0., maxval=1.) + value /= self.scale if value == self.last_value: return print_time = self.printer.lookup_object('toolhead').get_last_move_time() print_time = max(print_time, self.last_value_time + PIN_MIN_TIME) if self.is_pwm: - if value < 0. or value > 1.: - raise self.gcode.error("Invalid pin value") self.mcu_pin.set_pwm(print_time, value) else: if value not in [0., 1.]: -- cgit v1.2.3-70-g09d2