display: Support writing single character glyphs using write_glyph()

Add write_glyph() support to hd44780.py.  Update uc1701.py and
st7920.py to support writing single character glyphs via
write_glyph().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2018-09-20 12:40:30 -04:00
committed by KevinOConnor
parent 2a5778be3a
commit c8d9d575a1
5 changed files with 43 additions and 7 deletions

View File

@@ -9,6 +9,8 @@ import icons, font8x14
BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000
TextGlyphs = { 'right_arrow': '\x1a' }
class UC1701:
char_right_arrow = '\x1a'
CURRENT_BUF, OLD_BUF = 0, 1
@@ -153,6 +155,13 @@ class UC1701:
# Draw icon in graphics mode
for i, bits in enumerate(icon):
self.write_graphics(x, y, i, [(bits >> 8) & 0xff, bits & 0xff])
return 2
char = TextGlyphs.get(glyph_name)
if char is not None:
# Draw character
self.write_text(x, y, char)
return 1
return 0
def clear(self):
zeros = bytearray(128)
for page in self.vram[self.CURRENT_BUF]: