From 08a5f8a5ffbc4a3aed825f8e9840702faab482d7 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 20 Feb 2018 20:50:06 -0500 Subject: display: Add initial support for LCD screens attached to an MCU Add support for displaying basic status information on ST7920 and HD44780 based LCDs that are attached directly to a micro-controller. Signed-off-by: Marcio Teixeira Signed-off-by: Kevin O'Connor --- klippy/toolhead.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'klippy/toolhead.py') 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: -- cgit v1.2.3-70-g09d2