dhylands / python_lcd

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

Working CPython 3 support (tested with 3.8.10) #37

Closed clach04 closed 2 years ago

clach04 commented 2 years ago

Added start of install notes.

Python 3 needs relative paths for import to work. Updated import order to match pep-8 (system, third party, then custom/local imports).

Demo code that works for me with both CPython 2.7 and 3.8:

"""Display to a HD44780 character LCD connected via PCF8574 on I2C."""

import sys

from lcd.i2c_lcd import I2cLcd  # https://github.com/dhylands/python_lcd

print('Python %r on %r' % (sys.version, sys.platform))

# The PCF8574 has a jumper selectable address: 0x20 - 0x27
DEFAULT_I2C_ADDR = 0x27

lcd = I2cLcd(1, DEFAULT_I2C_ADDR, 2, 16)
#lcd.blink_cursor_on()
#lcd.blink_cursor_off()
lcd.hide_cursor()
d_str = 'The quick brown fox jumps over t'  #
lcd.putstr(d_str)