LcdDisplay.DriverUtil (lcd_display v0.0.17) View Source
A collection of utility functions that are used for display drivers.
Link to this section Summary
Functions
Determine a list of row offsets based on how many columns the display has.
Determines a Display Data RAM (DDRAM) address based on the display configuration (rows and columns) and the zero-indexed cursor position (row and column).
Link to this section Types
Specs
display_config() :: %{ :rows => LcdDisplay.Driver.num_rows(), :cols => LcdDisplay.Driver.num_cols(), required(any()) => any() }
Typically 2x16 or 4x20.
Specs
row_col_pos() :: {non_neg_integer(), non_neg_integer()}
Link to this section Functions
Specs
ddram_row_offsets(LcdDisplay.Driver.num_cols()) :: {0, 64, pos_integer(), pos_integer()}
Determine a list of row offsets based on how many columns the display has.
0x00: | ROW 0 | ROW 2 |
0x40: | ROW 1 | ROW 3 |
For more info, please refer to Hitachi HD44780 datasheet page 10.
Examples
iex> LcdDisplay.DriverUtil.ddram_row_offsets(8)
{0, 64, 8, 72}
iex> LcdDisplay.DriverUtil.ddram_row_offsets(16)
{0, 64, 16, 80}
iex> LcdDisplay.DriverUtil.ddram_row_offsets(20)
{0, 64, 20, 84}
Specs
determine_ddram_address(row_col_pos(), display_config()) :: non_neg_integer()
Determines a Display Data RAM (DDRAM) address based on the display configuration (rows and columns) and the zero-indexed cursor position (row and column).
Examples
iex> LcdDisplay.DriverUtil.determine_ddram_address({0,0}, %{rows: 2, cols: 16})
0
iex> LcdDisplay.DriverUtil.determine_ddram_address({0,15}, %{rows: 2, cols: 16})
15
iex> LcdDisplay.DriverUtil.determine_ddram_address({1,0}, %{rows: 2, cols: 16})
64
iex> LcdDisplay.DriverUtil.determine_ddram_address({1,15}, %{rows: 2, cols: 16})
79