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 <marcio@alephobjects.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-02-20 20:50:06 -05:00
parent 43ac56766e
commit 08a5f8a5ff
10 changed files with 588 additions and 2 deletions

View file

@ -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: