aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/stepper_buzz.py
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/extras/stepper_buzz.py')
-rw-r--r--klippy/extras/stepper_buzz.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/klippy/extras/stepper_buzz.py b/klippy/extras/stepper_buzz.py
index 093dcbe8..a9cc5b80 100644
--- a/klippy/extras/stepper_buzz.py
+++ b/klippy/extras/stepper_buzz.py
@@ -4,11 +4,20 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
+import chelper
+
+BUZZ_VELOCITY = 4.
class StepperBuzz:
def __init__(self, config):
self.printer = config.get_printer()
self.steppers = {}
+ # Setup iterative solver
+ ffi_main, ffi_lib = chelper.get_ffi()
+ self.cmove = ffi_main.gc(ffi_lib.move_alloc(), ffi_lib.free)
+ self.move_fill = ffi_lib.move_fill
+ self.stepper_kinematics = ffi_main.gc(
+ ffi_lib.cartesian_stepper_alloc('x'), ffi_lib.free)
def register_stepper(self, stepper, name):
self.steppers[name] = stepper
# Register STEPPER_BUZZ command
@@ -16,6 +25,11 @@ class StepperBuzz:
self.gcode.register_mux_command(
'STEPPER_BUZZ', 'STEPPER', name, self.cmd_STEPPER_BUZZ,
desc=self.cmd_STEPPER_BUZZ_help)
+ def manual_move(self, print_time, stepper, start_pos, dist):
+ self.move_fill(
+ self.cmove, print_time, 0., abs(dist / BUZZ_VELOCITY), 0.,
+ start_pos, 0., 0., dist, 0., 0., 0., BUZZ_VELOCITY, 0.)
+ stepper.step_itersolve(self.cmove)
cmd_STEPPER_BUZZ_help = "Oscillate a given stepper to help id it"
def cmd_STEPPER_BUZZ(self, params):
name = self.gcode.get_str('STEPPER', params)
@@ -31,12 +45,14 @@ class StepperBuzz:
stepper.motor_enable(print_time, 1)
print_time += .1
was_ignore = stepper.mcu_stepper.set_ignore_move(False)
+ prev_sk = stepper.mcu_stepper.setup_itersolve(self.stepper_kinematics)
for i in range(10):
- stepper.step_const(print_time, pos, 1., 4., 0.)
+ self.manual_move(print_time, stepper, 0., 1.)
print_time += .3
- stepper.step_const(print_time, pos + 1., -1., 4., 0.)
+ self.manual_move(print_time, stepper, 1., -1.)
toolhead.reset_print_time(print_time + .7)
print_time = toolhead.get_last_move_time()
+ stepper.mcu_stepper.setup_itersolve(prev_sk)
stepper.mcu_stepper.set_ignore_move(was_ignore)
if need_motor_enable:
print_time += .1