From 1a7e4e51b32bb4eead6eab111293ced012871414 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 8 Jun 2020 17:21:42 -0400 Subject: [PATCH] display: Use '.' and '*' in display_glyph description Signed-off-by: Kevin O'Connor --- config/example-extras.cfg | 9 +- klippy/extras/display/display.cfg | 224 +++++++++++++++--------------- klippy/extras/display/display.py | 20 +-- 3 files changed, 127 insertions(+), 126 deletions(-) diff --git a/config/example-extras.cfg b/config/example-extras.cfg index 59c2c82a..46e056ad 100644 --- a/config/example-extras.cfg +++ b/config/example-extras.cfg @@ -1909,10 +1909,11 @@ # i.e. ~my_display_glyph~ #[display_glyph my_display_glyph] #data: -# The display data, stored as 16 lines consisting of 16 bits (1 per pixel) -# e.g. 1111111111111111 to display a solid horizontal line. Put each display -# line into a separate config line. The glyph must consist of exactly 16 -# lines with 16 bits each. +# The display data, stored as 16 lines consisting of 16 bits (1 per +# pixel) where '.' is a blank pixel and '*' is an on pixel (e.g., +# "****************" to display a solid horizontal line). Put each +# display line into a separate config line. The glyph must consist +# of exactly 16 lines with 16 bits each. # If a primary [display] section has been defined in printer.cfg as shown # above it is possible to define multiple auxilary displays. Note that diff --git a/klippy/extras/display/display.cfg b/klippy/extras/display/display.cfg index 4939792b..1e9d152e 100644 --- a/klippy/extras/display/display.cfg +++ b/klippy/extras/display/display.cfg @@ -193,136 +193,136 @@ text: { render("_print_status") } [display_glyph extruder] data: - 0000000000000000 - 0000000000000000 - 0011111111111100 - 0000011111100000 - 0011111111111100 - 0000011111100000 - 0011111111111100 - 0000000000000000 - 0000111111110000 - 0000111111010000 - 0000111111110000 - 0000000000000000 - 0000001111000000 - 0000000110000000 - 0000000000000000 - 0000000000000000 + ................ + ................ + ..************.. + .....******..... + ..************.. + .....******..... + ..************.. + ................ + ....********.... + ....******.*.... + ....********.... + ................ + ......****...... + .......**....... + ................ + ................ [display_glyph bed] data: - 0000000000000000 - 0000000000000000 - 0000000000000000 - 0000000000000000 - 0000000000000000 - 0000000000000000 - 0000000000000000 - 0000000000000000 - 0000000000000000 - 0000000000000000 - 0000000000000000 - 0001111111110000 - 0010000000001000 - 0111111111111100 - 0000000000000000 - 0000000000000000 + ................ + ................ + ................ + ................ + ................ + ................ + ................ + ................ + ................ + ................ + ................ + ...*********.... + ..*.........*... + .*************.. + ................ + ................ [display_glyph bed_heat1] data: - 0000000000000000 - 0000000000000000 - 0010000100001000 - 0100001000010000 - 0010000100001000 - 0001000010000100 - 0010000100001000 - 0100001000010000 - 0010000100001000 - 0000000000000000 - 0000000000000000 - 0001111111110000 - 0010000000001000 - 0111111111111100 - 0000000000000000 - 0000000000000000 + ................ + ................ + ..*....*....*... + .*....*....*.... + ..*....*....*... + ...*....*....*.. + ..*....*....*... + .*....*....*.... + ..*....*....*... + ................ + ................ + ...*********.... + ..*.........*... + .*************.. + ................ + ................ [display_glyph bed_heat2] data: - 0000000000000000 - 0000000000000000 - 0010000100001000 - 0001000010000100 - 0010000100001000 - 0100001000010000 - 0010000100001000 - 0001000010000100 - 0010000100001000 - 0000000000000000 - 0000000000000000 - 0001111111110000 - 0010000000001000 - 0111111111111100 - 0000000000000000 - 0000000000000000 + ................ + ................ + ..*....*....*... + ...*....*....*.. + ..*....*....*... + .*....*....*.... + ..*....*....*... + ...*....*....*.. + ..*....*....*... + ................ + ................ + ...*********.... + ..*.........*... + .*************.. + ................ + ................ [display_glyph fan1] data: - 0000000000000000 - 0000000000000000 - 0000111000000000 - 0001111000011000 - 0001111000111100 - 0000111001111100 - 0000010000111100 - 0000000110000000 - 0000000110000000 - 0011110000100000 - 0011111001110000 - 0011110001111000 - 0001100001111000 - 0000000001110000 - 0000000000000000 - 0000000000000000 + ................ + ................ + ....***......... + ...****....**... + ...****...****.. + ....***..*****.. + .....*....****.. + .......**....... + .......**....... + ..****....*..... + ..*****..***.... + ..****...****... + ...**....****... + .........***.... + ................ + ................ [display_glyph fan2] data: - 0000000000000000 - 0000000000000000 - 0000000111100000 - 0000000111100000 - 0000000111000000 - 0011000110000000 - 0011100000000000 - 0011110110111100 - 0011110110111100 - 0000000000011100 - 0000000110001100 - 0000001110000000 - 0000011110000000 - 0000011110000000 - 0000000000000000 - 0000000000000000 + ................ + ................ + .......****..... + .......****..... + .......***...... + ..**...**....... + ..***........... + ..****.**.****.. + ..****.**.****.. + ...........***.. + .......**...**.. + ......***....... + .....****....... + .....****....... + ................ + ................ [display_glyph feedrate] data: - 0000000000000000 - 0000000000000000 - 1110111011101100 - 1000100010001010 - 1100110011001010 - 1000100010001010 - 1000111011101100 - 0000000000000000 - 1100010011101110 - 1010101001001000 - 1100111001001100 - 1010101001001000 - 1010101001001110 - 0000000000000000 - 0000000000000000 - 0000000000000000 + ................ + ................ + ***.***.***.**.. + *...*...*...*.*. + **..**..**..*.*. + *...*...*...*.*. + *...***.***.**.. + ................ + **...*..***.***. + *.*.*.*..*..*... + **..***..*..**.. + *.*.*.*..*..*... + *.*.*.*..*..***. + ................ + ................ + ................ # In addition to the above glyphs, 16x4 displays also have the # following hard-coded single character glyphs: right_arrow, degrees. diff --git a/klippy/extras/display/display.py b/klippy/extras/display/display.py index 880e0a32..78d6667c 100644 --- a/klippy/extras/display/display.py +++ b/klippy/extras/display/display.py @@ -147,16 +147,16 @@ class PrinterLCD: glyph_name = dg.get_name()[len(dg_prefix):] glyph_data = [] for line in dg.get('data').split('\n'): - if line: - line_val = int(line, 2) - if line_val > 65535: - raise config.error("Glyph line out of range for " + \ - "glyph %s maximum is 65535" % (glyph_name,)) - glyph_data.append(line_val) - if len(glyph_data) < 16: - raise config.error("Not enough lines for" + \ - "glyph %s, 16 lines are needed" % (glyph_name,)) - icons[dg.get_name()[len(dg_prefix):]] = glyph_data + line = line.strip().replace('.', '0').replace('*', '1') + if not line: + continue + if len(line) != 16 or line.replace('0', '').replace('1', ''): + raise config.error("Invalid glyph line in %s" + % (glyph_name,)) + glyph_data.append(int(line, 2)) + if len(glyph_data) != 16: + raise config.error("Glyph %s must be 16 lines" % (glyph_name,)) + icons[glyph_name] = glyph_data self.lcd_chip.set_glyphs(icons) # Initialization def handle_ready(self):