aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-09-20 13:01:51 -0400
committerKevinOConnor <kevin@koconnor.net>2018-09-21 16:39:38 -0400
commit30a49d3186c8bee11581422901b46be23b07e29e (patch)
tree192129b2b50a31fd3e0ed63ee57f97988d2ab957
parentc8d9d575a1eaddf536002b3a4330e5e3b4dc9ad1 (diff)
downloadkutter-30a49d3186c8bee11581422901b46be23b07e29e.tar.gz
kutter-30a49d3186c8bee11581422901b46be23b07e29e.tar.xz
kutter-30a49d3186c8bee11581422901b46be23b07e29e.zip
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>
-rw-r--r--klippy/extras/display/display.py33
-rw-r--r--klippy/extras/display/hd44780.py8
-rw-r--r--klippy/extras/display/st7920.py1
-rw-r--r--klippy/extras/display/uc1701.py1
4 files changed, 20 insertions, 23 deletions
diff --git a/klippy/extras/display/display.py b/klippy/extras/display/display.py
index 580f8b8d..7e2bb223 100644
--- a/klippy/extras/display/display.py
+++ b/klippy/extras/display/display.py
@@ -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):
diff --git a/klippy/extras/display/hd44780.py b/klippy/extras/display/hd44780.py
index d864ceaa..2bdf3a30 100644
--- a/klippy/extras/display/hd44780.py
+++ b/klippy/extras/display/hd44780.py
@@ -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
diff --git a/klippy/extras/display/st7920.py b/klippy/extras/display/st7920.py
index 4d92c8b1..4ccfcd24 100644
--- a/klippy/extras/display/st7920.py
+++ b/klippy/extras/display/st7920.py
@@ -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
diff --git a/klippy/extras/display/uc1701.py b/klippy/extras/display/uc1701.py
index ea4efb94..55d3ed2f 100644
--- a/klippy/extras/display/uc1701.py
+++ b/klippy/extras/display/uc1701.py
@@ -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):