LcdDisplay.HD44780.Driver behaviour (lcd_display v0.3.0)

View Source

Defines a behaviour required for an LCD driver.

Summary

Types

Type that represents a supported display command. Some driver modules do not support the backlight LED commands.

Type that represents an available display feature.

t()

Type that represents the display state.

Callbacks

Executes the specified command and returns a new display state.

Initializes the LCD driver and returns the initial display state.

Sends a data byte to the display.

Sends an instruction byte to the display.

Functions

Injects the common logic for an LCD driver. For display flags, please refer to HD44780 data sheet.

Types

command()

@type command() ::
  :clear
  | :home
  | {:print, String.t() | byte()}
  | {:set_cursor, integer(), integer()}
  | {:cursor, boolean()}
  | {:blink, boolean()}
  | {:display, boolean()}
  | {:autoscroll, boolean()}
  | {:text_direction, :right_to_left}
  | {:text_direction, :left_to_right}
  | {:scroll, integer()}
  | {:left, integer()}
  | {:right, integer()}
  | {:backlight, boolean()}
  | {:red, boolean()}
  | {:green, boolean()}
  | {:blue, boolean()}

Type that represents a supported display command. Some driver modules do not support the backlight LED commands.

Supported CommandDescription
:clearClear the display.
:homeMove the cursor home.
:printPrint a character or text at the current cursor.
:set_cursorSet the cursor position (row and column).
:cursorSwitch on/off the underline cursor.
:displaySwitch on/off the display without losing what is on it.
:blinkSwitch on/off the block cursor.
:autoscrollMake existing text shift when new text is printed.
:text_directionMake text flow left/right from the cursor.
:scrollScroll text left and right.
:leftMove the cursor left.
:rightMove the cursor right.
:backlightSwitch on/off the backlight.
:redSwitch on/off the red LED.
:greenSwitch on/off the green LED.
:blueSwitch on/off the blue LED.

config()

@type config() :: map()

feature()

@type feature() :: :entry_mode | :display_control

Type that represents an available display feature.

num_cols()

@type num_cols() :: 8..20

num_rows()

@type num_rows() :: 1..4

t()

@type t() :: %{
  :driver_module => atom(),
  :rows => num_rows(),
  :cols => num_cols(),
  :entry_mode => byte(),
  :display_control => byte(),
  :backlight => boolean(),
  required(atom()) => any()
}

Type that represents the display state.

Callbacks

execute(t, command)

@callback execute(t(), command()) :: {:ok, t()} | {:error, any()}

Executes the specified command and returns a new display state.

start(config)

@callback start(config()) :: {:ok, t()} | {:error, any()}

Initializes the LCD driver and returns the initial display state.

write_data(t, byte)

@callback write_data(t(), byte()) :: t()

Sends a data byte to the display.

write_instruction(t, byte)

@callback write_instruction(t(), byte()) :: t()

Sends an instruction byte to the display.

Functions

__using__(_)

(macro)

Injects the common logic for an LCD driver. For display flags, please refer to HD44780 data sheet.

Examples

use LcdDisplay.HD44780.Driver