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 <kevin@koconnor.net>
This commit is contained in:
@@ -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.]:
|
||||
|
||||
@@ -102,7 +102,7 @@ class VirtualSD:
|
||||
# Set SD position
|
||||
if self.work_timer is not None:
|
||||
raise self.gcode.error("SD busy")
|
||||
pos = self.gcode.get_int('S', params)
|
||||
pos = self.gcode.get_int('S', params, minval=0)
|
||||
self.file_position = pos
|
||||
def cmd_M27(self, params):
|
||||
# Report SD print status
|
||||
|
||||
Reference in New Issue
Block a user