servo: Use new GCodeCommand wrappers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
53093a7a15
commit
a11535fc86
|
@ -26,8 +26,8 @@ class PrinterServo:
|
|||
self.enable = config.getboolean('enable', True)
|
||||
self.last_enable = not self.enable
|
||||
servo_name = config.get_name().split()[1]
|
||||
self.gcode = self.printer.lookup_object('gcode')
|
||||
self.gcode.register_mux_command("SET_SERVO", "SERVO", servo_name,
|
||||
gcode = self.printer.lookup_object('gcode')
|
||||
gcode.register_mux_command("SET_SERVO", "SERVO", servo_name,
|
||||
self.cmd_SET_SERVO,
|
||||
desc=self.cmd_SET_SERVO_help)
|
||||
# Check to see if an initial angle or pulse width is
|
||||
|
@ -71,18 +71,17 @@ class PrinterServo:
|
|||
width = max(self.min_width, min(self.max_width, width))
|
||||
return width * self.width_to_value
|
||||
cmd_SET_SERVO_help = "Set servo angle"
|
||||
def cmd_SET_SERVO(self, params):
|
||||
def cmd_SET_SERVO(self, gcmd):
|
||||
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
|
||||
if 'ENABLE' in params:
|
||||
value = self.gcode.get_int('ENABLE', params)
|
||||
self.enable = value != 0
|
||||
if 'WIDTH' in params:
|
||||
self._set_pwm(print_time, self._get_pwm_from_pulse_width(
|
||||
self.gcode.get_float('WIDTH', params)))
|
||||
else:
|
||||
if 'ANGLE' in params:
|
||||
self._set_pwm(print_time, self._get_pwm_from_angle(
|
||||
self.gcode.get_float('ANGLE', params)))
|
||||
enable = gcmd.get_int('ENABLE', None)
|
||||
width = gcmd.get_float('WIDTH', None)
|
||||
angle = gcmd.get_float('ANGLE', None)
|
||||
if enable is not None:
|
||||
self.enable = enable != 0
|
||||
if width is not None:
|
||||
self._set_pwm(print_time, self._get_pwm_from_pulse_width(width))
|
||||
elif angle is not None:
|
||||
self._set_pwm(print_time, self._get_pwm_from_angle(angle))
|
||||
else:
|
||||
self._set_pwm(print_time, self.last_value)
|
||||
|
||||
|
|
Loading…
Reference in New Issue