mirror of https://github.com/Desuuuu/klipper.git
force_move: Use new GCodeCommand wrappers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
57ca91a875
commit
19abe2b974
|
@ -41,15 +41,15 @@ class ForceMove:
|
|||
ffi_lib.cartesian_stepper_alloc('x'), ffi_lib.free)
|
||||
ffi_lib.itersolve_set_trapq(self.stepper_kinematics, self.trapq)
|
||||
# Register commands
|
||||
self.gcode = self.printer.lookup_object('gcode')
|
||||
self.gcode.register_command('STEPPER_BUZZ', self.cmd_STEPPER_BUZZ,
|
||||
desc=self.cmd_STEPPER_BUZZ_help)
|
||||
gcode = self.printer.lookup_object('gcode')
|
||||
gcode.register_command('STEPPER_BUZZ', self.cmd_STEPPER_BUZZ,
|
||||
desc=self.cmd_STEPPER_BUZZ_help)
|
||||
if config.getboolean("enable_force_move", False):
|
||||
self.gcode.register_command('FORCE_MOVE', self.cmd_FORCE_MOVE,
|
||||
desc=self.cmd_FORCE_MOVE_help)
|
||||
self.gcode.register_command(
|
||||
'SET_KINEMATIC_POSITION', self.cmd_SET_KINEMATIC_POSITION,
|
||||
desc=self.cmd_SET_KINEMATIC_POSITION_help)
|
||||
gcode.register_command('FORCE_MOVE', self.cmd_FORCE_MOVE,
|
||||
desc=self.cmd_FORCE_MOVE_help)
|
||||
gcode.register_command('SET_KINEMATIC_POSITION',
|
||||
self.cmd_SET_KINEMATIC_POSITION,
|
||||
desc=self.cmd_SET_KINEMATIC_POSITION_help)
|
||||
def register_stepper(self, stepper):
|
||||
name = stepper.get_name()
|
||||
self.steppers[name] = stepper
|
||||
|
@ -91,14 +91,14 @@ class ForceMove:
|
|||
stepper.set_stepper_kinematics(prev_sk)
|
||||
toolhead.note_kinematic_activity(print_time)
|
||||
toolhead.dwell(accel_t + cruise_t + accel_t)
|
||||
def _lookup_stepper(self, params):
|
||||
name = self.gcode.get_str('STEPPER', params)
|
||||
def _lookup_stepper(self, gcmd):
|
||||
name = gcmd.get('STEPPER')
|
||||
if name not in self.steppers:
|
||||
raise self.gcode.error("Unknown stepper %s" % (name,))
|
||||
raise gcmd.error("Unknown stepper %s" % (name,))
|
||||
return self.steppers[name]
|
||||
cmd_STEPPER_BUZZ_help = "Oscillate a given stepper to help id it"
|
||||
def cmd_STEPPER_BUZZ(self, params):
|
||||
stepper = self._lookup_stepper(params)
|
||||
def cmd_STEPPER_BUZZ(self, gcmd):
|
||||
stepper = self._lookup_stepper(gcmd)
|
||||
logging.info("Stepper buzz %s", stepper.get_name())
|
||||
was_enable = self.force_enable(stepper)
|
||||
toolhead = self.printer.lookup_object('toolhead')
|
||||
|
@ -112,26 +112,27 @@ class ForceMove:
|
|||
toolhead.dwell(.450)
|
||||
self.restore_enable(stepper, was_enable)
|
||||
cmd_FORCE_MOVE_help = "Manually move a stepper; invalidates kinematics"
|
||||
def cmd_FORCE_MOVE(self, params):
|
||||
stepper = self._lookup_stepper(params)
|
||||
distance = self.gcode.get_float('DISTANCE', params)
|
||||
speed = self.gcode.get_float('VELOCITY', params, above=0.)
|
||||
accel = self.gcode.get_float('ACCEL', params, 0., minval=0.)
|
||||
def cmd_FORCE_MOVE(self, gcmd):
|
||||
stepper = self._lookup_stepper(gcmd)
|
||||
distance = gcmd.get_float('DISTANCE')
|
||||
speed = gcmd.get_float('VELOCITY', above=0.)
|
||||
accel = gcmd.get_float('ACCEL', 0., minval=0.)
|
||||
logging.info("FORCE_MOVE %s distance=%.3f velocity=%.3f accel=%.3f",
|
||||
stepper.get_name(), distance, speed, accel)
|
||||
self.force_enable(stepper)
|
||||
self.manual_move(stepper, distance, speed, accel)
|
||||
cmd_SET_KINEMATIC_POSITION_help = "Force a low-level kinematic position"
|
||||
def cmd_SET_KINEMATIC_POSITION(self, params):
|
||||
def cmd_SET_KINEMATIC_POSITION(self, gcmd):
|
||||
toolhead = self.printer.lookup_object('toolhead')
|
||||
toolhead.get_last_move_time()
|
||||
curpos = toolhead.get_position()
|
||||
x = self.gcode.get_float('X', params, curpos[0])
|
||||
y = self.gcode.get_float('Y', params, curpos[1])
|
||||
z = self.gcode.get_float('Z', params, curpos[2])
|
||||
x = gcmd.get_float('X', curpos[0])
|
||||
y = gcmd.get_float('Y', curpos[1])
|
||||
z = gcmd.get_float('Z', curpos[2])
|
||||
logging.info("SET_KINEMATIC_POSITION pos=%.3f,%.3f,%.3f", x, y, z)
|
||||
toolhead.set_position([x, y, z, curpos[3]], homing_axes=(0, 1, 2))
|
||||
self.gcode.reset_last_position()
|
||||
gcode = self.printer.lookup_object('gcode')
|
||||
gcode.reset_last_position()
|
||||
|
||||
def load_config(config):
|
||||
return ForceMove(config)
|
||||
|
|
Loading…
Reference in New Issue