- Notifications
You must be signed in to change notification settings - Fork6
Use character liquid crystal display (LCD) in Elixir
License
mnishiguchi/lcd_display
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
LcdDisplay
allows you to control aHitachi HD44780-compatibleLiquid-crystal display (LCD) inElixir.
For the specification of the HD44780 LCD, please refer to theHD44780 data sheet.
You can installLcdDisplay
by addinglcd_display
to your list of dependencies inmix.exs
:
defdepsdo[{:lcd_display,"~> 0.2.0"}]end
As an example, if you want to control aHitachi HD44780 type display throughthe 8-bit I/O expanderPCF8574,you can useLcdDisplay.HD44780.PCF8574
module as a display driver.
driver_config=%{driver_module:LcdDisplay.HD44780.PCF8574,i2c_bus:"i2c-1",# I2C bus namei2c_address:0x27,# 7-bit addressrows:2,# the number of display rowscols:16,# the number of display columnsfont_size:"5x8"# "5x10" or "5x8"}{:ok,pid}=LcdDisplay.start_link(driver_config)
Many configuration values are optional, falling back to default values. Please refer to each display module documentation.
Please refer to theLcdDisplay.HD44780.Driver
documentation for supported display commands.
# Print textLcdDisplay.execute(pid,{:print,"Hello world"})# Clear the displayLcdDisplay.execute(pid,:clear)# Print a character at a timeLcdDisplay.execute(pid,{:print,0b00110001})LcdDisplay.execute(pid,{:print,0b00110000})LcdDisplay.execute(pid,{:print,0b00100101})
Different products out there use different I/O expanders, so please be aware of which I/O expander you are using if you use something like an I2C backpack.Also the pin assignment between the LCD and the I/O expander is important since this library assumes certain pin assignment based on popular products out there.
When you connect an LCD standalone directly to the GPIO pins on your target device, theLcdDisplay.HD44780.GPIO
driver module is useful.
Here are some relevant products:
- Adafruit Assembled Standard LCD 16x2 - White on Blue
- Adafruit Standard LCD 16x2 - white on blue
- Adafruit Standard LCD 20x4 - white on blue
- Adafruit RGB backlight LCD 16x2 - black on RGB
- Adafruit RGB backlight LCD 16x2 - RGB on black
Many inexpensive I2C modules on Amazon.com usesPCF8574. A pre-assembled 16x2 LCD with I2C module is typically less than US$10.Handson Technology I2C Serial Interface 1602 LCD Module User Guide summarizes the typical specifications of the PCF8574-based I2C module.
TheAdafruit i2c / SPI character LCD backpack supports both I2C and SPI interfaces. It usesMCP23008 for I2C andSN74HC595 for SPI as of writing.
It is easy to make your own driver modules in case you want a custom pin assignment, a different I/O expander or some custom features.
ExLCD
for inspiration
About
Use character liquid crystal display (LCD) in Elixir