Check if connected to printer before updating display
This commit is contained in:
parent
8691101976
commit
e7e15cf7c5
1 changed files with 19 additions and 12 deletions
|
@ -30,6 +30,8 @@ class LCD_HD44780(octoprint.plugin.StartupPlugin,
|
|||
self.cols = 20
|
||||
self.rows = 4
|
||||
|
||||
self._ClosedOrError = False
|
||||
|
||||
self._line1 = ''
|
||||
self._line2 = ''
|
||||
self._line3 = ''
|
||||
|
@ -170,11 +172,9 @@ class LCD_HD44780(octoprint.plugin.StartupPlugin,
|
|||
pass
|
||||
|
||||
def on_printer_add_temperature(self, data):
|
||||
try:
|
||||
if not self._ClosedOrError:
|
||||
self._line4 = 'E{:3.0f}/{:3.0f} B{:3.0f}/{:3.0f}'.format(data['tool0']['actual'], data['tool0']['target'], data['bed']['actual'], data['bed']['target'])
|
||||
self._lcd_update()
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def on_printer_received_registered_message(self, name, output):
|
||||
pass
|
||||
|
@ -182,6 +182,9 @@ class LCD_HD44780(octoprint.plugin.StartupPlugin,
|
|||
def on_printer_send_current_data(self, data):
|
||||
self._line1 = data['state']['text'][:20].center(20)
|
||||
|
||||
self._ClosedOrError = data['state']['flags']['closedOrError']
|
||||
|
||||
if not self._ClosedOrError:
|
||||
if data['job']['file']['name'] is not None:
|
||||
self._line2 = data['job']['file']['name'][:20]
|
||||
else:
|
||||
|
@ -194,6 +197,10 @@ class LCD_HD44780(octoprint.plugin.StartupPlugin,
|
|||
self._line3 += ' ~' + '{:1.0f}:{:02.0f}'.format(data['progress']['printTimeLeft']/60, data['progress']['printTimeLeft']%60) + 'min '
|
||||
else:
|
||||
self._line3 = ''
|
||||
else:
|
||||
self._line2 = ''
|
||||
self._line3 = ''
|
||||
self._line4 = ''
|
||||
|
||||
self._lcd_update()
|
||||
|
||||
|
|
Loading…
Reference in a new issue