From 7d76067ff9efaf75808b05f768dfef4295251ede Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 9 Feb 2020 15:37:15 -0500 Subject: [PATCH] tmc: Fix typo preventing stealthchop threshold from being set Fix typo introduced in commit 67b28522. Signed-off-by: Kevin O'Connor --- klippy/extras/tmc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py index 5f0f5f7e..7c92d772 100644 --- a/klippy/extras/tmc.py +++ b/klippy/extras/tmc.py @@ -284,7 +284,8 @@ class TMCStealthchopHelper: en_pwm_mode = False self.velocity = config.getfloat('stealthchop_threshold', 0., minval=0.) if self.velocity: - printer.register_event_handler("connect", self.handle_connect) + printer.register_event_handler("klippy:connect", + self.handle_connect) en_pwm_mode = True reg = fields.lookup_register("en_pwm_mode", None) if reg is not None: @@ -296,6 +297,6 @@ class TMCStealthchopHelper: stepper_name = " ".join(self.name.split()[1:]) stepper = self.force_move.lookup_stepper(stepper_name) step_dist = stepper.get_step_dist() - step_dist_256 = step_dist / (1 << fields.get_field("MRES")) + step_dist_256 = step_dist / (1 << self.fields.get_field("MRES")) threshold = int(self.tmc_freq * step_dist_256 / self.velocity + .5) self.fields.set_field("TPWMTHRS", max(0, min(0xfffff, threshold)))