Defines | Functions

# lcd.h File Reference

Dotmatrix LCD Library. More...

`#include <avr/io.h>`
`#include <stdio.h>`
Include dependency graph for lcd.h:
This graph shows which files directly or indirectly include this file:

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

## Detailed Description

Dotmatrix LCD Library.

Authors:
  Dominic Rathje (dominic.rathje@uni-ulm.de)
  Christian Degenhart (christian.degenhart@uni-ulm.de)

Version:
  1.1

Note:
  - Compiler : WinAVR 20100110
  - Supported devices : ATMega8

Definition in file lcd.h.

## Define Documentation

#define LCD_TYPE 3

defines the format of the connected Display 0 = 16*2 1 = 16*4 2 = 40*2 3 = 4*20

Definition at line 34 of file lcd.h.

## Function Documentation

void lcd_command | ( | uint8_t | cmd ) |

send a command byte

Parameters:

  cmd | Command to send

void lcd_data | ( | uint8_t | data ) |

send one data byte

Parameters:

  data | Byte to send

Returns:
  void

void lcd_init | ( | void | ) |

initialise the display

executes the initialisation sequence defined by the HD44780 datasheet

Here is the caller graph for this function:

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.

Parameters:

  data | ASCII Character to print.
  stream | (is necessary to be compatible with printf)

Returns:
  0 on success.

Definition at line 187 of file lcd.c.

Here is the call graph for this function:

void lcd_puts | ( | char const * | c ) |

write a string

writes a sequence of characters until the first zero-byte.

Parameters:

  c | Pointer to a terminated string

Here is the caller graph for this function:

void lcd_puts_P | ( | char const * | ) |

write a string from flash

same as lcd_puts expect that the string is located in flash memory.

See also:
  lcd_puts

Parameters:

  c | Pointer to a terminated string

uint8_t lcd_readadr | ( | void | ) |

read the position of the cursor

Returns:
  current address of the cursor position

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 134 of file lcd.c.

Here is the call graph for this function:

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.

Parameters:

  adr | Address

Here is the caller graph for this function:

void print_buffer | ( | void | ) |

send the buffer contents to the display

prints the contents of the buffer on the screen. This function is called automatically by lcd_putchar when a is received.

Definition at line 78 of file lcd.c.

Here is the call graph for this function:

Here is the caller graph for this function: