From 46355f903eb8d13448633045346051bc68c1279b Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 15 Oct 2018 18:24:15 -0400 Subject: [PATCH] toolhead: Don't clear sync_print_time on a get_next_move_time() call Only clear the internal sync_print_time flag if the code performs a regular "lazy" flush of the look-ahead queue. This helps build the look-ahead queue even when running internal scripts. Signed-off-by: Kevin O'Connor --- klippy/toolhead.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/klippy/toolhead.py b/klippy/toolhead.py index ad1141f0..dff6e3fa 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -264,15 +264,16 @@ class ToolHead: flush_to_time = self.print_time - self.move_flush_time for m in self.all_mcus: m.flush_moves(flush_to_time) - def get_next_move_time(self): - if not self.sync_print_time: - return self.print_time - self.sync_print_time = False + def _calc_print_time(self): est_print_time = self.mcu.estimated_print_time(self.reactor.monotonic()) if est_print_time + self.buffer_time_start > self.print_time: self.print_time = est_print_time + self.buffer_time_start self.last_print_start_time = self.print_time - self.reactor.update_timer(self.flush_timer, self.reactor.NOW) + def get_next_move_time(self): + if self.sync_print_time: + self.sync_print_time = False + self.reactor.update_timer(self.flush_timer, self.reactor.NOW) + self._calc_print_time() return self.print_time def _flush_lookahead(self, must_sync=False): sync_print_time = self.sync_print_time @@ -287,11 +288,13 @@ class ToolHead: m.flush_moves(self.print_time) def get_last_move_time(self): self._flush_lookahead() - return self.get_next_move_time() + if self.sync_print_time: + self._calc_print_time() + return self.print_time def reset_print_time(self, min_print_time=0.): self._flush_lookahead(must_sync=True) - self.print_time = max(min_print_time, self.mcu.estimated_print_time( - self.reactor.monotonic())) + est_print_time = self.mcu.estimated_print_time(self.reactor.monotonic()) + self.print_time = max(min_print_time, est_print_time) def _check_stall(self): eventtime = self.reactor.monotonic() if self.sync_print_time: