From db7a9cf071abcd7c57ec788b906ff96d7b3c41d9 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 12 Apr 2025 16:54:49 -0400 Subject: manual_stepper: Implement "drip moves" for manual stepper STOP_ON_ENDSTOP Currently, `MANUAL_STEPPER STOP_ON_ENDSTOP=1` type commands will move until hitting the endstop, but it will still always consume the total amount of move time. That is, following moves can't be started until the total possible time of the homing move is completed. Implement "drip moves" so that the code only schedules the movement in small segments. This allows following movements to be scheduled without a significant delay. Signed-off-by: Kevin O'Connor --- klippy/extras/manual_stepper.py | 24 +++++++++++++++++++----- klippy/toolhead.py | 4 +++- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'klippy') diff --git a/klippy/extras/manual_stepper.py b/klippy/extras/manual_stepper.py index 9f21cc8d..1465590d 100644 --- a/klippy/extras/manual_stepper.py +++ b/klippy/extras/manual_stepper.py @@ -55,17 +55,20 @@ class ManualStepper: self.sync_print_time() def do_set_position(self, setpos): self.rail.set_position([setpos, 0., 0.]) - def do_move(self, movepos, speed, accel, sync=True): - self.sync_print_time() + def _submit_move(self, movetime, movepos, speed, accel): cp = self.rail.get_commanded_position() dist = movepos - cp axis_r, accel_t, cruise_t, cruise_v = force_move.calc_move_time( dist, speed, accel) - self.trapq_append(self.trapq, self.next_cmd_time, + self.trapq_append(self.trapq, movetime, accel_t, cruise_t, accel_t, cp, 0., 0., axis_r, 0., 0., 0., cruise_v, accel) - self.next_cmd_time = self.next_cmd_time + accel_t + cruise_t + accel_t + return movetime + accel_t + cruise_t + accel_t + def do_move(self, movepos, speed, accel, sync=True): + self.sync_print_time() + self.next_cmd_time = self._submit_move(self.next_cmd_time, movepos, + speed, accel) self.rail.generate_steps(self.next_cmd_time) self.trapq_finalize_moves(self.trapq, self.next_cmd_time + 99999.9, self.next_cmd_time + 99999.9) @@ -117,7 +120,18 @@ class ManualStepper: def dwell(self, delay): self.next_cmd_time += max(0., delay) def drip_move(self, newpos, speed, drip_completion): - self.do_move(newpos[0], speed, self.homing_accel) + # Submit move to trapq + self.sync_print_time() + maxtime = self._submit_move(self.next_cmd_time, newpos[0], + speed, self.homing_accel) + # Drip updates to motors + toolhead = self.printer.lookup_object('toolhead') + toolhead.drip_update_time(maxtime, drip_completion, self.steppers) + # Clear trapq of any remaining parts of movement + reactor = self.printer.get_reactor() + self.trapq_finalize_moves(self.trapq, reactor.NEVER, 0) + self.rail.set_position([newpos[0], 0., 0.]) + self.sync_print_time() def get_kinematics(self): return self def get_steppers(self): diff --git a/klippy/toolhead.py b/klippy/toolhead.py index f7d7ef7e..806da7bf 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -503,7 +503,7 @@ class ToolHead: def get_extruder(self): return self.extruder # Homing "drip move" handling - def drip_update_time(self, next_print_time, drip_completion): + def drip_update_time(self, next_print_time, drip_completion, addstepper=()): # Transition from "NeedPrime"/"Priming"/main state to "Drip" state self.special_queuing_state = "Drip" self.need_check_pause = self.reactor.NEVER @@ -526,6 +526,8 @@ class ToolHead: npt = min(self.print_time + DRIP_SEGMENT_TIME, next_print_time) self.note_mcu_movequeue_activity(npt + self.kin_flush_delay, set_step_gen_time=True) + for stepper in addstepper: + stepper.generate_steps(npt) self._advance_move_time(npt) # Exit "Drip" state self.reactor.update_timer(self.flush_timer, self.reactor.NOW) -- cgit v1.2.3-70-g09d2