diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2020-04-25 00:00:42 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2020-05-05 11:08:12 -0400 |
commit | 3e64093b81dd3bd4f03410cabaee8f6020b780dc (patch) | |
tree | 764206f28d18ec5de2a7ec20937d07adca3d393b /klippy | |
parent | 8b8f591a05c6ea76efefc6864b6fe31b65c9bc82 (diff) | |
download | kutter-3e64093b81dd3bd4f03410cabaee8f6020b780dc.tar.gz kutter-3e64093b81dd3bd4f03410cabaee8f6020b780dc.tar.xz kutter-3e64093b81dd3bd4f03410cabaee8f6020b780dc.zip |
tmc2660: Use new GCodeCommand wrappers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r-- | klippy/extras/tmc2660.py | 21 |
1 files 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) ###################################################################### |