?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{FILE START}

library

?curdirlinks? - Rev 6

?prevdifflink? - Blame - ?getfile?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Procyon AVRlib: lcd.h Source File</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.2 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>lcd.h</h1><a href="lcd_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file lcd.h \brief Character LCD driver for HD44780/SED1278 displays. */</span>
00002 <span class="comment">//*****************************************************************************</span>
00003 <span class="comment">//</span>
00004 <span class="comment">// File Name    : 'lcd.h'</span>
00005 <span class="comment">// Title        : Character LCD driver for HD44780/SED1278 displays</span>
00006 <span class="comment">//                  (usable in mem-mapped, or I/O mode)</span>
00007 <span class="comment">// Author       : Pascal Stang</span>
00008 <span class="comment">// Created      : 11/22/2000</span>
00009 <span class="comment">// Revised      : 4/30/2002</span>
00010 <span class="comment">// Version      : 1.1</span>
00011 <span class="comment">// Target MCU   : Atmel AVR series</span>
00012 <span class="comment">// Editor Tabs  : 4</span>
00013 <span class="comment">//</span><span class="comment"></span>
00014 <span class="comment">/// \ingroup driver_hw</span>
00015 <span class="comment">/// \defgroup lcd Character LCD Driver for HD44780/SED1278-based displays (lcd.c)</span>
00016 <span class="comment">/// \code #include "lcd.h" \endcode</span>
00017 <span class="comment">/// \par Overview</span>
00018 <span class="comment">///     This display driver provides an interface to the most common type of</span>
00019 <span class="comment">/// character LCD, those based on the HD44780 or SED1278 controller chip</span>
00020 <span class="comment">/// (about 90% of character LCDs use one of these chips).  The display driver</span>
00021 <span class="comment">/// can interface to the display through the CPU memory bus, or directly via</span>
00022 <span class="comment">/// I/O port pins.  When using the direct I/O port mode, no additional</span>
00023 <span class="comment">/// interface hardware is needed except for a contrast potentiometer.</span>
00024 <span class="comment">/// Supported functions include initialization, clearing, scrolling, cursor</span>
00025 <span class="comment">/// positioning, text writing, and loading of custom characters or icons</span>
00026 <span class="comment">/// (up to 8).  Although these displays are simple, clever use of the custom</span>
00027 <span class="comment">/// characters can allow you to create animations or simple graphics.  The</span>
00028 <span class="comment">/// "progress bar" function that is included in this driver is an example of</span>
00029 <span class="comment">/// graphics using limited custom-chars.</span>
00030 <span class="comment">///</span>
00031 <span class="comment">/// \Note The driver now supports both 8-bit and 4-bit interface modes.</span>
00032 <span class="comment">///</span>
00033 <span class="comment">/// \Note For full text output functionality, you may wish to use the rprintf</span>
00034 <span class="comment">/// functions along with this driver</span>
00035 <span class="comment"></span><span class="comment">//</span>
00036 <span class="comment">// This code is distributed under the GNU Public License</span>
00037 <span class="comment">//      which can be found at http://www.gnu.org/licenses/gpl.txt</span>
00038 <span class="comment">//</span>
00039 <span class="comment">//*****************************************************************************</span>
00040 
00041 <span class="preprocessor">#ifndef LCD_H</span>
00042 <span class="preprocessor"></span><span class="preprocessor">#define LCD_H</span>
00043 <span class="preprocessor"></span>
00044 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>
00045 
00046 <span class="comment">// include project-dependent configurations</span>
00047 <span class="preprocessor">#include "<a class="code" href="lcdconf_8h.html">lcdconf.h</a>"</span>
00048 
00049 <span class="comment">// if LCD_DELAY is not defined, this definition sequence</span>
00050 <span class="comment">// attempts to find a suitable LCD_DELAY given the F_CPU</span>
00051 <span class="preprocessor">#ifndef LCD_DELAY</span>
00052 <span class="preprocessor"></span><span class="preprocessor">#if F_CPU &gt;= 16000000</span>
00053 <span class="preprocessor"></span><span class="preprocessor">#define LCD_DELAY   asm volatile ("nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n");</span>
00054 <span class="preprocessor"></span><span class="preprocessor">#else</span>
00055 <span class="preprocessor"></span><span class="preprocessor">#if F_CPU &gt;= 12000000</span>
00056 <span class="preprocessor"></span><span class="preprocessor">#define LCD_DELAY   asm volatile ("nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n nop\n");</span>
00057 <span class="preprocessor"></span><span class="preprocessor">#else</span>
00058 <span class="preprocessor"></span><span class="preprocessor">#if F_CPU &gt;= 8000000</span>
00059 <span class="preprocessor"></span><span class="preprocessor">#define LCD_DELAY   asm volatile ("nop\n nop\n nop\n nop\n nop\n nop\n nop\n");</span>
00060 <span class="preprocessor"></span><span class="preprocessor">#else</span>
00061 <span class="preprocessor"></span><span class="preprocessor">#if F_CPU &gt;= 4000000</span>
00062 <span class="preprocessor"></span><span class="preprocessor">#define LCD_DELAY   asm volatile ("nop\n nop\n nop\n nop\n nop\n");</span>
00063 <span class="preprocessor"></span><span class="preprocessor">#else</span>
00064 <span class="preprocessor"></span><span class="preprocessor">#define LCD_DELAY   asm volatile ("nop\n nop\n nop\n");</span>
00065 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00066 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00067 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00068 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00069 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00070 <span class="preprocessor"></span>
00071 <span class="comment">// HD44780 LCD controller command set (do not modify these)</span>
00072 <span class="comment">// writing:</span>
00073 <span class="preprocessor">#define LCD_CLR             0      // DB0: clear display</span>
00074 <span class="preprocessor"></span><span class="preprocessor">#define LCD_HOME            1      // DB1: return to home position</span>
00075 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ENTRY_MODE      2      // DB2: set entry mode</span>
00076 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ENTRY_INC       1      //   DB1: increment</span>
00077 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ENTRY_SHIFT     0      //   DB2: shift</span>
00078 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ON_CTRL         3      // DB3: turn lcd/cursor on</span>
00079 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ON_DISPLAY      2      //   DB2: turn display on</span>
00080 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ON_CURSOR       1      //   DB1: turn cursor on</span>
00081 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ON_BLINK        0      //   DB0: blinking cursor</span>
00082 <span class="preprocessor"></span><span class="preprocessor">#define LCD_MOVE            4      // DB4: move cursor/display</span>
00083 <span class="preprocessor"></span><span class="preprocessor">#define LCD_MOVE_DISP       3      //   DB3: move display (0-&gt; move cursor)</span>
00084 <span class="preprocessor"></span><span class="preprocessor">#define LCD_MOVE_RIGHT      2      //   DB2: move right (0-&gt; left)</span>
00085 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION        5      // DB5: function set</span>
00086 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION_8BIT   4      //   DB4: set 8BIT mode (0-&gt;4BIT mode)</span>
00087 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION_2LINES 3      //   DB3: two lines (0-&gt;one line)</span>
00088 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION_10DOTS 2      //   DB2: 5x10 font (0-&gt;5x7 font)</span>
00089 <span class="preprocessor"></span><span class="preprocessor">#define LCD_CGRAM           6      // DB6: set CG RAM address</span>
00090 <span class="preprocessor"></span><span class="preprocessor">#define LCD_DDRAM           7      // DB7: set DD RAM address</span>
00091 <span class="preprocessor"></span><span class="comment">// reading:</span>
00092 <span class="preprocessor">#define LCD_BUSY            7      // DB7: LCD is busy</span>
00093 <span class="preprocessor"></span>
00094 <span class="comment">// Default LCD setup</span>
00095 <span class="comment">// this default setup is loaded on LCD initialization</span>
00096 <span class="preprocessor">#ifdef LCD_DATA_4BIT</span>
00097 <span class="preprocessor"></span><span class="preprocessor">    #define LCD_FDEF_1          (0&lt;&lt;LCD_FUNCTION_8BIT)</span>
00098 <span class="preprocessor"></span><span class="preprocessor">#else</span>
00099 <span class="preprocessor"></span><span class="preprocessor">    #define LCD_FDEF_1          (1&lt;&lt;LCD_FUNCTION_8BIT)</span>
00100 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00101 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FDEF_2              (1&lt;&lt;LCD_FUNCTION_2LINES)</span>
00102 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION_DEFAULT    ((1&lt;&lt;LCD_FUNCTION) | LCD_FDEF_1 | LCD_FDEF_2)</span>
00103 <span class="preprocessor"></span><span class="preprocessor">#define LCD_MODE_DEFAULT        ((1&lt;&lt;LCD_ENTRY_MODE) | (1&lt;&lt;LCD_ENTRY_INC))</span>
00104 <span class="preprocessor"></span>
00105 <span class="comment">// custom LCD characters</span>
00106 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> __attribute__ ((progmem)) LcdCustomChar[];
00107 #define LCDCHAR_PROGRESS05      0   <span class="comment">// 0/5 full progress block</span>
00108 #define LCDCHAR_PROGRESS15      1   <span class="comment">// 1/5 full progress block</span>
00109 #define LCDCHAR_PROGRESS25      2   <span class="comment">// 2/5 full progress block</span>
00110 #define LCDCHAR_PROGRESS35      3   <span class="comment">// 3/5 full progress block</span>
00111 #define LCDCHAR_PROGRESS45      4   <span class="comment">// 4/5 full progress block</span>
00112 #define LCDCHAR_PROGRESS55      5   <span class="comment">// 5/5 full progress block</span>
00113 #define LCDCHAR_REWINDARROW     6   <span class="comment">// rewind arrow</span>
00114 #define LCDCHAR_STOPBLOCK       7   <span class="comment">// stop block</span>
00115 #define LCDCHAR_PAUSEBARS       8   <span class="comment">// pause bars</span>
00116 #define LCDCHAR_FORWARDARROW    9   <span class="comment">// fast-forward arrow</span>
00117 #define LCDCHAR_SCROLLUPARROW   10  <span class="comment">// scroll up arrow</span>
00118 #define LCDCHAR_SCROLLDNARROW   11  <span class="comment">// scroll down arrow</span>
00119 #define LCDCHAR_BLANK           12  <span class="comment">// scroll down arrow</span>
00120 #define LCDCHAR_ANIPLAYICON0    13  <span class="comment">// animated play icon frame 0</span>
00121 #define LCDCHAR_ANIPLAYICON1    14  <span class="comment">// animated play icon frame 1</span>
00122 #define LCDCHAR_ANIPLAYICON2    15  <span class="comment">// animated play icon frame 2</span>
00123 #define LCDCHAR_ANIPLAYICON3    16  <span class="comment">// animated play icon frame 3</span>
00124 
00125 <span class="comment">// progress bar defines</span>
00126 #define PROGRESSPIXELS_PER_CHAR 6
00127 
00128 
00129 <span class="comment">// ****** Low-level functions ******</span>
00130 <span class="comment">// the following functions are the only ones which deal with the CPU</span>
00131 <span class="comment">// memory or port pins directly.  If you decide to use a fundamentally</span>
00132 <span class="comment">// different hardware interface to your LCD, only these functions need</span>
00133 <span class="comment">// to be changed, after which all the high-level functions will</span>
00134 <span class="comment">// work again.</span>
00135 
00136 <span class="comment">// initializes I/O pins connected to LCD</span>
00137 <span class="keywordtype">void</span> lcdInitHW(<span class="keywordtype">void</span>);
00138 <span class="comment">// waits until LCD is not busy</span>
00139 <span class="keywordtype">void</span> lcdBusyWait(<span class="keywordtype">void</span>);
00140 <span class="comment">// writes a control command to the LCD</span>
00141 <span class="keywordtype">void</span> lcdControlWrite(u08 data);
00142 <span class="comment">// read the control status from the LCD</span>
00143 u08 lcdControlRead(<span class="keywordtype">void</span>);
00144 <span class="comment">// writes a data byte to the LCD screen at the current position</span>
00145 <span class="keywordtype">void</span> lcdDataWrite(u08 data);
00146 <span class="comment">// reads the data byte on the LCD screen at the current position</span>
00147 u08 lcdDataRead(<span class="keywordtype">void</span>);
00148 
00149 
00150 <span class="comment">// ****** High-levlel functions ******</span>
00151 <span class="comment">// these functions provide the high-level control of the LCD</span>
00152 <span class="comment">// such as clearing the display, setting cursor positions,</span>
00153 <span class="comment">// displaying text and special characters</span>
00154 
00155 <span class="comment">// initializes the LCD display (gets it ready for use)</span>
00156 <span class="keywordtype">void</span> lcdInit(<span class="keywordtype">void</span>);
00157 
00158 <span class="comment">// moves the cursor/position to Home (upper left corner)</span>
00159 <span class="keywordtype">void</span> lcdHome(<span class="keywordtype">void</span>);
00160 
00161 <span class="comment">// clears the LCD display</span>
00162 <span class="keywordtype">void</span> lcdClear(<span class="keywordtype">void</span>);
00163 
00164 <span class="comment">// moves the cursor/position to the row,col requested</span>
00165 <span class="comment">// ** this may not be accurate for all displays</span>
00166 <span class="keywordtype">void</span> lcdGotoXY(u08 row, u08 col);
00167 
00168 <span class="comment">// loads a special user-defined character into the LCD</span>
00169 <span class="comment">// &lt;lcdCustomCharArray&gt; is a pointer to a ROM array containing custom characters</span>
00170 <span class="comment">// &lt;romCharNum&gt; is the index of the character to load from lcdCustomCharArray</span>
00171 <span class="comment">// &lt;lcdCharNum&gt; is the RAM location in the LCD (legal value: 0-7)</span>
00172 <span class="keywordtype">void</span> lcdLoadCustomChar(u08* lcdCustomCharArray, u08 romCharNum, u08 lcdCharNum);
00173 
00174 <span class="comment">// prints a series of bytes/characters to the display</span>
00175 <span class="keywordtype">void</span> lcdPrintData(<span class="keywordtype">char</span>* data, u08 nBytes);
00176 
00177 <span class="comment">// displays a horizontal progress bar at the current cursor location</span>
00178 <span class="comment">// &lt;progress&gt; is the value the bargraph should indicate</span>
00179 <span class="comment">// &lt;maxprogress&gt; is the value at the end of the bargraph</span>
00180 <span class="comment">// &lt;length&gt; is the number of LCD characters that the bargraph should cover</span>
00181 <span class="keywordtype">void</span> lcdProgressBar(u16 progress, u16 maxprogress, u08 length);
00182 
00183 #endif
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
</body>
</html>
{FILE END}
{FOOTER START}

Powered by WebSVN v2.8.3