extruder: Add a SET_EXTRUDER_ROTATION_DISTANCE command

Support altering the extruder distance using the higher-level
rotation_distance.  This is in preparation for removal of the
SET_EXTRUDER_STEP_DISTANCE command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2022-01-29 14:13:26 -05:00
parent 6d7c03365a
commit 189188e3ca
5 changed files with 55 additions and 23 deletions

View File

@@ -520,8 +520,9 @@ def TMCStealthchopHelper(config, mcu_tmc, tmc_freq):
velocity = config.getfloat('stealthchop_threshold', 0., minval=0.)
if velocity:
stepper_name = " ".join(config.get_name().split()[1:])
stepper_config = config.getsection(stepper_name)
step_dist = stepper.parse_step_distance(stepper_config)
sconfig = config.getsection(stepper_name)
rotation_dist, steps_per_rotation = stepper.parse_step_distance(sconfig)
step_dist = rotation_dist / steps_per_rotation
step_dist_256 = step_dist / (1 << fields.get_field("mres"))
threshold = int(tmc_freq * step_dist_256 / velocity + .5)
fields.set_field("tpwmthrs", max(0, min(0xfffff, threshold)))