Dotmatrix LCD Library. More...
#include <avr/io.h>
#include <stdio.h>
Go to the source code of this file.
Defines | |
#define | INPUT_BUFFER_SIZE 60 |
size of the input buffer used when scrolling is enabled | |
#define | LCD_D_PORT PORTC |
Port for Data Lines DB4-DB7 = Px0-Px3. | |
#define | LCD_E_PORT PORTD |
Port for Control Line E. | |
#define | LCD_RS_PORT PORTD |
Port for Control Line RS. | |
#define | LCD_RW_PORT PORTD |
Port for Control Line RW. | |
#define | LCD_DATAMSK 0x0f |
Mask of the Data Pins. | |
#define | LCD_RS 4 |
Register Set Pin Bitposition. | |
#define | LCD_E 2 |
LCD Enable Pin Bitposition. | |
#define | LCD_RW 3 |
Read / Write Pin Bitposition. | |
#define | LCD_TYPE 3 |
#define | ks0073 |
if the controller is a KS0073 the addresses of the LDC-Rows are slightly different | |
#define | ENTRY_MODE 0b00000100 |
#define | DISPLAY_STATUS 0b00001100 |
#define | FUNCTION_SET 0b00101000 |
#define | FUNCTION_SET_RE 0b00100100 |
#define | EXT_FUNCTION_SET 0b00001001 |
#define | LCD_CMD_CLEAR 0x01 |
LCD Command: Clear Screen. | |
#define | LCD_CMD_HOME 0x02 |
LCD Command: move cursor to upper left corner. | |
#define | LCD_CMD_MOVE_RIGHT 0x14 |
LCD Command: move cursor richt by one position. | |
#define | LCD_CMD_MOVE_LEFT 0x10 |
LCD Command: move cursor left by one position. | |
#define | LCD_CMD_SHIFT_RIGHT 0x1C |
LCD Command: shift right. | |
#define | LCD_CMD_SHIFT_LEFT 0x18 |
LCD Command: shift left. | |
#define | LCD_CMD_DISPLAY_OFF 0x08 |
LCD Command: Display off. | |
#define | LCD_CMD_DISPLAY_ON 0x0C |
LCD Command: Display on (CUESOR and BLINK is OFF) | |
#define | LCD_CMD_CURSOR_ON 0x0E |
LCD Command: Cursor on. | |
#define | LCD_CMD_BLINK_ON 0x0D |
LCD Command: Blink on. | |
#define | lcd_home() lcd_command(LCD_CMD_HOME); |
move the Cursor to to the upper left corner of the screen. | |
#define | lcd_clear() lcd_command(LCD_CMD_CLEAR); |
sends the command clear the display | |
#define | LCD_D_DDR (LCD_D_PORT-1) |
#define | LCD_D_PIN (LCD_D_PORT-2) |
#define | LCD_E_DDR (LCD_E_PORT-1) |
#define | LCD_RS_DDR (LCD_RS_PORT-1) |
#define | LCD_RW_DDR (LCD_RW_PORT-1) |
#define | LCD_ROWS 4 |
#define | LCD_COLS 20 |
#define | LCD_LINE1 0x00 |
#define | LCD_LINE2 0x20 |
#define | LCD_LINE3 0x40 |
#define | LCD_LINE4 0x60 |
Functions | |
void | lcd_data (uint8_t data) |
send one data byte | |
void | lcd_command (uint8_t cmd) |
send a command byte | |
void | lcd_setadr (uint8_t adr) |
set a specific display address | |
void | lcd_puts (char const *c) |
write a string | |
void | lcd_puts_P (char const *) |
write a string from flash | |
void | lcd_init (void) |
initialise the display | |
uint8_t | lcd_readadr (void) |
read the position of the cursor | |
int | lcd_putchar (char data, FILE *sream) |
Write one Character on the Display. | |
void | print_buffer (void) |
send the buffer contents to the display | |
void | lcd_scroll (void) |
scroll individual lines |
Dotmatrix LCD Library.
Definition in file lcd.h.
#define LCD_TYPE 3 |
void lcd_command | ( | uint8_t | cmd ) |
send a command byte
cmd | Command to send |
void lcd_data | ( | uint8_t | data ) |
send one data byte
data | Byte to send |
void lcd_init | ( | void | ) |
initialise the display
executes the initialisation sequence defined by the HD44780 datasheet
int lcd_putchar | ( | char | data, |
FILE * | sream | ||
) |
Write one Character on the Display.
Characters received are transformer by a lookup-table because the charset of the Display is not equal to ASCII. As input to this function any ASCII character that can be typed ba a German or American Keyboard is valid and displayed correctly on the screen.
As the Display has some amazing special characters, like fancy arrows, there are some sequences that are parsed and replaced by the corresponding symbol. See https://wiki.fs-et.de/student-lab/UartDisplay for details on the parser.
data | ASCII Character to print. |
stream | (is necessary to be compatible with printf) |
Definition at line 181 of file lcd.c.
void lcd_puts | ( | char const * | c ) |
write a string
writes a sequence of characters until the first zero-byte.
c | Pointer to a terminated string |
void lcd_puts_P | ( | char const * | ) |
write a string from flash
same as lcd_puts expect that the string is located in flash memory.
c | Pointer to a terminated string |
uint8_t lcd_readadr | ( | void | ) |
read the position of the cursor
void lcd_scroll | ( | void | ) |
scroll individual lines
This function should be called by the main loop regularly if scroll mode is activated. Each time this function is executed the content of a line longer than the physical display lentgh is rotated by one position.
Definition at line 128 of file lcd.c.
void lcd_setadr | ( | uint8_t | adr ) |
set a specific display address
Moves the cursor to a specific address, so the next character sent will be displayed at this position. To get the address of a certain position use the offset of the line (LCD_LINE[1..4]) and add the desired column.
adr | Address |
void print_buffer | ( | void | ) |