diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-09-20 11:58:43 -0400 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2018-09-21 16:39:38 -0400 |
commit | 2a5778be3a921a59733ee85791d18ae0b8ff4a92 (patch) | |
tree | 2c1dbeeb0a729c4520e61e4f4ef992a33cd652fe /klippy/extras/display/uc1701.py | |
parent | 2857255ef18fc12a4e04a2850556d7300f8e36f2 (diff) | |
download | kutter-2a5778be3a921a59733ee85791d18ae0b8ff4a92.tar.gz kutter-2a5778be3a921a59733ee85791d18ae0b8ff4a92.tar.xz kutter-2a5778be3a921a59733ee85791d18ae0b8ff4a92.zip |
display: Move icon drawing from display.py to lcd_chip code
Move the st7920 icon rendering optimizations from display.py to
st7920.py. This simplifies the code for other displays.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/display/uc1701.py')
-rw-r--r-- | klippy/extras/display/uc1701.py | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/klippy/extras/display/uc1701.py b/klippy/extras/display/uc1701.py index 32ba7ebf..5a2239eb 100644 --- a/klippy/extras/display/uc1701.py +++ b/klippy/extras/display/uc1701.py @@ -5,7 +5,7 @@ # # This file may be distributed under the terms of the GNU GPLv3 license. import logging -from font8x14 import VGA_FONT as CHAR_SET +import icons, font8x14 BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000 @@ -29,7 +29,6 @@ class UC1701: self.spi_oid = self.mcu.create_oid() self.a0_oid = self.mcu.create_oid() self.mcu.register_config_callback(self.build_config) - self.glyph_buffer = [] self.spi_xfer_cmd = self.set_pin_cmd = None self.vram = ([bytearray(128) for i in range(8)], [bytearray('~'*128) for i in range(8)]) @@ -114,24 +113,6 @@ class UC1701: page_byte = ~(0x01 << (pix_y % 8)) #set the correct pixel in the vram buffer to 0 self.vram[self.CURRENT_BUF][page_idx][pix_x] &= page_byte - def load_glyph(self, glyph_id, data): - if len(data) > 16: - data = data[:16] - self.glyph_buffer.append((glyph_id, data)) - self.glyph_buffer.sort(key=lambda x: x[0]) - def write_glyph(self, x, y, glyph_id): - pix_x = x*8 - pix_y = y*16 - data = self.glyph_buffer[glyph_id][1] - for bits in data: - if bits: - bit_x = pix_x - for i in range(15, -1, -1): - mask = 0x0001 << i - if bits & mask: - self.set_pixel(bit_x, pix_y) - bit_x += 1 - pix_y += 1 def write_text(self, x, y, data): if x + len(data) > 16: data = data[:16 - min(x, 16)] @@ -143,7 +124,7 @@ class UC1701: # Empty char pix_x += 8 continue - char = CHAR_SET[c_idx] + char = font8x14.VGA_FONT[c_idx] bit_y = pix_y for bits in char: if bits: @@ -166,6 +147,12 @@ class UC1701: if bits & mask: self.set_pixel(pix_x, pix_y) pix_x += 1 + def write_glyph(self, x, y, glyph_name): + icon = icons.Icons16x16.get(glyph_name) + if icon is not None: + # Draw icon in graphics mode + for i, bits in enumerate(icon): + self.write_graphics(x, y, i, [(bits >> 8) & 0xff, bits & 0xff]) def clear(self): zeros = bytearray(128) for page in self.vram[self.CURRENT_BUF]: |