tmc2660: Use new GCodeCommand wrappers

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-04-25 00:00:42 -04:00
parent 8b8f591a05
commit 3e64093b81
1 changed files with 10 additions and 11 deletions

View File

@ -150,9 +150,9 @@ class TMC2660CurrentHelper:
self.handle_ready) self.handle_ready)
gcode = self.printer.lookup_object("gcode") gcode = self.printer.lookup_object("gcode")
gcode.register_mux_command( gcode.register_mux_command("SET_TMC_CURRENT", "STEPPER", self.name,
"SET_TMC_CURRENT", "STEPPER", self.name, self.cmd_SET_TMC_CURRENT,
self.cmd_SET_TMC_CURRENT, desc=self.cmd_SET_TMC_CURRENT_help) desc=self.cmd_SET_TMC_CURRENT_help)
def _calc_current_bits(self, current, vsense): def _calc_current_bits(self, current, vsense):
vref = 0.165 if vsense else 0.310 vref = 0.165 if vsense else 0.310
@ -188,14 +188,13 @@ class TMC2660CurrentHelper:
self.mcu_tmc.set_register("DRVCONF", val, print_time) self.mcu_tmc.set_register("DRVCONF", val, print_time)
cmd_SET_TMC_CURRENT_help = "Set the current of a TMC2660 driver" cmd_SET_TMC_CURRENT_help = "Set the current of a TMC2660 driver"
def cmd_SET_TMC_CURRENT(self, params): def cmd_SET_TMC_CURRENT(self, gcmd):
gcode = self.printer.lookup_object('gcode') cur = gcmd.get_float('CURRENT', None, minval=0.1, maxval=MAX_CURRENT)
if 'CURRENT' in params: if cur is None:
self.current = gcode.get_float( return
'CURRENT', params, minval=0.1, maxval=MAX_CURRENT) self.current = cur
self.set_current( print_time = self.printer.lookup_object('toolhead').get_last_move_time()
self.printer.lookup_object('toolhead').get_last_move_time(), self.set_current(print_time, self.current)
self.current)
###################################################################### ######################################################################