mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-23 14:44:20 -06:00
force_move: Rename stepper_buzz.py to force_move.py
This is in preparation for extending the ability to make manual moves. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
13ccb1a46f
commit
2c5eba44ee
2 changed files with 12 additions and 10 deletions
|
@ -1,63 +0,0 @@
|
|||
# Utility for moving a stepper back and forth to help identify it
|
||||
#
|
||||
# Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# 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
|
||||
self.gcode = self.printer.lookup_object('gcode')
|
||||
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)
|
||||
logging.info("Stepper buzz %s", name)
|
||||
stepper = self.steppers[name]
|
||||
need_motor_enable = not stepper.is_motor_enabled()
|
||||
# Move stepper
|
||||
toolhead = self.printer.lookup_object('toolhead')
|
||||
toolhead.wait_moves()
|
||||
pos = stepper.get_commanded_position()
|
||||
print_time = toolhead.get_last_move_time()
|
||||
if need_motor_enable:
|
||||
stepper.motor_enable(print_time, 1)
|
||||
print_time += .1
|
||||
was_ignore = stepper.set_ignore_move(False)
|
||||
prev_sk = stepper.set_stepper_kinematics(self.stepper_kinematics)
|
||||
for i in range(10):
|
||||
self.manual_move(print_time, stepper, 0., 1.)
|
||||
print_time += .3
|
||||
self.manual_move(print_time, stepper, 1., -1.)
|
||||
toolhead.reset_print_time(print_time + .7)
|
||||
print_time = toolhead.get_last_move_time()
|
||||
stepper.set_stepper_kinematics(prev_sk)
|
||||
stepper.set_ignore_move(was_ignore)
|
||||
if need_motor_enable:
|
||||
print_time += .1
|
||||
stepper.motor_enable(print_time, 0)
|
||||
toolhead.reset_print_time(print_time)
|
||||
|
||||
def load_config(config):
|
||||
return StepperBuzz(config)
|
Loading…
Add table
Add a link
Reference in a new issue