lcd.h

gehe zur Dokumentation dieser Datei
00001 
00016 /*------------------------------------------------------------------------------
00017  *
00018  * Copyright (c) 2006 Rizqi Ahmad (raid_ox)
00019  *
00020  * This software is a free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by the
00022  * Free Software Foundation; either version 2 of the License, or (at your option)
00023  * any later version. You should have received a copy of the GNU
00024  * General Public License along with asurolib; if not, write to the
00025  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
00026  * Boston, MA 02110-1301  USA
00027  *
00028  * The above copyright notice and this permission notice shall be included
00029  * in all copies or substantial portions of the Software.
00030  *
00031  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00032  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00033  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00034  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00035  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00036  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00037  * DEALINGS IN THE SOFTWARE.
00038  *****************************************************************/
00039 
00040 #ifndef LCD_H
00041 #define LCD_H
00042 
00043 #include "asuro.h"
00044 
00045 /*------ DEFINITIONS & MACROS -------------------------------*/
00046 
00047 
00049 
00051 // !SEE DATASHEET
00052 // EXAMPLE:
00053 // #define LCD_INIT {(LCD_4BIT | LCD_1LINE | LCD_5x7), COMMAND2, COMMAND3}
00054 
00055 #define LCD_INIT        {(LCD_4BIT | LCD_2LINE | LCD_5X7), 0}
00056 //#define LCD_INIT {0x29, 0x1C, 0x52, 0x69, 0x74, 0}             // DOGM162 Init, See Datasheet
00057 
00058 #define LCD_DEV         0x40                    // LCD Device Address
00059 #define LCD_LINES       2                                 // Total LCD Lines
00060 #define LCD_CHARS       8                                 // Maximal LCD characters each line
00061 
00062 #define LCD_LINE1       0x00                    // This should be 0x00 on all displays
00063 #define LCD_LINE2       0x40                    // Change this to the address for line 2 on your display
00064 #define LCD_LINE3       0x10                    // Change this to the address for line 3 on your display
00065 #define LCD_LINE4       0x50                    // Change this to the address for line 4 on your display
00066 
00068 
00069 #define LD4                     0                               // Pin to Data Bus 4
00070 #define LD5                     1                               // Pin to Data Bus 5
00071 #define LD6                     2                               // Pin to Data Bus 6
00072 #define LD7                     3                               // Pin to Data Bus 7
00073 
00074 #define LRS                     4                               // Pin to RS Pin (Register Select)
00075 #define LRW                     5                               // Pin to Read/Write Pin
00076 #define LEN                     7                               // Pin to Enable Pin
00077 #define LBL                     6                               // Backlight Pin
00078 
00080 
00082 
00083 #define LCD_D0          (1 << LD4)
00084 #define LCD_D1          (1 << LD5)
00085 #define LCD_D2          (1 << LD6)
00086 #define LCD_D3          (1 << LD7)
00087 
00088 #define LCD_D4          (1 << LD4)
00089 #define LCD_D5          (1 << LD5)
00090 #define LCD_D6          (1 << LD6)
00091 #define LCD_D7          (1 << LD7)
00092 
00093 #define LCD_RS          (1 << LRS)
00094 #define LCD_RW          (1 << LRW)
00095 #define LCD_EN          (1 << LEN)
00096 #define LCD_BL          (1 << LBL)
00097 
00099 
00100 #ifndef CENTER
00101 #define CENTER                  2
00102 #endif
00103 
00105 
00106 #define LCD_CLEAR                       0x01                                                        // Clear Screen
00107 #define LCD_HOME                              0x02                                                          // Cursor Home
00108 
00109 #define LCD_ENTRYMODE               0x04                                                            // Set entrymode
00110 #define LCD_INCREASE                (LCD_ENTRYMODE | 0x02)                // Set cursor move direction -- Increase
00111 #define LCD_DECREASE                (LCD_ENTRYMODE | 0x00)                // Set cursor move direction -- Decrease
00112 #define LCD_DISPLAYSHIFTON      (LCD_ENTRYMODE | 0x01)            // Display is shifted
00113 #define LCD_DISPLAYSHIFTOFF     (LCD_ENTRYMODE | 0x00)            // Display is not shifted
00114 
00115 #define LCD_DISPLAYMODE     0x08                                                            // Set displaymode
00116 #define LCD_DISPLAYON               (LCD_DISPLAYMODE | 0x04)      // Display on
00117 #define LCD_DISPLAYOFF      (LCD_DISPLAYMODE | 0x00)      // Display off
00118 #define LCD_CURSORON                (LCD_DISPLAYMODE | 0x02)      // Cursor on
00119 #define LCD_CURSOROFF               (LCD_DISPLAYMODE | 0x00)      // Cursor off
00120 #define LCD_BLINKINGON      (LCD_DISPLAYMODE | 0x01)      // Blinking on
00121 #define LCD_BLINKINGOFF     (LCD_DISPLAYMODE | 0x00)      // Blinking off
00122 
00123 #define LCD_SHIFTMODE               0x10                                                            // Set shiftmode
00124 #define LCD_DISPLAYSHIFT          (LCD_SHIFTMODE | 0x08)                  // Display shift
00125 #define LCD_CURSORMOVE      (LCD_SHIFTMODE | 0x00)                // Cursor move
00126 #define LCD_RIGHT                             (LCD_SHIFTMODE | 0x04)              // Right shift
00127 #define LCD_LEFT                              (LCD_SHIFTMODE | 0x00)              // Left shift
00128 
00129 #define LCD_CONFIGURATION         0x20                                                    // Set function
00130 #define LCD_8BIT                              (LCD_CONFIGURATION | 0x10)  // 8 bits interface
00131 #define LCD_4BIT                              (LCD_CONFIGURATION | 0x00)        // 4 bits interface
00132 #define LCD_2LINE                             (LCD_CONFIGURATION | 0x08)        // 2 line display
00133 #define LCD_1LINE                             (LCD_CONFIGURATION | 0x00)        // 1 line display
00134 #define LCD_5X10                              (LCD_CONFIGURATION | 0x04)        // 5 X 10 dots
00135 #define LCD_5X7                               (LCD_CONFIGURATION | 0x00)        // 5 X 7 dots
00136 
00137 #define LCD_CGRAM                             0x40                                                          // DD RAM Address Set
00138 #define LCD_DDRAM                             0x80                                                          // DD RAM Address Set
00139 
00140 
00141 /*------- GLOBAL VARIABLES -----------------*/
00142 
00143 unsigned char portLCD; // LCD PORT REGISTER
00144 unsigned char lineLCD;
00145 unsigned char cursorLCD;
00146 
00147 /*------ HEADERS & DESCRIPTIONS ------------*/
00152 void InitLCD(void);
00153 
00154 
00160 void BacklightLCD(unsigned char state);
00161 
00169 void SetIOLCD(unsigned char setCommand, unsigned char bits);
00170 
00176 unsigned char GetIOLCD(void);
00177 
00184 void SetCursorLCD(unsigned char cursor, unsigned char line);
00185 
00191 void ClearLCD(void);
00192 
00198 void SetDataLCD(unsigned char data);
00199 
00205 void CommandLCD(unsigned char command);
00206 
00212 void WriteLCD(unsigned char data);
00213 
00220 void PrintLCD(char *string, unsigned char wrap);
00221 
00229 void PrintSetLCD(unsigned char cursor, unsigned char line, char *string);
00230 
00236 void PrintIntLCD(int value);
00237 
00245 void PrintAlignLCD(unsigned char line, unsigned char alignment, char *string);
00246 
00247 /*----------- FUNCTIONS -------------------*/
00248 
00249 #endif /* LCD_H */
00250 
00251 

Erzeugt am Sun Nov 18 18:24:52 2007 für ASURO Library von  doxygen 1.5.1-p1