LcdDisplay.DriverUtil (lcd_display v0.0.15) View Source

A collection of utility functions that are used for display drivers.

Link to this section Summary

Functions

Determines a cursor position based on the display configuration (rows and columns) and the zero-indexed cursor position (row and column).

Determine a list of row offsets based on how many columns the display has.

Link to this section Functions

Link to this function

determine_cursor_position(arg1, arg2)

View Source

Specs

determine_cursor_position({num_rows(), num_cols()}, {row_pos(), col_pos()}) ::
  non_neg_integer()

Determines a cursor position based on the display configuration (rows and columns) and the zero-indexed cursor position (row and column).

Examples

iex> LcdDisplay.DriverUtil.determine_cursor_position({2, 16}, {0,0})
0

iex> LcdDisplay.DriverUtil.determine_cursor_position({2, 16}, {0,15})
15

iex> LcdDisplay.DriverUtil.determine_cursor_position({2, 16}, {1,0})
64

iex> LcdDisplay.DriverUtil.determine_cursor_position({2, 16}, {1,15})
79
Link to this function

row_offsets_for_num_cols(num_cols)

View Source

Specs

row_offsets_for_num_cols(num_cols()) :: {0, 64, pos_integer(), pos_integer()}

Determine a list of row offsets based on how many columns the display has.

Examples

iex> LcdDisplay.DriverUtil.row_offsets_for_num_cols(8) {0, 64, 8, 72}

iex> LcdDisplay.DriverUtil.row_offsets_for_num_cols(16) {0, 64, 16, 80}

iex> LcdDisplay.DriverUtil.row_offsets_for_num_cols(20) {0, 64, 20, 84}