Main Page | File List | Globals | Related Pages

c/hd44780.h File Reference

This file provides methods to control a HD44780 based 5x7 point lc display. More...

#include <avr/pgmspace.h>

Go to the source code of this file.

Defines

#define HD44780_PORT   PORTB
 The data port the display is attached to.
#define HD44780_DDR   DDRB
 The data direction register of the display port.
#define HD44780_PIN   PINB
 The input register of the display port.
#define HD44780_BIT_ENABLE   5
 The port bit to use for the enable signal.
#define HD44780_BIT_RW   6
 The port bit to use for the r/w signal.
#define HD44780_BIT_RS   7
 The port bit to use for the rs (register select) signal.
#define HD44780_DATA   sbi(HD44780_PORT, HD44780_BIT_RS);
 This macro sets the display to data mode.
#define HD44780_INSTR   cbi(HD44780_PORT, HD44780_BIT_RS);
 Set the display to instruction mode.
#define HD44780_FIRST_ROW   0x80
 Command to position the cursor in the first line.
#define HD44780_SECOND_ROW   0xc0
 As HD44780_FIRST_ROW but positions the cursor in the second row.
#define HD44780_CMD_CLEAR   0x01
 Command to clear the display contents.

Functions

void hd44780_init (void)
 Initialize the electrical interface to the display.
void hd44780_putchar (char c)
 Send one byte to the display.
char hd44780_getchar (void)
 Read a character from the display.
void hd44780_reset (void)
 Reset the display.
void hd44780_put_pgm_str (PGM_P data)
 Print a string out of program memory on the display.
void hd44780_put_str (char *data)
 Print a string out of ram on the display.


Detailed Description

This file provides methods to control a HD44780 based 5x7 point lc display.

The display is used in 4 bit mode. The port the display is attached to can be defined in this file. The default electrical setup is as follows:

function | rs | rw | e | - | d7 | d6 | d5 | d4
bit      | 7  | 6  | 5 | 4 |  3 | 2  | 1  | 0

As you can see bit 4 of the port is not used, so is is also possible to used a seven bit wide port, e.g. PORTA on AT90S2313.


Define Documentation

#define HD44780_DATA   sbi(HD44780_PORT, HD44780_BIT_RS);
 

This macro sets the display to data mode.

After calling this macro all data written to the display is written to the data memory i.e. is displayed.

#define HD44780_FIRST_ROW   0x80
 

Command to position the cursor in the first line.

Add the number of characters the cursor should be moved to the right inside this line but not more than the line length

#define HD44780_INSTR   cbi(HD44780_PORT, HD44780_BIT_RS);
 

Set the display to instruction mode.

After calling this macro you can send commands to the display, e.g. for clearing the display, position the cursor, etc.


Function Documentation

char hd44780_getchar void   ) 
 

Read a character from the display.

Use HD44780_INSTR or HD44780_DATA before calling.

void hd44780_init void   ) 
 

Initialize the electrical interface to the display.

This method should be called once before the display is used the first time

void hd44780_put_pgm_str PGM_P  data  ) 
 

Print a string out of program memory on the display.

The display is set to data mode (as HD44780_DATA does) automatically.

Parameters:
data The address (in program memory) of the string to display

void hd44780_put_str char *  data  ) 
 

Print a string out of ram on the display.

The display is set to data mode (as HD44780_DATA does) automatically.

Parameters:
data The address of a string in memory (ram) to display

void hd44780_putchar char  c  ) 
 

Send one byte to the display.

Calling HD44780_DATA or HD44780_INSTR before calling this method determines if the data is written as data to display or as a command to execute.

Parameters:
c The byte to send to the display

void hd44780_reset void   ) 
 

Reset the display.

The display gets cleared, is set two 5x7 pixel mode, 2 lines, etc. This should be called directly after hd44780_init().


Generated on Wed Oct 27 10:57:05 2004 by  doxygen 1.3.9.1