dhylands / python_lcd

Python based library for talking to character based LCDs.
MIT License
298 stars 116 forks source link

Update README.md #38

Closed clach04 closed 2 years ago

clach04 commented 2 years ago

Link to online character editor

clach04 commented 2 years ago

Note due bug #36 CPython doesn't work out of the box with custom characters, e.g. the happy face sample in the readme fails.

Workaround:

# Monkey patch time
def sleep_us(usecs):
    time.sleep(usecs / 1000000)

time.sleep_us = sleep_us  # monkey patch

happy_face = bytearray([0x00,0x0A,0x00,0x04,0x00,0x11,0x0E,0x00])
happy_face = (
        0b00001,
        0b00010,
        0b00010,
        0b00110,
        0b01000,
        0b01000,
        0b01000,
        0b10000
)

lcd.custom_char(0, happy_face)
lcd.putchar(chr(0))