aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--klippy/toolhead.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index 51d39148..85e4be53 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -17,6 +17,7 @@ class Move:
self.start_pos = tuple(start_pos)
self.end_pos = tuple(end_pos)
self.accel = toolhead.max_accel
+ self.timing_callbacks = []
velocity = min(speed, toolhead.max_velocity)
self.is_kinematic_move = True
self.axes_d = axes_d = [end_pos[i] - start_pos[i] for i in (0, 1, 2, 3)]
@@ -112,6 +113,10 @@ class MoveQueue:
self.junction_flush = LOOKAHEAD_FLUSH_TIME
def set_flush_time(self, flush_time):
self.junction_flush = flush_time
+ def get_last(self):
+ if self.queue:
+ return self.queue[-1]
+ return None
def flush(self, lazy=False):
self.junction_flush = LOOKAHEAD_FLUSH_TIME
update_flush_count = lazy
@@ -314,6 +319,8 @@ class ToolHead:
self.extruder.move(next_move_time, move)
next_move_time = (next_move_time + move.accel_t
+ move.cruise_t + move.decel_t)
+ for cb in move.timing_callbacks:
+ cb(next_move_time)
# Generate steps for moves
if self.special_queuing_state:
self._update_drip_move_time(next_move_time)
@@ -507,6 +514,12 @@ class ToolHead:
self.kin_flush_times.append(delay)
new_delay = max(self.kin_flush_times + [0.])
self.kin_flush_delay = new_delay
+ def register_lookahead_callback(self, callback):
+ last_move = self.move_queue.get_last()
+ if last_move is None:
+ callback(self.get_last_move_time())
+ return
+ last_move.timing_callbacks.append(callback)
def note_kinematic_activity(self, kin_time):
self.last_kin_move_time = max(self.last_kin_move_time, kin_time)
def get_max_velocity(self):