From 3e64093b81dd3bd4f03410cabaee8f6020b780dc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 25 Apr 2020 00:00:42 -0400 Subject: [PATCH] tmc2660: Use new GCodeCommand wrappers Signed-off-by: Kevin O'Connor --- klippy/extras/tmc2660.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/klippy/extras/tmc2660.py b/klippy/extras/tmc2660.py index 95321056..2f5ac527 100644 --- a/klippy/extras/tmc2660.py +++ b/klippy/extras/tmc2660.py @@ -150,9 +150,9 @@ class TMC2660CurrentHelper: self.handle_ready) gcode = self.printer.lookup_object("gcode") - gcode.register_mux_command( - "SET_TMC_CURRENT", "STEPPER", self.name, - self.cmd_SET_TMC_CURRENT, desc=self.cmd_SET_TMC_CURRENT_help) + gcode.register_mux_command("SET_TMC_CURRENT", "STEPPER", self.name, + self.cmd_SET_TMC_CURRENT, + desc=self.cmd_SET_TMC_CURRENT_help) def _calc_current_bits(self, current, vsense): vref = 0.165 if vsense else 0.310 @@ -188,14 +188,13 @@ class TMC2660CurrentHelper: self.mcu_tmc.set_register("DRVCONF", val, print_time) cmd_SET_TMC_CURRENT_help = "Set the current of a TMC2660 driver" - def cmd_SET_TMC_CURRENT(self, params): - gcode = self.printer.lookup_object('gcode') - if 'CURRENT' in params: - self.current = gcode.get_float( - 'CURRENT', params, minval=0.1, maxval=MAX_CURRENT) - self.set_current( - self.printer.lookup_object('toolhead').get_last_move_time(), - self.current) + def cmd_SET_TMC_CURRENT(self, gcmd): + cur = gcmd.get_float('CURRENT', None, minval=0.1, maxval=MAX_CURRENT) + if cur is None: + return + self.current = cur + print_time = self.printer.lookup_object('toolhead').get_last_move_time() + self.set_current(print_time, self.current) ######################################################################