Main Page   Data Structures   File List   Data Fields   Globals  

/lcd.h

Go to the documentation of this file.
00001 /*! \file lcd.h \brief Character LCD driver for HD44780/SED1278 displays. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'lcd.h'
00005 // Title        : Character LCD driver for HD44780/SED1278 displays
00006 //                  (usable in mem-mapped, or I/O mode)
00007 // Author       : Pascal Stang
00008 // Created      : 11/22/2000
00009 // Revised      : 4/30/2002
00010 // Version      : 1.1
00011 // Target MCU   : Atmel AVR series
00012 // Editor Tabs  : 4
00013 //
00014 // This code is distributed under the GNU Public License
00015 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00016 //
00017 //*****************************************************************************
00018 
00019 #ifndef LCD_H
00020 #define LCD_H
00021 
00022 #include "global.h"
00023 
00024 // include project-dependent configurations
00025 #include "lcdconf.h"
00026 
00027 // HD44780 LCD controller command set (do not modify these)
00028 // writing:
00029 #define LCD_CLR             0      // DB0: clear display
00030 #define LCD_HOME            1      // DB1: return to home position
00031 #define LCD_ENTRY_MODE      2      // DB2: set entry mode
00032 #define LCD_ENTRY_INC       1      //   DB1: increment
00033 #define LCD_ENTRY_SHIFT     0      //   DB2: shift
00034 #define LCD_ON_CTRL         3      // DB3: turn lcd/cursor on
00035 #define LCD_ON_DISPLAY      2      //   DB2: turn display on
00036 #define LCD_ON_CURSOR       1      //   DB1: turn cursor on
00037 #define LCD_ON_BLINK        0      //   DB0: blinking cursor
00038 #define LCD_MOVE            4      // DB4: move cursor/display
00039 #define LCD_MOVE_DISP       3      //   DB3: move display (0-> move cursor)
00040 #define LCD_MOVE_RIGHT      2      //   DB2: move right (0-> left)
00041 #define LCD_FUNCTION        5      // DB5: function set
00042 #define LCD_FUNCTION_8BIT   4      //   DB4: set 8BIT mode (0->4BIT mode)
00043 #define LCD_FUNCTION_2LINES 3      //   DB3: two lines (0->one line)
00044 #define LCD_FUNCTION_10DOTS 2      //   DB2: 5x10 font (0->5x7 font)
00045 #define LCD_CGRAM           6      // DB6: set CG RAM address
00046 #define LCD_DDRAM           7      // DB7: set DD RAM address
00047 // reading:
00048 #define LCD_BUSY            7      // DB7: LCD is busy
00049 
00050 // Default LCD setup
00051 // this default setup is loaded on LCD initialization
00052 #ifdef LCD_DATA_4BIT
00053     #define LCD_FDEF_1          (0<<LCD_FUNCTION_8BIT)
00054 #else
00055     #define LCD_FDEF_1          (1<<LCD_FUNCTION_8BIT)
00056 #endif
00057 #define LCD_FDEF_2              (1<<LCD_FUNCTION_2LINES)
00058 #define LCD_FUNCTION_DEFAULT    ((1<<LCD_FUNCTION) | LCD_FDEF_1 | LCD_FDEF_2)
00059 #define LCD_MODE_DEFAULT        ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC))
00060 
00061 // custom LCD characters
00062 #define LCDCHAR_PROGRESS05      0   // 0/5 full progress block
00063 #define LCDCHAR_PROGRESS15      1   // 1/5 full progress block
00064 #define LCDCHAR_PROGRESS25      2   // 2/5 full progress block
00065 #define LCDCHAR_PROGRESS35      3   // 3/5 full progress block
00066 #define LCDCHAR_PROGRESS45      4   // 4/5 full progress block
00067 #define LCDCHAR_PROGRESS55      5   // 5/5 full progress block
00068 #define LCDCHAR_REWINDARROW     6   // rewind arrow
00069 #define LCDCHAR_STOPBLOCK       7   // stop block
00070 #define LCDCHAR_PAUSEBARS       8   // pause bars
00071 #define LCDCHAR_FORWARDARROW    9   // fast-forward arrow
00072 #define LCDCHAR_SCROLLUPARROW   10  // scroll up arrow
00073 #define LCDCHAR_SCROLLDNARROW   11  // scroll down arrow
00074 #define LCDCHAR_BLANK           12  // scroll down arrow
00075 #define LCDCHAR_ANIPLAYICON0    13  // animated play icon frame 0
00076 #define LCDCHAR_ANIPLAYICON1    14  // animated play icon frame 1
00077 #define LCDCHAR_ANIPLAYICON2    15  // animated play icon frame 2
00078 #define LCDCHAR_ANIPLAYICON3    16  // animated play icon frame 3
00079 
00080 // progress bar defines
00081 #define PROGRESSPIXELS_PER_CHAR 6
00082 
00083 
00084 // ****** Low-level functions ******
00085 // the following functions are the only ones which deal with the CPU
00086 // memory or port pins directly.  If you decide to use a fundamentally
00087 // different hardware interface to your LCD, only these functions need
00088 // to be changed, after which all the high-level functions will
00089 // work again.
00090 
00091 // initializes I/O pins connected to LCD
00092 void lcdInitHW(void);
00093 // waits until LCD is not busy
00094 void lcdBusyWait(void);
00095 // writes a control command to the LCD
00096 void lcdControlWrite(u08 data);
00097 // read the control status from the LCD
00098 u08 lcdControlRead(void);
00099 // writes a data byte to the LCD screen at the current position
00100 void lcdDataWrite(u08 data);
00101 // reads the data byte on the LCD screen at the current position
00102 u08 lcdDataRead(void);
00103 
00104 
00105 // ****** High-levlel functions ******
00106 // these functions provide the high-level control of the LCD
00107 // such as clearing the display, setting cursor positions,
00108 // displaying text and special characters
00109 
00110 // initializes the LCD display (gets it ready for use)
00111 void lcdInit(void);
00112 
00113 // moves the cursor/position to Home (upper left corner)
00114 void lcdHome(void);
00115 
00116 // clears the LCD display
00117 void lcdClear(void);
00118 
00119 // moves the cursor/position to the row,col requested
00120 // ** this may not be accurate for all displays
00121 void lcdGotoXY(u08 row, u08 col);
00122 
00123 // loads a special user-defined character into the LCD
00124 // <lcdCustomCharArray> is a pointer to a ROM array containing custom characters
00125 // <romCharNum> is the index of the character to load from lcdCustomCharArray
00126 // <lcdCharNum> is the RAM location in the LCD (legal value: 0-7)
00127 void lcdLoadCustomChar(u08* lcdCustomCharArray, u08 romCharNum, u08 lcdCharNum);
00128 
00129 // prints a series of bytes/characters to the display
00130 void lcdPrintData(char* data, u08 nBytes);
00131 
00132 // displays a horizontal progress bar at the current cursor location
00133 // <progress> is the value the bargraph should indicate
00134 // <maxprogress> is the value at the end of the bargraph
00135 // <length> is the number of LCD characters that the bargraph should cover
00136 void lcdProgressBar(u16 progress, u16 maxprogress, u08 length);
00137 
00138 #endif

Generated on Fri Aug 1 10:42:41 2003 for Procyon AVRlib by doxygen1.2.18