SLS AVR Lib 0.1a
 
Loading...
Searching...
No Matches
lcd_hd44780_pin.h File Reference

The dot-matrix liquid crystal display lib for HD44780 compatible controller, connected by 6, 7, 10 or 11 pins. More...

#include <stdbool.h>
#include <stdint.h>
#include <sls-avr/avr.h>
#include <sls-lcd/dm_hd44780.h>

Go to the source code of this file.

Data Structures

struct  lcd_init_t
 Initialization information. More...
 

Macros

#define LCD_HD44780_PIN_SINGLE_SOME_CODE   0
 This allows for the same code to be achieved with the macro LCD_HD44780_PIN_MULTI_MODE on and off.
 
#define LCD_HD44780_PIN_MULTI_MODE   0
 Multidisplay display mode.
 
#define LCD_HD44780_PIN_DISPLAY_TYPE
 Display type.
 
#define HD44780_INIT_IDL_4BIT   0x00
 Initialization with 4-bit interface data length. Ignored for single display mode.
 
#define HD44780_INIT_IDL_8BIT   (_BV(__HD44780_INIT_IDL_BIT))
 Initialization with 8-bit interface data length. Ignored for single display mode.
 
#define HD44780_INIT_READ_OFF   0x00
 Initialization without controller read support. Ignored for single display mode.
 
#define HD44780_INIT_READ_ON   (_BV(__HD44780_INIT_READ_BIT))
 Initialization with controller read support. Ignored for single display mode.
 
#define HD44780_INIT_MOV_DIR_DEC   0x00
 Initialization with cursor moving direction decrement.
 
#define HD44780_INIT_MOV_DIR_INC   (_BV(__HD44780_INIT_MOV_DIR_BIT))
 Initialization with cursor moving direction increment.
 
#define HD44780_INIT_SHIFT_OFF   0x00
 Initialization with shift disabled.
 
#define HD44780_INIT_SHIFT_ON   (_BV(__HD44780_INIT_SHIFT_BIT))
 Initialization with shift enabled.
 
#define HD44780_INIT_BLINKING_OFF   0x00
 Initialization with the blinking off.
 
#define HD44780_INIT_BLINKING_ON   (_BV(__HD44780_INIT_BLINKING_BIT))
 Initialization with the blinking on.
 
#define HD44780_INIT_CURSOR_OFF   0x00
 Initialization with the cursor off.
 
#define HD44780_INIT_CURSOR_ON   (_BV(__HD44780_INIT_CURSOR_BIT))
 Initialization with the cursor on.
 
#define HD44780_INIT_FONT_NORMAL   0x00
 Initialization with normal(5x8) font.
 
#define HD44780_INIT_FONT_BIG   (_BV(__HD44780_INIT_FONT_BIT))
 Initialization with the big font.
 
#define HD44780_INIT_DISP_OFF   0x00
 Initialization with the display off.
 
#define HD44780_INIT_DISP_ON   (_BV(__HD44780_INIT_DISP_BIT))
 Initialization with the display on.
 

Typedefs

typedef volatile lcd_info_struct lcd_info_t
 Information to distinguish a specific display from several connected ones.
 

Functions

lcd_info_t lcd_init (const lcd_init_t *const config)
 Initializes the display.
 
void lcd_clear (const lcd_info_t *const info)
 Clears the display.
 
void lcd_home (const lcd_info_t *const info, const uint8_t flags)
 Sets DDRAM address 0 in a ddress counter.
 
void lcd_entry_mode (const lcd_info_t *const info, const uint8_t flags)
 Sets cursor move direction and specifies display shift.
 
void lcd_display_ctrl (const lcd_info_t *const info, const uint8_t flags)
 Sets diplay options.
 
void lcd_cursor (const lcd_info_t *const info, const uint8_t flags)
 Moves the cursor or shifts the display.
 
void lcd_func_set (const lcd_info_t *const info, const uint8_t flags)
 Sets options.
 
void lcd_cgr_adr (const lcd_info_t *const info, const uint8_t flags)
 Sets CGRAM address.
 
void lcd_ddr_adr (const lcd_info_t *const info, const uint8_t flags)
 Sets DDRAM address.
 
void lcd_set_pos (const lcd_info_t *const info, const lcd_line_t line, const uint8_t pos)
 Sets DDRAM address to a given position.
 
void lcd_byte (const lcd_info_t *const info, const byte_t ch)
 Outputs a symbol.
 
void lcd_line (const lcd_info_t *const info, const char str[], const lcd_line_t line, const uint8_t start_pos)
 Outputs a string on entry line.
 
void lcd_print (const lcd_info_t *const info, const char str[])
 Outputs a string to buffer.
 
void lcd_refresh_ml (const lcd_info_t *const info, const char str[])
 Outputs a string on all lines.
 
void lcd_custom_char (const lcd_info_t *const info, const byte_t char_pos, const byte_t custom_char[8])
 Creates a custom symbol.
 
byte_t lcd_read_busy_and_addr (const lcd_info_t *const info)
 Waits until display is buisy and returns address counter contents.
 
byte_t lcd_read_data (const lcd_info_t *const info)
 Reads data from CGRAM or from DDRAM.
 
void lcd_clear (void)
 Clears the display.
 
void lcd_home (const uint8_t flags)
 Sets DDRAM address 0 in a ddress counter.
 
void lcd_entry_mode (const uint8_t flags)
 Sets cursor move direction and specifies display shift.
 
void lcd_display_ctrl (const uint8_t flags)
 Sets diplay options.
 
void lcd_cursor (const uint8_t flags)
 Moves the cursor or shifts the display.
 
void lcd_func_set (const uint8_t flags)
 Sets options.
 
void lcd_cgr_adr (const uint8_t flags)
 Sets CGRAM address.
 
void lcd_ddr_adr (const uint8_t flags)
 Sets DDRAM address.
 
void lcd_set_pos (const lcd_line_t line, const uint8_t pos)
 Sets DDRAM address to a given position.
 
void lcd_byte (const byte_t ch)
 Outputs a symbol.
 
void lcd_line (const char str[], const lcd_line_t line, const uint8_t start_pos)
 Outputs a string on entry line.
 
void lcd_print (const char str[])
 Outputs a string to buffer.
 
void lcd_refresh_ml (const char str[])
 Outputs a string on all lines.
 
byte_t lcd_read_busy_and_addr ()
 Waits until display is buisy and returns address counter contents.
 
byte_t lcd_read_data ()
 Reads data from CGRAM or from DDRAM.
 

Detailed Description

The dot-matrix liquid crystal display lib for HD44780 compatible controller, connected by 6, 7, 10 or 11 pins.

Author
Simon Litt simon.nosp@m.@1it.nosp@m.t.net https://coding.1itt.net, https://github.com/SimonLitt

For a 4-bit interface, the data bus connection pins should be connected in series; for an 8-bit interface, the data bus should occupy the entire port. The remaining 2 or 3 pins can be selected separately.

The dot-matrix liquid crystal display lib for HD44780 compatible controller, connected by 6,...

Macro Definition Documentation

◆ HD44780_INIT_BLINKING_OFF

#define HD44780_INIT_BLINKING_OFF   0x00

Initialization with the blinking off.

◆ HD44780_INIT_BLINKING_ON

#define HD44780_INIT_BLINKING_ON   (_BV(__HD44780_INIT_BLINKING_BIT))

Initialization with the blinking on.

◆ HD44780_INIT_CURSOR_OFF

#define HD44780_INIT_CURSOR_OFF   0x00

Initialization with the cursor off.

◆ HD44780_INIT_CURSOR_ON

#define HD44780_INIT_CURSOR_ON   (_BV(__HD44780_INIT_CURSOR_BIT))

Initialization with the cursor on.

◆ HD44780_INIT_DISP_OFF

#define HD44780_INIT_DISP_OFF   0x00

Initialization with the display off.

◆ HD44780_INIT_DISP_ON

#define HD44780_INIT_DISP_ON   (_BV(__HD44780_INIT_DISP_BIT))

Initialization with the display on.

◆ HD44780_INIT_FONT_BIG

#define HD44780_INIT_FONT_BIG   (_BV(__HD44780_INIT_FONT_BIT))

Initialization with the big font.

◆ HD44780_INIT_FONT_NORMAL

#define HD44780_INIT_FONT_NORMAL   0x00

Initialization with normal(5x8) font.

◆ HD44780_INIT_IDL_4BIT

#define HD44780_INIT_IDL_4BIT   0x00

Initialization with 4-bit interface data length. Ignored for single display mode.

◆ HD44780_INIT_IDL_8BIT

#define HD44780_INIT_IDL_8BIT   (_BV(__HD44780_INIT_IDL_BIT))

Initialization with 8-bit interface data length. Ignored for single display mode.

◆ HD44780_INIT_MOV_DIR_DEC

#define HD44780_INIT_MOV_DIR_DEC   0x00

Initialization with cursor moving direction decrement.

◆ HD44780_INIT_MOV_DIR_INC

#define HD44780_INIT_MOV_DIR_INC   (_BV(__HD44780_INIT_MOV_DIR_BIT))

Initialization with cursor moving direction increment.

◆ HD44780_INIT_READ_OFF

#define HD44780_INIT_READ_OFF   0x00

Initialization without controller read support. Ignored for single display mode.

◆ HD44780_INIT_READ_ON

#define HD44780_INIT_READ_ON   (_BV(__HD44780_INIT_READ_BIT))

Initialization with controller read support. Ignored for single display mode.

◆ HD44780_INIT_SHIFT_OFF

#define HD44780_INIT_SHIFT_OFF   0x00

Initialization with shift disabled.

◆ HD44780_INIT_SHIFT_ON

#define HD44780_INIT_SHIFT_ON   (_BV(__HD44780_INIT_SHIFT_BIT))

Initialization with shift enabled.

◆ LCD_HD44780_PIN_DISPLAY_TYPE

◆ LCD_HD44780_PIN_MULTI_MODE

#define LCD_HD44780_PIN_MULTI_MODE   0

Multidisplay display mode.

◆ LCD_HD44780_PIN_SINGLE_SOME_CODE

#define LCD_HD44780_PIN_SINGLE_SOME_CODE   0

This allows for the same code to be achieved with the macro LCD_HD44780_PIN_MULTI_MODE on and off.

Typedef Documentation

◆ lcd_info_t

typedef volatile lcd_info_struct lcd_info_t

Information to distinguish a specific display from several connected ones.

This parameter is set during LCD initialization and should not be changed manually later.

Function Documentation

◆ lcd_byte() [1/2]

void lcd_byte ( const byte_t ch)

Outputs a symbol.

Parameters
chSymbol code

◆ lcd_byte() [2/2]

void lcd_byte ( const lcd_info_t *const info,
const byte_t ch )

Outputs a symbol.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
chSymbol code

◆ lcd_cgr_adr() [1/2]

void lcd_cgr_adr ( const lcd_info_t *const info,
const uint8_t flags )

Sets CGRAM address.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
flagsCGRAM address

◆ lcd_cgr_adr() [2/2]

void lcd_cgr_adr ( const uint8_t flags)

Sets CGRAM address.

Parameters
flagsCGRAM address

◆ lcd_clear() [1/2]

void lcd_clear ( const lcd_info_t *const info)

Clears the display.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.

◆ lcd_clear() [2/2]

void lcd_clear ( void )

Clears the display.

◆ lcd_cursor() [1/2]

void lcd_cursor ( const lcd_info_t *const info,
const uint8_t flags )

Moves the cursor or shifts the display.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
flagsOptions flags

◆ lcd_cursor() [2/2]

void lcd_cursor ( const uint8_t flags)

Moves the cursor or shifts the display.

Parameters
flagsOptions flags

◆ lcd_custom_char()

void lcd_custom_char ( const lcd_info_t *const info,
const byte_t char_pos,
const byte_t custom_char[8] )

Creates a custom symbol.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
char_posChar position 0-7.
custom_char8-byte array with symbol information.
infolcd_info_t reference.
Remarks
Once executed, no output will be possible until the DDRAM address is set. The DDRAM address can be set using the following methods: lcd_ddr_adr(), lcd_set_pos() and lcd_clear().

◆ lcd_ddr_adr() [1/2]

void lcd_ddr_adr ( const lcd_info_t *const info,
const uint8_t flags )

Sets DDRAM address.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
flagsDDRAM address

◆ lcd_ddr_adr() [2/2]

void lcd_ddr_adr ( const uint8_t flags)

Sets DDRAM address.

Parameters
flagsDDRAM address

◆ lcd_display_ctrl() [1/2]

void lcd_display_ctrl ( const lcd_info_t *const info,
const uint8_t flags )

Sets diplay options.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
flagsOptions flags

◆ lcd_display_ctrl() [2/2]

void lcd_display_ctrl ( const uint8_t flags)

Sets diplay options.

Parameters
flagsOptions flags

◆ lcd_entry_mode() [1/2]

void lcd_entry_mode ( const lcd_info_t *const info,
const uint8_t flags )

Sets cursor move direction and specifies display shift.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
flagsOptions flags

◆ lcd_entry_mode() [2/2]

void lcd_entry_mode ( const uint8_t flags)

Sets cursor move direction and specifies display shift.

Parameters
flagsOptions flags

◆ lcd_func_set() [1/2]

void lcd_func_set ( const lcd_info_t *const info,
const uint8_t flags )

Sets options.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
flagsOptions flags

◆ lcd_func_set() [2/2]

void lcd_func_set ( const uint8_t flags)

Sets options.

Parameters
flagsOptions flags

◆ lcd_home() [1/2]

void lcd_home ( const lcd_info_t *const info,
const uint8_t flags )

Sets DDRAM address 0 in a ddress counter.

◆ lcd_home() [2/2]

void lcd_home ( const uint8_t flags)

Sets DDRAM address 0 in a ddress counter.

Parameters
flagsOptions flags

◆ lcd_init()

void lcd_init ( const lcd_init_t *const config)

Initializes the display.

lcd_info_t lcd_init(const lcd_init_t *const config)

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
configlcd_init_t structure
Returns
lcd_info_t structure. Should be used for further access to the same display.

void lcd_init(const lcd_init_t *const config)

Parameters
configlcd_init_t structure

◆ lcd_line() [1/2]

void lcd_line ( const char str[],
const lcd_line_t line,
const uint8_t start_pos )

Outputs a string on entry line.

Parameters
strA string
lineDisplay row
start_posStarts with the display column

◆ lcd_line() [2/2]

void lcd_line ( const lcd_info_t *const info,
const char str[],
const lcd_line_t line,
const uint8_t start_pos )

Outputs a string on entry line.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
strA string
lineDisplay row
start_posStarts with the display column

◆ lcd_print() [1/2]

void lcd_print ( const char str[])

Outputs a string to buffer.

No line overflow control. The CR character will be skipped.

Parameters
strA string

◆ lcd_print() [2/2]

void lcd_print ( const lcd_info_t *const info,
const char str[] )

Outputs a string to buffer.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

No line overflow control. The CR character will be skipped.

Parameters
infolcd_info_t reference.
strA string

◆ lcd_read_busy_and_addr() [1/2]

byte_t lcd_read_busy_and_addr ( )

Waits until display is buisy and returns address counter contents.

Returns
Address counter contents.

◆ lcd_read_busy_and_addr() [2/2]

byte_t lcd_read_busy_and_addr ( const lcd_info_t *const info)

Waits until display is buisy and returns address counter contents.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
Returns
Address counter contents.

◆ lcd_read_data() [1/2]

byte_t lcd_read_data ( )

Reads data from CGRAM or from DDRAM.

Returns
Readed byte

◆ lcd_read_data() [2/2]

byte_t lcd_read_data ( const lcd_info_t *const info)

Reads data from CGRAM or from DDRAM.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
Returns
Readed byte

◆ lcd_refresh_ml() [1/2]

void lcd_refresh_ml ( const char str[])

Outputs a string on all lines.

Parameters
strA string

◆ lcd_refresh_ml() [2/2]

void lcd_refresh_ml ( const lcd_info_t *const info,
const char str[] )

Outputs a string on all lines.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
strA string

◆ lcd_set_pos() [1/2]

void lcd_set_pos ( const lcd_info_t *const info,
const lcd_line_t line,
const uint8_t pos )

Sets DDRAM address to a given position.

Multidisplay or some code modes only. See LCD_HD44780_PIN_MULTI_MODE , LCD_HD44780_PIN_SINGLE_SOME_CODE

Parameters
infolcd_info_t reference.
lineDisplay row
posDisplay column

◆ lcd_set_pos() [2/2]

void lcd_set_pos ( const lcd_line_t line,
const uint8_t pos )

Sets DDRAM address to a given position.

Parameters
lineDisplay row
posDisplay column