toolhead: Add register_lookahead_callback() method
Add a mechanism for obtaining the print_time via a callback instead of by flushing the look-ahead queue. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
4b6a65c1e0
commit
8158dbcc21
|
@ -17,6 +17,7 @@ class Move:
|
||||||
self.start_pos = tuple(start_pos)
|
self.start_pos = tuple(start_pos)
|
||||||
self.end_pos = tuple(end_pos)
|
self.end_pos = tuple(end_pos)
|
||||||
self.accel = toolhead.max_accel
|
self.accel = toolhead.max_accel
|
||||||
|
self.timing_callbacks = []
|
||||||
velocity = min(speed, toolhead.max_velocity)
|
velocity = min(speed, toolhead.max_velocity)
|
||||||
self.is_kinematic_move = True
|
self.is_kinematic_move = True
|
||||||
self.axes_d = axes_d = [end_pos[i] - start_pos[i] for i in (0, 1, 2, 3)]
|
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
|
self.junction_flush = LOOKAHEAD_FLUSH_TIME
|
||||||
def set_flush_time(self, flush_time):
|
def set_flush_time(self, flush_time):
|
||||||
self.junction_flush = 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):
|
def flush(self, lazy=False):
|
||||||
self.junction_flush = LOOKAHEAD_FLUSH_TIME
|
self.junction_flush = LOOKAHEAD_FLUSH_TIME
|
||||||
update_flush_count = lazy
|
update_flush_count = lazy
|
||||||
|
@ -314,6 +319,8 @@ class ToolHead:
|
||||||
self.extruder.move(next_move_time, move)
|
self.extruder.move(next_move_time, move)
|
||||||
next_move_time = (next_move_time + move.accel_t
|
next_move_time = (next_move_time + move.accel_t
|
||||||
+ move.cruise_t + move.decel_t)
|
+ move.cruise_t + move.decel_t)
|
||||||
|
for cb in move.timing_callbacks:
|
||||||
|
cb(next_move_time)
|
||||||
# Generate steps for moves
|
# Generate steps for moves
|
||||||
if self.special_queuing_state:
|
if self.special_queuing_state:
|
||||||
self._update_drip_move_time(next_move_time)
|
self._update_drip_move_time(next_move_time)
|
||||||
|
@ -507,6 +514,12 @@ class ToolHead:
|
||||||
self.kin_flush_times.append(delay)
|
self.kin_flush_times.append(delay)
|
||||||
new_delay = max(self.kin_flush_times + [0.])
|
new_delay = max(self.kin_flush_times + [0.])
|
||||||
self.kin_flush_delay = new_delay
|
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):
|
def note_kinematic_activity(self, kin_time):
|
||||||
self.last_kin_move_time = max(self.last_kin_move_time, kin_time)
|
self.last_kin_move_time = max(self.last_kin_move_time, kin_time)
|
||||||
def get_max_velocity(self):
|
def get_max_velocity(self):
|
||||||
|
|
Loading…
Reference in New Issue