Skip to content

Instantly share code, notes, and snippets.

Created July 29, 2015 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0fd82d376cd22763faf1 to your computer and use it in GitHub Desktop.
Save anonymous/0fd82d376cd22763faf1 to your computer and use it in GitHub Desktop.
define new lcd character
import wiringpi2 as wiringpi
wiringpi.wiringPiSetupSys();
# connecting to the lcd (via i2c)
af_base = 100
af_rs = af_base + 0
af_e = af_base + 2
af_db4 = af_base + 4
af_db5 = af_base + 5
af_db6 = af_base + 6
af_db7 = af_base + 7
af_backlight = af_base + 3
wiringpi.pcf8574Setup(af_base, 0x27)
lcd_handle = wiringpi.lcdInit(4, 20, 4, af_rs, af_e, af_db4, af_db5, af_db6, af_db7, 0, 0, 0, 0)
# turning on the backlight
wiringpi.digitalWrite(af_backlight, 1)
# test if display runs as expected
wiringpi.lcdPrintf(lcd_handle, "Hello World")
# now comes the "tricky part"
wiringpi.lcdCharDef(lcd_handle, 0, b'\x0A\x04\x0A\x11\x1F\x11\x11\x00')
# OUTPUT (IPython Console)
# ---------------------------------------------------------------------------
# TypeError Traceback (most recent call last)
# <ipython-input-2-096051f2f529> in <module>()
# ----> 1 wiringpi.lcdCharDef(lcd_handle, 0, b'\x0A\x04\x0A\x11\x1F\x11\x11\x00')
#
# TypeError: in method 'lcdCharDef', argument 3 of type 'unsigned char [8]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment