display: Use write_glyph() when writing special characters

Always use the write_glyph() method when writing special characters
during status screen updates.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-09-20 13:01:51 -04:00 committed by KevinOConnor
parent c8d9d575a1
commit 30a49d3186
4 changed files with 20 additions and 23 deletions

View File

@ -89,15 +89,15 @@ class PrinterLCD:
# Heaters
if self.extruder0 is not None:
info = self.extruder0.get_heater().get_status(eventtime)
lcd_chip.write_text(0, 0, lcd_chip.char_thermometer)
lcd_chip.write_glyph(0, 0, 'extruder')
self.draw_heater(1, 0, info)
if self.extruder1 is not None:
info = self.extruder1.get_heater().get_status(eventtime)
lcd_chip.write_text(0, 1, lcd_chip.char_thermometer)
lcd_chip.write_glyph(0, 1, 'extruder')
self.draw_heater(1, 1, info)
if self.heater_bed is not None:
info = self.heater_bed.get_status(eventtime)
lcd_chip.write_text(10, 0, lcd_chip.char_heater_bed)
lcd_chip.write_glyph(10, 0, 'bed')
self.draw_heater(11, 0, info)
# Fan speed
if self.fan is not None:
@ -106,14 +106,14 @@ class PrinterLCD:
self.draw_percent(14, 1, 4, info['speed'])
# G-Code speed factor
gcode_info = self.gcode.get_status(eventtime)
lcd_chip.write_text(0, 2, lcd_chip.char_speed_factor)
lcd_chip.write_glyph(0, 2, 'feedrate')
self.draw_percent(1, 2, 4, gcode_info['speed_factor'])
# Print progress
progress = None
toolhead_info = self.toolhead.get_status(eventtime)
if self.progress is not None:
progress = self.progress / 100.
lcd_chip.write_text(8, 2, lcd_chip.char_usb)
lcd_chip.write_glyph(8, 2, 'usb')
if toolhead_info['status'] != "Printing":
# 5 second timeout when not printing
self.prg_time -= .5
@ -122,10 +122,10 @@ class PrinterLCD:
elif self.sdcard is not None:
info = self.sdcard.get_status(eventtime)
progress = info['progress']
lcd_chip.write_text(8, 2, lcd_chip.char_sd)
lcd_chip.write_glyph(8, 2, 'sd')
if progress is not None:
self.draw_percent(9, 2, 4, progress)
lcd_chip.write_text(14, 2, lcd_chip.char_clock)
lcd_chip.write_glyph(14, 2, 'clock')
self.draw_time(15, 2, toolhead_info['printing_time'])
# If there is a message set by M117, display it instead of toolhead info
if self.message:
@ -212,16 +212,23 @@ class PrinterLCD:
else:
self.draw_status(0, 3, gcode_info, toolhead_info)
# Screen update helpers
def draw_text(self, x, y, mixed_text):
pos = x
for i, text in enumerate(mixed_text.split('~')):
if i & 1 == 0:
# write text
self.lcd_chip.write_text(pos, y, text)
pos += len(text)
else:
# write glyph
pos += self.lcd_chip.write_glyph(pos, y, text)
def draw_heater(self, x, y, info):
temperature, target = info['temperature'], info['target']
if target and abs(temperature - target) > 2.:
s = "%3.0f%s%.0f" % (
temperature, self.lcd_chip.char_right_arrow, target)
self.draw_text(x, y, "%3.0f~right_arrow~%.0f~degrees~" % (
temperature, target))
else:
s = "%3.0f" % (temperature,)
if self.lcd_type == 'hd44780':
s += self.lcd_chip.char_degrees
self.lcd_chip.write_text(x, y, s)
self.draw_text(x, y, "%3.0f~degrees~" % (temperature,))
def draw_percent(self, x, y, width, value, align='^'):
self.lcd_chip.write_text(x, y, '{:{}{}.0%}'.format(value, align, width))
def draw_time(self, x, y, seconds):

View File

@ -11,14 +11,6 @@ BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000
HD44780_DELAY = .000037
class HD44780:
char_right_arrow = '\x7e'
char_thermometer = '\x00'
char_heater_bed = '\x01'
char_speed_factor = '\x02'
char_clock = '\x03'
char_degrees = '\x04'
char_usb = '\x05'
char_sd = '\x06'
def __init__(self, config):
self.printer = config.get_printer()
# pin config

View File

@ -15,7 +15,6 @@ ST7920_SYNC_DELAY = .000045
TextGlyphs = { 'right_arrow': '\x1a' }
class ST7920:
char_right_arrow = '\x1a'
def __init__(self, config):
printer = config.get_printer()
# pin config

View File

@ -12,7 +12,6 @@ BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000
TextGlyphs = { 'right_arrow': '\x1a' }
class UC1701:
char_right_arrow = '\x1a'
CURRENT_BUF, OLD_BUF = 0, 1
EMPTY_CHAR = (0, 32, 255)
def __init__(self, config):