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

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>Procyon AVRlib: lcd.h Source File</title>
4 <link href="dox.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.4.2 -->
7 <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>
8 <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>
9 00002 <span class="comment">//*****************************************************************************</span>
10 00003 <span class="comment">//</span>
11 00004 <span class="comment">// File Name : 'lcd.h'</span>
12 00005 <span class="comment">// Title : Character LCD driver for HD44780/SED1278 displays</span>
13 00006 <span class="comment">// (usable in mem-mapped, or I/O mode)</span>
14 00007 <span class="comment">// Author : Pascal Stang</span>
15 00008 <span class="comment">// Created : 11/22/2000</span>
16 00009 <span class="comment">// Revised : 4/30/2002</span>
17 00010 <span class="comment">// Version : 1.1</span>
18 00011 <span class="comment">// Target MCU : Atmel AVR series</span>
19 00012 <span class="comment">// Editor Tabs : 4</span>
20 00013 <span class="comment">//</span><span class="comment"></span>
21 00014 <span class="comment">/// \ingroup driver_hw</span>
22 00015 <span class="comment">/// \defgroup lcd Character LCD Driver for HD44780/SED1278-based displays (lcd.c)</span>
23 00016 <span class="comment">/// \code #include "lcd.h" \endcode</span>
24 00017 <span class="comment">/// \par Overview</span>
25 00018 <span class="comment">/// This display driver provides an interface to the most common type of</span>
26 00019 <span class="comment">/// character LCD, those based on the HD44780 or SED1278 controller chip</span>
27 00020 <span class="comment">/// (about 90% of character LCDs use one of these chips).  The display driver</span>
28 00021 <span class="comment">/// can interface to the display through the CPU memory bus, or directly via</span>
29 00022 <span class="comment">/// I/O port pins.  When using the direct I/O port mode, no additional</span>
30 00023 <span class="comment">/// interface hardware is needed except for a contrast potentiometer.</span>
31 00024 <span class="comment">/// Supported functions include initialization, clearing, scrolling, cursor</span>
32 00025 <span class="comment">/// positioning, text writing, and loading of custom characters or icons</span>
33 00026 <span class="comment">/// (up to 8).  Although these displays are simple, clever use of the custom</span>
34 00027 <span class="comment">/// characters can allow you to create animations or simple graphics.  The</span>
35 00028 <span class="comment">/// "progress bar" function that is included in this driver is an example of</span>
36 00029 <span class="comment">/// graphics using limited custom-chars.</span>
37 00030 <span class="comment">///</span>
38 00031 <span class="comment">/// \Note The driver now supports both 8-bit and 4-bit interface modes.</span>
39 00032 <span class="comment">///</span>
40 00033 <span class="comment">/// \Note For full text output functionality, you may wish to use the rprintf</span>
41 00034 <span class="comment">/// functions along with this driver</span>
42 00035 <span class="comment"></span><span class="comment">//</span>
43 00036 <span class="comment">// This code is distributed under the GNU Public License</span>
44 00037 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>
45 00038 <span class="comment">//</span>
46 00039 <span class="comment">//*****************************************************************************</span>
47 00040
48 00041 <span class="preprocessor">#ifndef LCD_H</span>
49 00042 <span class="preprocessor"></span><span class="preprocessor">#define LCD_H</span>
50 00043 <span class="preprocessor"></span>
51 00044 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>
52 00045
53 00046 <span class="comment">// include project-dependent configurations</span>
54 00047 <span class="preprocessor">#include "<a class="code" href="lcdconf_8h.html">lcdconf.h</a>"</span>
55 00048
56 00049 <span class="comment">// if LCD_DELAY is not defined, this definition sequence</span>
57 00050 <span class="comment">// attempts to find a suitable LCD_DELAY given the F_CPU</span>
58 00051 <span class="preprocessor">#ifndef LCD_DELAY</span>
59 00052 <span class="preprocessor"></span><span class="preprocessor">#if F_CPU &gt;= 16000000</span>
60 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>
61 00054 <span class="preprocessor"></span><span class="preprocessor">#else</span>
62 00055 <span class="preprocessor"></span><span class="preprocessor">#if F_CPU &gt;= 12000000</span>
63 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>
64 00057 <span class="preprocessor"></span><span class="preprocessor">#else</span>
65 00058 <span class="preprocessor"></span><span class="preprocessor">#if F_CPU &gt;= 8000000</span>
66 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>
67 00060 <span class="preprocessor"></span><span class="preprocessor">#else</span>
68 00061 <span class="preprocessor"></span><span class="preprocessor">#if F_CPU &gt;= 4000000</span>
69 00062 <span class="preprocessor"></span><span class="preprocessor">#define LCD_DELAY asm volatile ("nop\n nop\n nop\n nop\n nop\n");</span>
70 00063 <span class="preprocessor"></span><span class="preprocessor">#else</span>
71 00064 <span class="preprocessor"></span><span class="preprocessor">#define LCD_DELAY asm volatile ("nop\n nop\n nop\n");</span>
72 00065 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
73 00066 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
74 00067 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
75 00068 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
76 00069 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
77 00070 <span class="preprocessor"></span>
78 00071 <span class="comment">// HD44780 LCD controller command set (do not modify these)</span>
79 00072 <span class="comment">// writing:</span>
80 00073 <span class="preprocessor">#define LCD_CLR 0 // DB0: clear display</span>
81 00074 <span class="preprocessor"></span><span class="preprocessor">#define LCD_HOME 1 // DB1: return to home position</span>
82 00075 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ENTRY_MODE 2 // DB2: set entry mode</span>
83 00076 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ENTRY_INC 1 // DB1: increment</span>
84 00077 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ENTRY_SHIFT 0 // DB2: shift</span>
85 00078 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ON_CTRL 3 // DB3: turn lcd/cursor on</span>
86 00079 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ON_DISPLAY 2 // DB2: turn display on</span>
87 00080 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ON_CURSOR 1 // DB1: turn cursor on</span>
88 00081 <span class="preprocessor"></span><span class="preprocessor">#define LCD_ON_BLINK 0 // DB0: blinking cursor</span>
89 00082 <span class="preprocessor"></span><span class="preprocessor">#define LCD_MOVE 4 // DB4: move cursor/display</span>
90 00083 <span class="preprocessor"></span><span class="preprocessor">#define LCD_MOVE_DISP 3 // DB3: move display (0-&gt; move cursor)</span>
91 00084 <span class="preprocessor"></span><span class="preprocessor">#define LCD_MOVE_RIGHT 2 // DB2: move right (0-&gt; left)</span>
92 00085 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION 5 // DB5: function set</span>
93 00086 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION_8BIT 4 // DB4: set 8BIT mode (0-&gt;4BIT mode)</span>
94 00087 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION_2LINES 3 // DB3: two lines (0-&gt;one line)</span>
95 00088 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION_10DOTS 2 // DB2: 5x10 font (0-&gt;5x7 font)</span>
96 00089 <span class="preprocessor"></span><span class="preprocessor">#define LCD_CGRAM 6 // DB6: set CG RAM address</span>
97 00090 <span class="preprocessor"></span><span class="preprocessor">#define LCD_DDRAM 7 // DB7: set DD RAM address</span>
98 00091 <span class="preprocessor"></span><span class="comment">// reading:</span>
99 00092 <span class="preprocessor">#define LCD_BUSY 7 // DB7: LCD is busy</span>
100 00093 <span class="preprocessor"></span>
101 00094 <span class="comment">// Default LCD setup</span>
102 00095 <span class="comment">// this default setup is loaded on LCD initialization</span>
103 00096 <span class="preprocessor">#ifdef LCD_DATA_4BIT</span>
104 00097 <span class="preprocessor"></span><span class="preprocessor"> #define LCD_FDEF_1 (0&lt;&lt;LCD_FUNCTION_8BIT)</span>
105 00098 <span class="preprocessor"></span><span class="preprocessor">#else</span>
106 00099 <span class="preprocessor"></span><span class="preprocessor"> #define LCD_FDEF_1 (1&lt;&lt;LCD_FUNCTION_8BIT)</span>
107 00100 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
108 00101 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FDEF_2 (1&lt;&lt;LCD_FUNCTION_2LINES)</span>
109 00102 <span class="preprocessor"></span><span class="preprocessor">#define LCD_FUNCTION_DEFAULT ((1&lt;&lt;LCD_FUNCTION) | LCD_FDEF_1 | LCD_FDEF_2)</span>
110 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>
111 00104 <span class="preprocessor"></span>
112 00105 <span class="comment">// custom LCD characters</span>
113 00106 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> __attribute__ ((progmem)) LcdCustomChar[];
114 00107 #define LCDCHAR_PROGRESS05 0 <span class="comment">// 0/5 full progress block</span>
115 00108 #define LCDCHAR_PROGRESS15 1 <span class="comment">// 1/5 full progress block</span>
116 00109 #define LCDCHAR_PROGRESS25 2 <span class="comment">// 2/5 full progress block</span>
117 00110 #define LCDCHAR_PROGRESS35 3 <span class="comment">// 3/5 full progress block</span>
118 00111 #define LCDCHAR_PROGRESS45 4 <span class="comment">// 4/5 full progress block</span>
119 00112 #define LCDCHAR_PROGRESS55 5 <span class="comment">// 5/5 full progress block</span>
120 00113 #define LCDCHAR_REWINDARROW 6 <span class="comment">// rewind arrow</span>
121 00114 #define LCDCHAR_STOPBLOCK 7 <span class="comment">// stop block</span>
122 00115 #define LCDCHAR_PAUSEBARS 8 <span class="comment">// pause bars</span>
123 00116 #define LCDCHAR_FORWARDARROW 9 <span class="comment">// fast-forward arrow</span>
124 00117 #define LCDCHAR_SCROLLUPARROW 10 <span class="comment">// scroll up arrow</span>
125 00118 #define LCDCHAR_SCROLLDNARROW 11 <span class="comment">// scroll down arrow</span>
126 00119 #define LCDCHAR_BLANK 12 <span class="comment">// scroll down arrow</span>
127 00120 #define LCDCHAR_ANIPLAYICON0 13 <span class="comment">// animated play icon frame 0</span>
128 00121 #define LCDCHAR_ANIPLAYICON1 14 <span class="comment">// animated play icon frame 1</span>
129 00122 #define LCDCHAR_ANIPLAYICON2 15 <span class="comment">// animated play icon frame 2</span>
130 00123 #define LCDCHAR_ANIPLAYICON3 16 <span class="comment">// animated play icon frame 3</span>
131 00124
132 00125 <span class="comment">// progress bar defines</span>
133 00126 #define PROGRESSPIXELS_PER_CHAR 6
134 00127
135 00128
136 00129 <span class="comment">// ****** Low-level functions ******</span>
137 00130 <span class="comment">// the following functions are the only ones which deal with the CPU</span>
138 00131 <span class="comment">// memory or port pins directly. If you decide to use a fundamentally</span>
139 00132 <span class="comment">// different hardware interface to your LCD, only these functions need</span>
140 00133 <span class="comment">// to be changed, after which all the high-level functions will</span>
141 00134 <span class="comment">// work again.</span>
142 00135
143 00136 <span class="comment">// initializes I/O pins connected to LCD</span>
144 00137 <span class="keywordtype">void</span> lcdInitHW(<span class="keywordtype">void</span>);
145 00138 <span class="comment">// waits until LCD is not busy</span>
146 00139 <span class="keywordtype">void</span> lcdBusyWait(<span class="keywordtype">void</span>);
147 00140 <span class="comment">// writes a control command to the LCD</span>
148 00141 <span class="keywordtype">void</span> lcdControlWrite(u08 data);
149 00142 <span class="comment">// read the control status from the LCD</span>
150 00143 u08 lcdControlRead(<span class="keywordtype">void</span>);
151 00144 <span class="comment">// writes a data byte to the LCD screen at the current position</span>
152 00145 <span class="keywordtype">void</span> lcdDataWrite(u08 data);
153 00146 <span class="comment">// reads the data byte on the LCD screen at the current position</span>
154 00147 u08 lcdDataRead(<span class="keywordtype">void</span>);
155 00148
156 00149
157 00150 <span class="comment">// ****** High-levlel functions ******</span>
158 00151 <span class="comment">// these functions provide the high-level control of the LCD</span>
159 00152 <span class="comment">// such as clearing the display, setting cursor positions,</span>
160 00153 <span class="comment">// displaying text and special characters</span>
161 00154
162 00155 <span class="comment">// initializes the LCD display (gets it ready for use)</span>
163 00156 <span class="keywordtype">void</span> lcdInit(<span class="keywordtype">void</span>);
164 00157
165 00158 <span class="comment">// moves the cursor/position to Home (upper left corner)</span>
166 00159 <span class="keywordtype">void</span> lcdHome(<span class="keywordtype">void</span>);
167 00160
168 00161 <span class="comment">// clears the LCD display</span>
169 00162 <span class="keywordtype">void</span> lcdClear(<span class="keywordtype">void</span>);
170 00163
171 00164 <span class="comment">// moves the cursor/position to the row,col requested</span>
172 00165 <span class="comment">// ** this may not be accurate for all displays</span>
173 00166 <span class="keywordtype">void</span> lcdGotoXY(u08 row, u08 col);
174 00167
175 00168 <span class="comment">// loads a special user-defined character into the LCD</span>
176 00169 <span class="comment">// &lt;lcdCustomCharArray&gt; is a pointer to a ROM array containing custom characters</span>
177 00170 <span class="comment">// &lt;romCharNum&gt; is the index of the character to load from lcdCustomCharArray</span>
178 00171 <span class="comment">// &lt;lcdCharNum&gt; is the RAM location in the LCD (legal value: 0-7)</span>
179 00172 <span class="keywordtype">void</span> lcdLoadCustomChar(u08* lcdCustomCharArray, u08 romCharNum, u08 lcdCharNum);
180 00173
181 00174 <span class="comment">// prints a series of bytes/characters to the display</span>
182 00175 <span class="keywordtype">void</span> lcdPrintData(<span class="keywordtype">char</span>* data, u08 nBytes);
183 00176
184 00177 <span class="comment">// displays a horizontal progress bar at the current cursor location</span>
185 00178 <span class="comment">// &lt;progress&gt; is the value the bargraph should indicate</span>
186 00179 <span class="comment">// &lt;maxprogress&gt; is the value at the end of the bargraph</span>
187 00180 <span class="comment">// &lt;length&gt; is the number of LCD characters that the bargraph should cover</span>
188 00181 <span class="keywordtype">void</span> lcdProgressBar(u16 progress, u16 maxprogress, u08 length);
189 00182
190 00183 #endif
191 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by&nbsp;
192 <a href="http://www.doxygen.org/index.html">
193 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
194 </body>
195 </html>
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3