HD44780  0.1.0
Data Structures | Functions
HD44780.h File Reference

HD44780 peripheral library for stm32 microcontrollers. More...

#include <stdbool.h>
#include <stdlib.h>
#include <stm32f1xx_hal.h>

Go to the source code of this file.

Data Structures

struct  HD44780
 HD44780 controller instance. More...
 
struct  HD44780_Config
 HD44780 controller configuration. More...
 

Functions

void HD44780_init (const HD44780 *lcd)
 Initialize the necessary hardware peripherals, then configure the controller itself. More...
 
void HD44780_configure (const HD44780 *lcd, const HD44780_Config *config)
 Update the configuration of the controller. More...
 
void HD44780_clear (const HD44780 *lcd)
 Clear the display and move the cursor to position 0 of the first line. More...
 
void HD44780_return_home (const HD44780 *lcd)
 Reset display shift to the initial position and move the cursor to position 0 of the first line. More...
 
void HD44780_cursor_to (const HD44780 *lcd, uint8_t column, uint8_t row)
 Move the cursor to the desired position. More...
 
void HD44780_shift_display (const HD44780 *lcd, int8_t n)
 Shift the contents of the display right or left by n positions. More...
 
void HD44780_create_symbol (const HD44780 *lcd, uint8_t address, bool font_5x10, const uint8_t symbol[])
 Create a user defined character to display in the LCD. More...
 
void HD44780_put_char (const HD44780 *lcd, uint8_t chr)
 Write a single character to the lcd, then advance the cursor. More...
 
void HD44780_put_str (const HD44780 *lcd, const char *str)
 Write a string to the lcd, then advance the cursor. More...
 

Detailed Description

HD44780 peripheral library for stm32 microcontrollers.

More information is available at the project's home page: https://github.com/murar8/stm32-HD44780

Version
0.1.0
Author
Lorenzo Murarotto lnzmr.nosp@m.r@gm.nosp@m.ail.c.nosp@m.om

Function Documentation

◆ HD44780_clear()

void HD44780_clear ( const HD44780 lcd)

Clear the display and move the cursor to position 0 of the first line.

Parameters
lcdController instance.

◆ HD44780_configure()

void HD44780_configure ( const HD44780 lcd,
const HD44780_Config config 
)

Update the configuration of the controller.

Parameters
lcdController instance.
configNew controller configuration.

◆ HD44780_create_symbol()

void HD44780_create_symbol ( const HD44780 lcd,
uint8_t  address,
bool  font_5x10,
const uint8_t  symbol[] 
)

Create a user defined character to display in the LCD.

The controller memory can store up to 8 5x8 symbols, and up to 4 5x10 symbols. Please take into consideartion that 5x10 symbols needs 2 CGRAM slots, so after defining a 5x10 symbol at address n, next symbol should be defined at address n+2.

Parameters
lcdController instance.
addressASCII code of the new symbol, must be in the range from 0 to 7 inclusive.
font_5x10Wheteher the new symbol will be a 5x10 character.
symbolArray of 5 bit values where each bit will determine whether the corresponding pixel is lit up in its corresponding row.

◆ HD44780_cursor_to()

void HD44780_cursor_to ( const HD44780 lcd,
uint8_t  column,
uint8_t  row 
)

Move the cursor to the desired position.

Parameters
lcdController instance.
columnIndex of the desired cursor position in the line. Must be less than 0x50 in single line mode, and less than 0x28 in two lines mode, or the cursor will wrap to the next line causing undefined behaviour.
rowIndex of the desired row. Must be 0 if the controller is configured for single line mode, and 0 or 1 when the controller is in two lines mode.

◆ HD44780_init()

void HD44780_init ( const HD44780 lcd)

Initialize the necessary hardware peripherals, then configure the controller itself.

The initial configuration will be the same as calling HD44780_configure() with all the config flags set to false.

Parameters
lcdController instance.

◆ HD44780_put_char()

void HD44780_put_char ( const HD44780 lcd,
uint8_t  chr 
)

Write a single character to the lcd, then advance the cursor.

When the character is '\n' the cursor will advance to the next line, wrapping around from last to first. When the character is '\t' 4 spaces will be written to the display.

Parameters
lcdController instance.
chrCharacter to be printed to the lcd.

◆ HD44780_put_str()

void HD44780_put_str ( const HD44780 lcd,
const char *  str 
)

Write a string to the lcd, then advance the cursor.

The same considerations for special characters from HD44780_put_char apply to this function.

Note
The string must be null terminated.
Parameters
lcdController instance.
strString to be printed to the lcd.

◆ HD44780_return_home()

void HD44780_return_home ( const HD44780 lcd)

Reset display shift to the initial position and move the cursor to position 0 of the first line.

Parameters
lcdController instance.

◆ HD44780_shift_display()

void HD44780_shift_display ( const HD44780 lcd,
int8_t  n 
)

Shift the contents of the display right or left by n positions.

Note
The first and second line will shift at the same time.
The execution time of this function will increase linearly with the numbers of positions shifted (~37us / position shifted).
Parameters
lcdController instance.
nNumber of positions to shift. When the value is positive the diplay will shift left to right, when negative the shift operation will advance right to left.