diff options
Diffstat (limited to 'klippy/toolhead.py')
-rw-r--r-- | klippy/toolhead.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 1b5021c0..d6b36cc9 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -205,6 +205,7 @@ class ToolHead: self.move_flush_time = config.getfloat( 'move_flush_time', 0.050, above=0.) self.print_time = 0. + self.last_print_start_time = 0. self.need_check_stall = -1. self.print_stall = 0 self.sync_print_time = True @@ -236,8 +237,9 @@ class ToolHead: self.sync_print_time = False self.need_motor_off = True est_print_time = self.mcu.estimated_print_time(self.reactor.monotonic()) - self.print_time = max( - self.print_time, est_print_time + self.buffer_time_start) + 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) return self.print_time def _flush_lookahead(self, must_sync=False): @@ -365,6 +367,16 @@ class ToolHead: is_active = buffer_time > -60. or not self.sync_print_time return is_active, "print_time=%.3f buffer_time=%.3f print_stall=%d" % ( self.print_time, max(buffer_time, 0.), self.print_stall) + def get_status(self, eventtime): + buffer_time = self.print_time - self.mcu.estimated_print_time(eventtime) + if buffer_time > -1. or not self.sync_print_time: + status = "Printing" + elif self.need_motor_off: + status = "Ready" + else: + status = "Idle" + printing_time = self.print_time - self.last_print_start_time + return {'status': status, 'printing_time': printing_time} def printer_state(self, state): if state == 'shutdown': try: |