aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/tmc.py
diff options
context:
space:
mode:
authorAlex Voinea <voinea.dragos.alexandru@gmail.com>2023-03-16 13:11:34 +0100
committerKevinOConnor <kevin@koconnor.net>2023-03-20 10:58:25 -0400
commit73f4c6cd0077310ca748c13f5a7e223989cfe92d (patch)
treefafa055e589ccb4c1aa4a10ede746d5af92386a6 /klippy/extras/tmc.py
parent0469710a69b36960442ae1b067c6631b696d4dd1 (diff)
downloadkutter-73f4c6cd0077310ca748c13f5a7e223989cfe92d.tar.gz
kutter-73f4c6cd0077310ca748c13f5a7e223989cfe92d.tar.xz
kutter-73f4c6cd0077310ca748c13f5a7e223989cfe92d.zip
tmc: SET_TMC_FIELD VELOCITY
Ability to specify `VELOCITY` as a parameter for SET_TMC_FIELD. Useful for configuring at runtime the TSTEP based fields of the driver. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
Diffstat (limited to 'klippy/extras/tmc.py')
-rw-r--r--klippy/extras/tmc.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py
index f9f2d150..36c27d5c 100644
--- a/klippy/extras/tmc.py
+++ b/klippy/extras/tmc.py
@@ -258,7 +258,18 @@ class TMCCommandHelper:
reg_name = self.fields.lookup_register(field_name, None)
if reg_name is None:
raise gcmd.error("Unknown field name '%s'" % (field_name,))
- value = gcmd.get_int('VALUE')
+ value = gcmd.get_int('VALUE', None)
+ velocity = gcmd.get_float('VELOCITY', None, minval=0.)
+ tmc_frequency = self.mcu_tmc.get_tmc_frequency()
+ if tmc_frequency is None and velocity is not None:
+ raise gcmd.error("VELOCITY parameter not supported by this driver")
+ if (value is None) == (velocity is None):
+ raise gcmd.error("Specify either VALUE or VELOCITY")
+ if velocity is not None:
+ step_dist = self.stepper.get_step_dist()
+ mres = self.fields.get_field("mres")
+ value = TMCtstepHelper(step_dist, mres, tmc_frequency,
+ velocity)
reg_val = self.fields.set_field(field_name, value)
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
self.mcu_tmc.set_register(reg_name, reg_val, print_time)