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:
Kevin O'Connor 2018-07-26 11:15:51 -04:00
parent 13ccb1a46f
commit 2c5eba44ee
2 changed files with 12 additions and 10 deletions

View File

@ -1,4 +1,4 @@
# Utility for moving a stepper back and forth to help identify it # Utility for manually moving a stepper for diagnostic purposes
# #
# Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net> # Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
# #
@ -8,7 +8,7 @@ import chelper
BUZZ_VELOCITY = 4. BUZZ_VELOCITY = 4.
class StepperBuzz: class ForceMove:
def __init__(self, config): def __init__(self, config):
self.printer = config.get_printer() self.printer = config.get_printer()
self.steppers = {} self.steppers = {}
@ -18,13 +18,13 @@ class StepperBuzz:
self.move_fill = ffi_lib.move_fill self.move_fill = ffi_lib.move_fill
self.stepper_kinematics = ffi_main.gc( self.stepper_kinematics = ffi_main.gc(
ffi_lib.cartesian_stepper_alloc('x'), ffi_lib.free) ffi_lib.cartesian_stepper_alloc('x'), ffi_lib.free)
def register_stepper(self, stepper, name):
self.steppers[name] = stepper
# Register STEPPER_BUZZ command # Register STEPPER_BUZZ command
self.gcode = self.printer.lookup_object('gcode') self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_mux_command( self.gcode.register_command('STEPPER_BUZZ', self.cmd_STEPPER_BUZZ,
'STEPPER_BUZZ', 'STEPPER', name, self.cmd_STEPPER_BUZZ,
desc=self.cmd_STEPPER_BUZZ_help) desc=self.cmd_STEPPER_BUZZ_help)
def register_stepper(self, stepper):
name = stepper.get_name()
self.steppers[name] = stepper
def manual_move(self, print_time, stepper, start_pos, dist): def manual_move(self, print_time, stepper, start_pos, dist):
self.move_fill( self.move_fill(
self.cmove, print_time, 0., abs(dist / BUZZ_VELOCITY), 0., self.cmove, print_time, 0., abs(dist / BUZZ_VELOCITY), 0.,
@ -33,6 +33,8 @@ class StepperBuzz:
cmd_STEPPER_BUZZ_help = "Oscillate a given stepper to help id it" cmd_STEPPER_BUZZ_help = "Oscillate a given stepper to help id it"
def cmd_STEPPER_BUZZ(self, params): def cmd_STEPPER_BUZZ(self, params):
name = self.gcode.get_str('STEPPER', params) name = self.gcode.get_str('STEPPER', params)
if name not in self.steppers:
raise self.gcode.error("Unknown stepper %s" % (name,))
logging.info("Stepper buzz %s", name) logging.info("Stepper buzz %s", name)
stepper = self.steppers[name] stepper = self.steppers[name]
need_motor_enable = not stepper.is_motor_enabled() need_motor_enable = not stepper.is_motor_enabled()
@ -60,4 +62,4 @@ class StepperBuzz:
toolhead.reset_print_time(print_time) toolhead.reset_print_time(print_time)
def load_config(config): def load_config(config):
return StepperBuzz(config) return ForceMove(config)

View File

@ -60,8 +60,8 @@ class PrinterStepper:
mcu_stepper.setup_step_distance(step_dist) mcu_stepper.setup_step_distance(step_dist)
self.enable = lookup_enable_pin(ppins, config.get('enable_pin', None)) self.enable = lookup_enable_pin(ppins, config.get('enable_pin', None))
# Register STEPPER_BUZZ command # Register STEPPER_BUZZ command
stepper_buzz = printer.try_load_module(config, 'stepper_buzz') force_move = printer.try_load_module(config, 'force_move')
stepper_buzz.register_stepper(self, config.get_name()) force_move.register_stepper(self)
# Wrappers # Wrappers
self.step_itersolve = mcu_stepper.step_itersolve self.step_itersolve = mcu_stepper.step_itersolve
self.setup_itersolve = mcu_stepper.setup_itersolve self.setup_itersolve = mcu_stepper.setup_itersolve