3.5.1. hd44780 — Dot matrix LCD

Source code: src/drivers/displays/hd44780.h, src/drivers/displays/hd44780.c

Example code: examples/drivers/displays/hd44780/main.c


Functions

int hd44780_module_init(void)

Initialize the driver module. This function must be called before calling any other function in this module.

The module will only be initialized once even if this function is called multiple times.

Return
zero(0) or negative error code.

int hd44780_init(struct hd44780_driver_t *self_p, struct pin_device_t *rs_p, struct pin_device_t *enable_p, struct pin_device_t *data_4_p, struct pin_device_t *data_5_p, struct pin_device_t *data_6_p, struct pin_device_t *data_7_p, unsigned int number_of_rows, unsigned int number_of_columns)

Initialize driver object. The driver object will be used for a single display.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to initialize.
  • rs_p: RS pin device.
  • enable_p: RS pin device.
  • data_4_p: Data 4 pin device.
  • data_5_p: Data 5 pin device.
  • data_6_p: Data 6 pin device.
  • data_7_p: Data 7 pin device.
  • number_of_rows: Number of rows.
  • number_of_columns: Number of columns.

int hd44780_start(struct hd44780_driver_t *self_p)

Start the driver.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int hd44780_stop(struct hd44780_driver_t *self_p)

Stop the driver.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int hd44780_display(struct hd44780_driver_t *self_p, const char *text_p)

Display given text on the display.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.
  • text_p: Text to display.

int hd44780_write(struct hd44780_driver_t *self_p, const char *text_p)

Write given text to the display at current cursor position.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.
  • text_p: Text to write to the display.

int hd44780_put(struct hd44780_driver_t *self_p, char character)

Write given character to the display at current cursor position.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.
  • character: Character to write to the display.

int hd44780_clear(struct hd44780_driver_t *self_p)

Clear the display.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int hd44780_cursor_move(struct hd44780_driver_t *self_p, unsigned int row, unsigned int column)

Move the cursor to given row and column, relative to the upper left-hand corner of the screen, which is (0, 0).

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.
  • row: Row to move to.
  • column: Colum to move to.

int hd44780_cursor_show(struct hd44780_driver_t *self_p)

Show the cursor on the display.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int hd44780_cursor_hide(struct hd44780_driver_t *self_p)

Do not show the cursor on the display.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int hd44780_text_show(struct hd44780_driver_t *self_p)

Show the text on the display.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int hd44780_text_hide(struct hd44780_driver_t *self_p)

Do not show the text on the display.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int hd44780_scroll_left(struct hd44780_driver_t *self_p)

Scroll the text on the display one position to the left.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int hd44780_scroll_right(struct hd44780_driver_t *self_p)

Scroll the text on the display one position to the right.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

struct hd44780_driver_t

Public Members

struct pin_device_t *rs_p
struct pin_device_t *enable_p
struct pin_device_t *data_4_p
struct pin_device_t *data_5_p
struct pin_device_t *data_6_p
struct pin_device_t *data_7_p
unsigned int number_of_rows
unsigned int number_of_columns
unsigned int row
unsigned int column
struct hd44780_driver_t::@0 hd44780_driver_t::cursor
uint8_t display_on_off_control