Project 5
Character Liquid-Crystal Display
|
Neff Site |
Header file for the LCD1602 module. More...
Go to the source code of this file.
Macros | |
#define | LCD1602_ADDR 0x27 |
#define | LCD1602_ROW_OFFSET 0x40 |
#define | LCD1602_DATA 0x01 |
#define | LCD1602_COMMAND 0x00 |
#define | LCD1602_CLR_E 0x00 |
#define | LCD1602_SET_E 0x04 |
#define | LCD1602_BACKLIGHT_ON 0x08 |
#define | LCD1602_BACKLIGHT_OFF 0x00 |
Functions | |
void | lcd1602_sendCommand (uint8_t cmd) |
Send a command. More... | |
void | lcd1602_sendData (uint8_t byte) |
Send a data byte. More... | |
void | lcd1602_init (void) |
Initialize the display. More... | |
void | lcd1602_displayOn (void) |
Turn the display on. More... | |
void | lcd1602_displayOff (void) |
Turn the display off. More... | |
void | lcd1602_displayClear (void) |
Clear the display. More... | |
void | lcd1602_cursorHome (void) |
Place the cursor at its home position. More... | |
void | lcd1602_cursorSet (uint8_t col, uint8_t row) |
Set cursor to the specified position. More... | |
void | lcd1602_putchar (const char c) |
Print a character at the display. More... | |
void | lcd1602_puts (const char *s) |
Print a string at the display. More... | |
Header file for the LCD1602 module.
This is a library for the LCD1602 monochrome liquid-crystal display. The module has an i2c interface and uses a 4-bit data transfer mode where the upper 4 bits are the data and the lower 4 bits are control bits. Please see page 33 of the HD44780 data sheet for the details of the data transfer.
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
I2C | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
HD7780 | DB7 | DB6 | DB5 | DB4 | BL | E | R/W | RS |
Two 4-bit transfers are necessary to send a byte to the display controller. The control bits have to be set appropriately. Look at the following code example for a possible implementation.
#define LCD1602_ADDR 0x27 |
#define LCD1602_BACKLIGHT_OFF 0x00 |
#define LCD1602_BACKLIGHT_ON 0x08 |
#define LCD1602_CLR_E 0x00 |
#define LCD1602_COMMAND 0x00 |
#define LCD1602_DATA 0x01 |
#define LCD1602_ROW_OFFSET 0x40 |
#define LCD1602_SET_E 0x04 |
void lcd1602_cursorHome | ( | void | ) |
Place the cursor at its home position.
void lcd1602_cursorSet | ( | uint8_t | col, |
uint8_t | row | ||
) |
Set cursor to the specified position.
This routine places the cursor at the specified position. The column and row counting starts with 1.
col | The new column position. |
row | The new row position. |
void lcd1602_displayClear | ( | void | ) |
Clear the display.
Clears the display and sets the cursor to its home position.
void lcd1602_displayOff | ( | void | ) |
Turn the display off.
Turns the display and the background lighting off.
void lcd1602_displayOn | ( | void | ) |
Turn the display on.
Turns the display and the background lighting on.
void lcd1602_init | ( | void | ) |
Initialize the display.
This routine initializes the I2C module and the display controller. Please see page 46 of the HD44780 data sheet for the details.
void lcd1602_putchar | ( | const char | c | ) |
Print a character at the display.
c | The character to be printed. |
void lcd1602_puts | ( | const char * | s | ) |
Print a string at the display.
s | The string to be printed. |
void lcd1602_sendCommand | ( | uint8_t | cmd | ) |
Send a command.
Sends a command to the display controller by an I2C transaction.
cmd | The command to be sent. |
void lcd1602_sendData | ( | uint8_t | byte | ) |
Send a data byte.
Sends a data byte to the display controller by an I2C transaction.
data | The data byte to be sent. |
Contact | Generated by 1.8.13 |