mikroSDK Reference Manual
LCD Driver

Generic liquid crystal display APIs. More...

Modules

 LCD Controller
 Generic liquid crystal display controller specific APIs.
 

Functions list

void lcd_configure_default (lcd_config_t *config)
 Configure LCD configuration structure. More...
 
lcd_err_t lcd_configure (lcd_handle_t *lcd_handle, lcd_config_t *config)
 Configures LCD handle with passed configuration structure. More...
 
void lcd_init (lcd_handle_t lcd_handle, init_sequence_ptr init_sequence)
 Initializes LCD. More...
 
void lcd_write (lcd_handle_t lcd_handle, char lcd_cmd_data, lcd_select_t cmd_or_data)
 Writes data to LCD. More...
 
void lcd_write_text (lcd_handle_t lcd_handle, char *lcd_data, lcd_row_t row)
 Writes text to LCD. More...
 
void lcd_shift_right (lcd_handle_t lcd_handle)
 Shifts data currently on LCD. More...
 
void lcd_shift_left (lcd_handle_t lcd_handle)
 Shifts data currently on LCD. More...
 
void lcd_set_row (lcd_handle_t lcd_handle, lcd_row_t row)
 Sets current active row on LCD. More...
 
void lcd_turn_on (lcd_handle_t lcd_handle)
 Turns LCD ON. More...
 
void lcd_turn_off (lcd_handle_t lcd_handle)
 Turns LCD OFF. More...
 
void lcd_clear (lcd_handle_t lcd_handle)
 Clears LCD. More...
 
void lcd_cursor_move_home (lcd_handle_t lcd_handle)
 Moves cursor to first position. More...
 
void lcd_cursor_move_left (lcd_handle_t lcd_handle)
 Moves cursor position. More...
 
void lcd_cursor_move_right (lcd_handle_t lcd_handle)
 Moves cursor position. More...
 
void lcd_cursor_off (lcd_handle_t lcd_handle)
 Removes cursor. More...
 
void lcd_cursor_on (lcd_handle_t lcd_handle)
 Shows cursor. More...
 
void lcd_backlight_off (lcd_handle_t lcd_handle)
 Turns LCD backlight OFF. More...
 
void lcd_backlight_on (lcd_handle_t lcd_handle)
 Turns LCD backlight ON. More...
 

Detailed Description

Function Documentation

◆ lcd_configure_default()

void lcd_configure_default ( lcd_config_t config)

Configures LCD structure to default initialization values. Take into consideration that this is just structure variable initial values setting. Values need to be redefined by user.

Parameters
[in,out]configLCD driver configuration structure. See lcd_config_t structure definition for detailed explanation.

Default values:

Function Default value
PIN_CS HAL_PIN_NC
PIN_RST HAL_PIN_NC
PIN_BACKLIGHT HAL_PIN_NC
PIN_D0 HAL_PIN_NC
PIN_D1 HAL_PIN_NC
PIN_D2 HAL_PIN_NC
PIN_D3 HAL_PIN_NC
PIN_D4 HAL_PIN_NC
PIN_D5 HAL_PIN_NC
PIN_D6 HAL_PIN_NC
PIN_D7 HAL_PIN_NC
MODE LCD_MODE_BIT_4
WAITBETWEENWRITES 1000
Returns
Nothing.

Example

// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
Note
PIN_BACKLIGHT is not required.

◆ lcd_configure()

lcd_err_t lcd_configure ( lcd_handle_t lcd_handle,
lcd_config_t config 
)

Configures LCD handle to values set in passed configuration structure. Additionaly will initialize all provided pins.

Parameters
[in,out]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
[in]configLCD driver configuration structure. See lcd_config_t structure definition for detailed explanation.
Returns
lcd_err_t. Will return error if some of the pins weren't initialized correctly.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);

◆ lcd_init()

void lcd_init ( lcd_handle_t  lcd_handle,
init_sequence_ptr  init_sequence 
)

Initializes LCD with default values.

Parameters
[in]lcd_handleLCD handle.
[in]init_sequence_ptrPointer to init sequence API. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
Note
init_sequence_ptr can be declared by user as well.

◆ lcd_write()

void lcd_write ( lcd_handle_t  lcd_handle,
char  lcd_cmd_data,
lcd_select_t  cmd_or_data 
)

Writes either commands or data to LCD lines.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
[in]lcd_cmd_dataData or command.
[in]cmd_or_dataSelector for pulse signaling. See lcd_select_t enum definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Write command to set first row as active one.
// Write out character 'A'.

◆ lcd_write_text()

void lcd_write_text ( lcd_handle_t  lcd_handle,
char *  lcd_data,
lcd_row_t  row 
)

Writes array of characters to LCD lines one by one.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
[in]lcd_dataData.
[in]rowSelects row to write to. See lcd_row_t enum definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Write out "Some text" to LCD row 1.
lcd_write_text(lcd, "Some text", LCD_ROW_1);

◆ lcd_shift_right()

void lcd_shift_right ( lcd_handle_t  lcd_handle)

Shifts the data on all rows on LCD one character at a time.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Write out "Some text" to LCD row 1.
lcd_write_text(lcd, "Some text", LCD_ROW_1);
// Move text to the left 7 times.
for(char i=0; i<8; i++) {
Delay_ms(250);
}

◆ lcd_shift_left()

void lcd_shift_left ( lcd_handle_t  lcd_handle)

Shifts the data on all rows on LCD one character at a time.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Write out "Some text" to LCD row 1.
lcd_write_text(lcd, "Some text", LCD_ROW_1);
// Move text to the right 7 times.
for(char i=0; i<8; i++) {
Delay_ms(250);
}

◆ lcd_set_row()

void lcd_set_row ( lcd_handle_t  lcd_handle,
lcd_row_t  row 
)

Sets active row on the LCD where data is to be output.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
[in]rowDesired row. Takes lcd_row_t values.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Write out "Some text" to LCD row 2.
lcd_write_text(lcd, "Some text", LCD_ROW_1);

◆ lcd_turn_on()

void lcd_turn_on ( lcd_handle_t  lcd_handle)
Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Turn LCD ON.

◆ lcd_turn_off()

void lcd_turn_off ( lcd_handle_t  lcd_handle)
Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Turn LCD OFF.

◆ lcd_clear()

void lcd_clear ( lcd_handle_t  lcd_handle)

Clears all characters on LCD.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Clear display.
lcd_clear(lcd);

◆ lcd_cursor_move_home()

void lcd_cursor_move_home ( lcd_handle_t  lcd_handle)

Moves current cursor position back to the home position.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Clear display.

◆ lcd_cursor_move_left()

void lcd_cursor_move_left ( lcd_handle_t  lcd_handle)

Moves current cursor position one column to the left.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Clear display.

◆ lcd_cursor_move_right()

void lcd_cursor_move_right ( lcd_handle_t  lcd_handle)

Moves current cursor position one column to the right.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Clear display.

◆ lcd_cursor_off()

void lcd_cursor_off ( lcd_handle_t  lcd_handle)

Removes cursor from current position on the display.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Clear display.

◆ lcd_cursor_on()

void lcd_cursor_on ( lcd_handle_t  lcd_handle)

Shows current cursor position on the display.

Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Clear display.
Attention
Turns cursor blinking ON for better visibility as well.

◆ lcd_backlight_off()

void lcd_backlight_off ( lcd_handle_t  lcd_handle)
Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Clear display.

◆ lcd_backlight_on()

void lcd_backlight_on ( lcd_handle_t  lcd_handle)
Parameters
[in]lcd_handleLCD handle. See lcd_handle_t structure definition for detailed explanation.
Returns
Nothing.

Example

// LCD handle.
// LCD config structure.
lcd_config_t lcd_cfg;
// Fill structure with default values.
// Set default pins.
LCD_MAP_PINS(lcd_cfg);
// Initialize handle and pins.
lcd_configure(&lcd, &lcd_cfg);
// Initialize LCD.
lcd_init(lcd);
// Clear display.
lcd_configure_default
void lcd_configure_default(lcd_config_t *config)
Configure LCD configuration structure.
lcd_cursor_off
void lcd_cursor_off(lcd_handle_t lcd_handle)
Removes cursor.
hd44780_lcd_init
void hd44780_lcd_init(uint32_t lcd_handle)
Initializes LCD.
lcd_clear
void lcd_clear(lcd_handle_t lcd_handle)
Clears LCD.
LCD_SELECT_CMD
Definition: lcd.h:117
lcd_turn_on
void lcd_turn_on(lcd_handle_t lcd_handle)
Turns LCD ON.
lcd_shift_left
void lcd_shift_left(lcd_handle_t lcd_handle)
Shifts data currently on LCD.
lcd_write_text
void lcd_write_text(lcd_handle_t lcd_handle, char *lcd_data, lcd_row_t row)
Writes text to LCD.
lcd_backlight_on
void lcd_backlight_on(lcd_handle_t lcd_handle)
Turns LCD backlight ON.
lcd_shift_right
void lcd_shift_right(lcd_handle_t lcd_handle)
Shifts data currently on LCD.
lcd_config
Definition: lcd.h:144
lcd_backlight_off
void lcd_backlight_off(lcd_handle_t lcd_handle)
Turns LCD backlight OFF.
LCD_ROW_2
Definition: lcd.h:136
LCD_MAP_PINS
#define LCD_MAP_PINS(lcd_cfg)
Mapping default LCD control and data pins.
Definition: lcd.h:73
lcd_cursor_move_home
void lcd_cursor_move_home(lcd_handle_t lcd_handle)
Moves cursor to first position.
LCD_ROW_1
Definition: lcd.h:135
lcd_write
void lcd_write(lcd_handle_t lcd_handle, char lcd_cmd_data, lcd_select_t cmd_or_data)
Writes data to LCD.
Delay_ms
void Delay_ms(uint32_t time_ms)
Creates a software delay in duration of time_ms milliseconds.
lcd_set_row
void lcd_set_row(lcd_handle_t lcd_handle, lcd_row_t row)
Sets current active row on LCD.
lcd_cursor_on
void lcd_cursor_on(lcd_handle_t lcd_handle)
Shows cursor.
lcd_handle
Definition: lcd.h:189
LCD_SELECT_DATA
Definition: lcd.h:118
lcd_cursor_move_right
void lcd_cursor_move_right(lcd_handle_t lcd_handle)
Moves cursor position.
lcd_cursor_move_left
void lcd_cursor_move_left(lcd_handle_t lcd_handle)
Moves cursor position.
lcd_turn_off
void lcd_turn_off(lcd_handle_t lcd_handle)
Turns LCD OFF.
lcd_init
void lcd_init(lcd_handle_t lcd_handle, init_sequence_ptr init_sequence)
Initializes LCD.
lcd_configure
lcd_err_t lcd_configure(lcd_handle_t *lcd_handle, lcd_config_t *config)
Configures LCD handle with passed configuration structure.