tmc2130: Use new GCodeCommand wrappers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
3e64093b81
commit
d759cc60d3
|
@ -109,9 +109,9 @@ class TMCCurrentHelper:
|
||||||
self.fields.set_field("IHOLD", ihold)
|
self.fields.set_field("IHOLD", ihold)
|
||||||
self.fields.set_field("IRUN", irun)
|
self.fields.set_field("IRUN", irun)
|
||||||
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):
|
||||||
sense_resistor = self.sense_resistor + 0.020
|
sense_resistor = self.sense_resistor + 0.020
|
||||||
vref = 0.32
|
vref = 0.32
|
||||||
|
@ -140,23 +140,22 @@ class TMCCurrentHelper:
|
||||||
current = (bits + 1) * vref / (32 * sense_resistor * math.sqrt(2.))
|
current = (bits + 1) * vref / (32 * sense_resistor * math.sqrt(2.))
|
||||||
return round(current, 2)
|
return round(current, 2)
|
||||||
cmd_SET_TMC_CURRENT_help = "Set the current of a TMC driver"
|
cmd_SET_TMC_CURRENT_help = "Set the current of a TMC driver"
|
||||||
def cmd_SET_TMC_CURRENT(self, params):
|
def cmd_SET_TMC_CURRENT(self, gcmd):
|
||||||
gcode = self.printer.lookup_object('gcode')
|
run_current = gcmd.get_float('CURRENT', None,
|
||||||
if 'HOLDCURRENT' in params:
|
minval=0., maxval=MAX_CURRENT)
|
||||||
hold_current = gcode.get_float(
|
hold_current = gcmd.get_float('HOLDCURRENT', None,
|
||||||
'HOLDCURRENT', params, above=0., maxval=MAX_CURRENT)
|
above=0., maxval=MAX_CURRENT)
|
||||||
else:
|
if run_current is None and hold_current is None:
|
||||||
hold_current = self._calc_current_from_field("IHOLD")
|
|
||||||
if 'CURRENT' in params:
|
|
||||||
run_current = gcode.get_float(
|
|
||||||
'CURRENT', params, minval=0., maxval=MAX_CURRENT)
|
|
||||||
else:
|
|
||||||
run_current = self._calc_current_from_field("IRUN")
|
|
||||||
if 'HOLDCURRENT' not in params and 'CURRENT' not in params:
|
|
||||||
# Query only
|
# Query only
|
||||||
gcode.respond_info("Run Current: %0.2fA Hold Current: %0.2fA"
|
run_current = self._calc_current_from_field("IRUN")
|
||||||
|
hold_current = self._calc_current_from_field("IHOLD")
|
||||||
|
gcmd.respond_info("Run Current: %0.2fA Hold Current: %0.2fA"
|
||||||
% (run_current, hold_current))
|
% (run_current, hold_current))
|
||||||
return
|
return
|
||||||
|
if run_current is None:
|
||||||
|
run_current = self._calc_current_from_field("IRUN")
|
||||||
|
if hold_current is None:
|
||||||
|
hold_current = self._calc_current_from_field("IHOLD")
|
||||||
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
|
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
|
||||||
vsense, irun, ihold = self._calc_current(run_current, hold_current)
|
vsense, irun, ihold = self._calc_current(run_current, hold_current)
|
||||||
if vsense != self.fields.get_field("vsense"):
|
if vsense != self.fields.get_field("vsense"):
|
||||||
|
|
Loading…
Reference in New Issue