LcdDisplay.HD44780.MCP23017 (lcd_display v0.2.0) View Source
Knows how to commuticate with HD44780 type display through the 16-bit I/O expander MCP23017. You can turn on/off the backlight and change the LED color by switching on/off red, green and blue.
Usage
iex(2)>  Circuits.I2C.detect_devices
Devices on I2C bus "i2c-1":
* 32  (0x20)
1 devices detected on 1 I2C busesconfig = %{
  i2c_bus: "i2c-1",          # I2C bus name
  i2c_address: 0x20,         # 7-bit address
  rows: 2,                   # the number of display rows
  cols: 16,                  # the number of display columns
  font_size: "5x8"           # "5x10" or "5x8"
}
# Start the LCD driver and get the initial display state.
{:ok, display} = LcdDisplay.HD44780.MCP23017.start(config)
# Run a command and the display state will be updated.
{:ok, display} = LcdDisplay.HD44780.MCP23017.execute(display, {:print, "Hello world"})
# Turn on/off `:red`, `:green` and `:blue` to change the backlight color.
{:ok, display} = LcdDisplay.HD44780.MCP23017.execute(display, {:red, false})
# Pick a random backlight color.
{:ok, display} = LcdDisplay.HD44780.MCP23017.execute(display, :random_color)Pin assignment
This module assumes the following pin assignment:
GPIOA
| MCP23017 | HD44780 | 
|---|---|
| GPA0 | - | 
| GPA1 | - | 
| GPA2 | - | 
| GPA3 | - | 
| GPA4 | - | 
| GPA5 | - | 
| GPA6 | LED RED | 
| GPA7 | LED GREEN | 
GPIOB
| MCP23017 | HD44780 | 
|---|---|
| GPB0 | LED BLUE | 
| GPB1 | DB7 (Data Bus 7) | 
| GPB2 | DB6 (Data Bus 6) | 
| GPB3 | DB5 (Data Bus 5) | 
| GPB4 | DB4 (Data Bus 4) | 
| GPB5 | E (Enable) | 
| GPB6 | - | 
| GPB7 | RS (Register Select) | 
Link to this section Summary
Functions
Executes the specified command and returns a new display state.
Initializes the LCD driver and returns the initial display state.
Link to this section Types
Specs
config() :: %{
  optional(:rows) => String.t(),
  optional(:cols) => pos_integer(),
  optional(:font_size) => pos_integer()
}
      The configuration options.
Specs
display_driver() :: LcdDisplay.HD44780.Driver.t()
Specs
rgb_key() :: :red | :green | :blue
Link to this section Functions
Executes the specified command and returns a new display state.
Specs
set_random_color(display_driver()) :: display_driver()
Specs
start(config()) :: {:ok, display_driver()} | {:error, any()}
Initializes the LCD driver and returns the initial display state.