This library is focused on providing a fast and simple way of communicating with the HD44780 controller while also providing low-level functionality to allow more control over the controller.
You can control data rate by redefining LCD_DELAY
macro (default is 100)
AVR devices
- Only supports 4-bit interface
- Doesn't support reading from display memory
- All pins have to be connected within a single port (PORTB, PORTD, etc..)
Warning: All pins have to be connected within a single port!
Create instance of PinConfig
struct:
PinConfig config = {.ddr = &DDRD, .port = &PORTD, .d0 = 16, .d1 = 32, .d2 = 64, .d3 = 128, .rs = 4, .en = 8};
Values in PinConfig
struct:
Assigned values must be corresponding to values of individual bits in port register:
Call the LCD_init(PinConfig*)
function with arguments:
- pointer to an instance of the
PinConfig
struct
LCD_init(&config);
Warning:
If you change values in config
you will also need to reinitialize the display
Display is off by default, to turn it on call LCD_on()
function:
LCD_on();
You can prit individual characters with LCD_write_char()
:
LCD_write_char('H');
LCD_write_char('e');
LCD_write_char('l');
LCD_write_char('l');
LCD_write_char('o');
LCD_write_char(' ');
LCD_write_char('w');
LCD_write_char('o');
LCD_write_char('r');
LCD_write_char('l');
LCD_write_char('d');
LCD_write_char('!');
To clear the display use LCD_clear()
:
LCD_clear();
To write string use LCD_write_string(char*)
with arguments:
- pointer to the string
char greetings[] = "Hello world!";
LCD_write_string(&greetings[0]);
-
Description:
Initializes the HD44780 interface
-
Arguments:
1. Pointer to instance of PinConfig struct
-
Return value:
int
:0 if success 1 if pin verification failed (some values specified in provided config are the same or 0)
-
Description:
Sends instruction to the display (list of instruction can be found in the datasheet on page 24)
-
Arguments:
1. Instruction
-
Return value:
void
:none
-
Description:
Writes one character to the display
-
Arguments:
1. ASCII character
-
Return value:
void
:none
-
Description:
Clears the display
-
Arguments:
none
-
Return value:
void
:none
-
Description:
Sets the cursor position
-
Arguments:
1. row (0 or 1) 2. collumn (0 to 40)
-
Return value:
void
:none
-
Description:
Writes string of characters to the display
-
Arguments:
1. pointer to the string
-
Return value:
void
:none
-
Description:
Writes buffer to the display
-
Arguments:
1. pointer to the buffer 2. length of the buffer
-
Return value:
void
:none
-
Description:
Pulses the EN pin of the display 1. pulls the pin HIGH 2. waits specified amount of microseconds (LCD_DELAY in HD44780/HD44780.h) 3. pulls the pin LOW again
-
Arguments:
none
-
Return value:
void
:none
-
Description:
Calls LCD_pulse_en() specified amount of times
-
Arguments:
1. amount of times to repeat
-
Return value:
void
:none
-
Description:
Turns on cursor on the display
-
Arguments:
none
-
Return value:
void
:none
-
Description:
Turns off cursor on the display
-
Arguments:
none
-
Return value:
void
:none
-
Description:
Turns on the display
-
Arguments:
none
-
Return value:
void
:none
-
Description:
Turns off the display
-
Arguments:
none
-
Return value:
void
:none
-
Description:
Turns cursor blink on
-
Arguments:
none
-
Return value:
void
:none
-
Description:
Turns cursor blink off
-
Arguments:
none
-
Return value:
void
:none
-
Description:
Sets cursor to the home position (0, 0)
-
Arguments:
none
-
Return value:
void
:none