⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_8h-source.html

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -