mcu: Remove set_ignore_move()

Update callers of set_ignore_move() to use the trapq system to set a
stepper to ignore moves.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-10-29 12:06:46 -04:00
parent befd263260
commit bd3c8920f6
4 changed files with 13 additions and 28 deletions

View File

@ -56,10 +56,8 @@ class ForceMove:
if not was_enable: if not was_enable:
stepper.motor_enable(print_time, 1) stepper.motor_enable(print_time, 1)
toolhead.dwell(STALL_TIME) toolhead.dwell(STALL_TIME)
was_ignore = stepper.set_ignore_move(False) return was_enable
return was_enable, was_ignore def restore_enable(self, stepper, was_enable):
def restore_enable(self, stepper, was_enable, was_ignore):
stepper.set_ignore_move(was_ignore)
if not was_enable: if not was_enable:
toolhead = self.printer.lookup_object('toolhead') toolhead = self.printer.lookup_object('toolhead')
toolhead.dwell(STALL_TIME) toolhead.dwell(STALL_TIME)
@ -89,14 +87,14 @@ class ForceMove:
def cmd_STEPPER_BUZZ(self, params): def cmd_STEPPER_BUZZ(self, params):
stepper = self._lookup_stepper(params) stepper = self._lookup_stepper(params)
logging.info("Stepper buzz %s", stepper.get_name()) logging.info("Stepper buzz %s", stepper.get_name())
was_enable, was_ignore = self.force_enable(stepper) was_enable = self.force_enable(stepper)
toolhead = self.printer.lookup_object('toolhead') toolhead = self.printer.lookup_object('toolhead')
for i in range(10): for i in range(10):
self.manual_move(stepper, 1., BUZZ_VELOCITY) self.manual_move(stepper, 1., BUZZ_VELOCITY)
toolhead.dwell(.050) toolhead.dwell(.050)
self.manual_move(stepper, -1., BUZZ_VELOCITY) self.manual_move(stepper, -1., BUZZ_VELOCITY)
toolhead.dwell(.450) toolhead.dwell(.450)
self.restore_enable(stepper, was_enable, was_ignore) self.restore_enable(stepper, was_enable)
cmd_FORCE_MOVE_help = "Manually move a stepper; invalidates kinematics" cmd_FORCE_MOVE_help = "Manually move a stepper; invalidates kinematics"
def cmd_FORCE_MOVE(self, params): def cmd_FORCE_MOVE(self, params):
stepper = self._lookup_stepper(params) stepper = self._lookup_stepper(params)
@ -105,9 +103,8 @@ class ForceMove:
accel = self.gcode.get_float('ACCEL', params, 0., minval=0.) accel = self.gcode.get_float('ACCEL', params, 0., minval=0.)
logging.info("FORCE_MOVE %s distance=%.3f velocity=%.3f accel=%.3f", logging.info("FORCE_MOVE %s distance=%.3f velocity=%.3f accel=%.3f",
stepper.get_name(), distance, speed, accel) stepper.get_name(), distance, speed, accel)
was_enable, was_ignore = self.force_enable(stepper) self.force_enable(stepper)
self.manual_move(stepper, distance, speed, accel) self.manual_move(stepper, distance, speed, accel)
self.restore_enable(stepper, True, was_ignore)
cmd_SET_KINEMATIC_POSITION_help = "Force a low-level kinematic position" cmd_SET_KINEMATIC_POSITION_help = "Force a low-level kinematic position"
def cmd_SET_KINEMATIC_POSITION(self, params): def cmd_SET_KINEMATIC_POSITION(self, params):
toolhead = self.printer.lookup_object('toolhead') toolhead = self.printer.lookup_object('toolhead')

View File

@ -36,7 +36,7 @@ class ZAdjustHelper:
gcode.respond_info(msg) gcode.respond_info(msg)
# Disable Z stepper movements # Disable Z stepper movements
for s in self.z_steppers: for s in self.z_steppers:
s.set_ignore_move(True) s.set_trapq(None)
# Move each z stepper (sorted from lowest to highest) until they match # Move each z stepper (sorted from lowest to highest) until they match
positions = [(-a, s) for a, s in zip(adjustments, self.z_steppers)] positions = [(-a, s) for a, s in zip(adjustments, self.z_steppers)]
positions.sort() positions.sort()
@ -45,7 +45,7 @@ class ZAdjustHelper:
for i in range(len(positions)-1): for i in range(len(positions)-1):
stepper_offset, stepper = positions[i] stepper_offset, stepper = positions[i]
next_stepper_offset, next_stepper = positions[i+1] next_stepper_offset, next_stepper = positions[i+1]
stepper.set_ignore_move(False) stepper.set_trapq(toolhead.get_trapq())
curpos[2] = z_low + next_stepper_offset curpos[2] = z_low + next_stepper_offset
try: try:
toolhead.move(curpos, speed) toolhead.move(curpos, speed)
@ -53,11 +53,11 @@ class ZAdjustHelper:
except: except:
logging.exception("ZAdjustHelper adjust_steppers") logging.exception("ZAdjustHelper adjust_steppers")
for s in self.z_steppers: for s in self.z_steppers:
s.set_ignore_move(False) s.set_trapq(toolhead.get_trapq())
raise raise
# Z should now be level - do final cleanup # Z should now be level - do final cleanup
last_stepper_offset, last_stepper = positions[-1] last_stepper_offset, last_stepper = positions[-1]
last_stepper.set_ignore_move(False) last_stepper.set_trapq(toolhead.get_trapq())
curpos[2] += first_stepper_offset curpos[2] += first_stepper_offset
toolhead.set_position(curpos) toolhead.set_position(curpos)
gcode.reset_last_position() gcode.reset_last_position()

View File

@ -26,10 +26,11 @@ class MCU_stepper:
self._stepqueue = ffi_main.gc(self._ffi_lib.stepcompress_alloc(oid), self._stepqueue = ffi_main.gc(self._ffi_lib.stepcompress_alloc(oid),
self._ffi_lib.stepcompress_free) self._ffi_lib.stepcompress_free)
self._mcu.register_stepqueue(self._stepqueue) self._mcu.register_stepqueue(self._stepqueue)
self._stepper_kinematics = self._itersolve_gen_steps = None self._stepper_kinematics = None
self._itersolve_generate_steps = self._itersolve_check_active = None self._itersolve_gen_steps = self._ffi_lib.itersolve_gen_steps
self._itersolve_generate_steps = self._ffi_lib.itersolve_generate_steps
self._itersolve_check_active = self._ffi_lib.itersolve_check_active
self._trapq = ffi_main.NULL self._trapq = ffi_main.NULL
self.set_ignore_move(False)
def get_mcu(self): def get_mcu(self):
return self._mcu return self._mcu
def setup_dir_pin(self, pin_params): def setup_dir_pin(self, pin_params):
@ -97,18 +98,6 @@ class MCU_stepper:
self._ffi_lib.itersolve_set_stepcompress( self._ffi_lib.itersolve_set_stepcompress(
sk, self._stepqueue, self._step_dist) sk, self._stepqueue, self._step_dist)
return old_sk return old_sk
def set_ignore_move(self, ignore_move):
fl = self._ffi_lib
was_ignore = self._itersolve_gen_steps is not fl.itersolve_gen_steps
if ignore_move:
self._itersolve_gen_steps = (lambda *args: 0)
self._itersolve_generate_steps = (lambda *args: 0)
self._itersolve_check_active = (lambda *args: 0.)
else:
self._itersolve_gen_steps = fl.itersolve_gen_steps
self._itersolve_generate_steps = fl.itersolve_generate_steps
self._itersolve_check_active = fl.itersolve_check_active
return was_ignore
def note_homing_end(self, did_trigger=False): def note_homing_end(self, did_trigger=False):
ret = self._ffi_lib.stepcompress_reset(self._stepqueue, 0) ret = self._ffi_lib.stepcompress_reset(self._stepqueue, 0)
if ret: if ret:

View File

@ -81,7 +81,6 @@ class PrinterStepper:
self.generate_steps = mcu_stepper.generate_steps self.generate_steps = mcu_stepper.generate_steps
self.set_trapq = mcu_stepper.set_trapq self.set_trapq = mcu_stepper.set_trapq
self.set_stepper_kinematics = mcu_stepper.set_stepper_kinematics self.set_stepper_kinematics = mcu_stepper.set_stepper_kinematics
self.set_ignore_move = mcu_stepper.set_ignore_move
self.calc_position_from_coord = mcu_stepper.calc_position_from_coord self.calc_position_from_coord = mcu_stepper.calc_position_from_coord
self.set_position = mcu_stepper.set_position self.set_position = mcu_stepper.set_position
self.get_commanded_position = mcu_stepper.get_commanded_position self.get_commanded_position = mcu_stepper.get_commanded_position