ASURO Library  2.80
lcd.h
gehe zur Dokumentation dieser Datei
1 
16 /*------------------------------------------------------------------------------
17  *
18  * Copyright (c) 2006 Rizqi Ahmad (raid_ox)
19  *
20  * This software is a free software; you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License as published by the
22  * Free Software Foundation; either version 2 of the License, or (at your option)
23  * any later version. You should have received a copy of the GNU
24  * General Public License along with asurolib; if not, write to the
25  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
26  * Boston, MA 02110-1301 USA
27  *
28  * The above copyright notice and this permission notice shall be included
29  * in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
34  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
37  * DEALINGS IN THE SOFTWARE.
38  *****************************************************************/
39 
40 #ifndef LCD_H
41 #define LCD_H
42 
43 #include "asuro.h"
44 #include "myasuro.h"
45 
46 /*------ DEFINITIONS & MACROS -------------------------------*/
47 
48 
50 
52 // !SEE DATASHEET
53 // EXAMPLE:
54 //#define LCD_INIT {(LCD_4BIT | LCD_1LINE | LCD_5x7), COMMAND2, COMMAND3}
55 
56 #define LCD_INIT {(LCD_4BIT | LCD_2LINE | LCD_5X7), 0}
57 //#define LCD_INIT {0x29, 0x1C, 0x52, 0x69, 0x74, 0} // DOGM162 Init, See Datasheet
58 
59 #define LCD_DEV 0x40 // LCD Device Address
60 #define LCD_LINES 2 // Total LCD Lines
61 #define LCD_CHARS 8 // Maximal LCD characters each line
62 
63 #define LCD_LINE1 0x00 // This should be 0x00 on all displays
64 #define LCD_LINE2 0x40 // Change this to the address for line 2 on your display
65 #define LCD_LINE3 0x10 // Change this to the address for line 3 on your display
66 #define LCD_LINE4 0x50 // Change this to the address for line 4 on your display
67 
69 
70 #define LD4 MY_LCD_LD4 // Pin to Data Bus 4
71 #define LD5 MY_LCD_LD5 // Pin to Data Bus 5
72 #define LD6 MY_LCD_LD6 // Pin to Data Bus 6
73 #define LD7 MY_LCD_LD7 // Pin to Data Bus 7
74 
75 #define LRS MY_LCD_LRS // Pin to RS Pin (Register Select)
76 #define LRW MY_LCD_LRW // Pin to Read/Write Pin
77 #define LEN MY_LCD_LEN // Pin to Enable Pin
78 #define LBL MY_LCD_LBL // Backlight Pin
79 
81 
83 
84 #define LCD_D0 (1 << LD4)
85 #define LCD_D1 (1 << LD5)
86 #define LCD_D2 (1 << LD6)
87 #define LCD_D3 (1 << LD7)
88 
89 #define LCD_D4 (1 << LD4)
90 #define LCD_D5 (1 << LD5)
91 #define LCD_D6 (1 << LD6)
92 #define LCD_D7 (1 << LD7)
93 
94 #define LCD_RS (1 << LRS)
95 #define LCD_RW (1 << LRW)
96 #define LCD_EN (1 << LEN)
97 #define LCD_BL (1 << LBL)
98 
100 
101 #ifndef CENTER
102 #define CENTER 2
103 #endif
104 
106 
107 #define LCD_CLEAR 0x01 // Clear Screen
108 #define LCD_HOME 0x02 // Cursor Home
109 
110 #define LCD_ENTRYMODE 0x04 // Set entrymode
111 #define LCD_INCREASE (LCD_ENTRYMODE | 0x02) // Set cursor move direction -- Increase
112 #define LCD_DECREASE (LCD_ENTRYMODE | 0x00) // Set cursor move direction -- Decrease
113 #define LCD_DISPLAYSHIFTON (LCD_ENTRYMODE | 0x01) // Display is shifted
114 #define LCD_DISPLAYSHIFTOFF (LCD_ENTRYMODE | 0x00) // Display is not shifted
115 
116 #define LCD_DISPLAYMODE 0x08 // Set displaymode
117 #define LCD_DISPLAYON (LCD_DISPLAYMODE | 0x04) // Display on
118 #define LCD_DISPLAYOFF (LCD_DISPLAYMODE | 0x00) // Display off
119 #define LCD_CURSORON (LCD_DISPLAYMODE | 0x02) // Cursor on
120 #define LCD_CURSOROFF (LCD_DISPLAYMODE | 0x00) // Cursor off
121 #define LCD_BLINKINGON (LCD_DISPLAYMODE | 0x01) // Blinking on
122 #define LCD_BLINKINGOFF (LCD_DISPLAYMODE | 0x00) // Blinking off
123 
124 #define LCD_SHIFTMODE 0x10 // Set shiftmode
125 #define LCD_DISPLAYSHIFT (LCD_SHIFTMODE | 0x08) // Display shift
126 #define LCD_CURSORMOVE (LCD_SHIFTMODE | 0x00) // Cursor move
127 #define LCD_RIGHT (LCD_SHIFTMODE | 0x04) // Right shift
128 #define LCD_LEFT (LCD_SHIFTMODE | 0x00) // Left shift
129 
130 #define LCD_CONFIGURATION 0x20 // Set function
131 #define LCD_8BIT (LCD_CONFIGURATION | 0x10) // 8 bits interface
132 #define LCD_4BIT (LCD_CONFIGURATION | 0x00) // 4 bits interface
133 #define LCD_2LINE (LCD_CONFIGURATION | 0x08) // 2 line display
134 #define LCD_1LINE (LCD_CONFIGURATION | 0x00) // 1 line display
135 #define LCD_5X10 (LCD_CONFIGURATION | 0x04) // 5 X 10 dots
136 #define LCD_5X7 (LCD_CONFIGURATION | 0x00) // 5 X 7 dots
137 
138 #define LCD_CGRAM 0x40 // DD RAM Address Set
139 #define LCD_DDRAM 0x80 // DD RAM Address Set
140 
141 // Makros für die drei Taster
142 #define LCD_KEY_YELLOW (1<<PD6)
143 #define LCD_KEY_RED (1<<PD2)
144 #define LCD_KEY_BLUE (1<<PB3)
145 
146 /*------- GLOBAL VARIABLES -----------------*/
147 
148 unsigned char portLCD; // LCD PORT REGISTER
149 unsigned char lineLCD;
150 unsigned char cursorLCD;
151 
152 /*------ HEADERS & DESCRIPTIONS ------------*/
157 void InitLCD(void);
158 
163 void InitLCDKeys(void);
164 
170 void BacklightLCD(unsigned char state);
171 
179 void SetIOLCD(unsigned char setCommand, unsigned char bits);
180 
186 unsigned char GetIOLCD(void);
187 
194 void SetCursorLCD(unsigned char cursor, unsigned char line);
195 
200 void ClearLCD(void);
201 
207 void SetDataLCD(unsigned char data);
208 
214 void CommandLCD(unsigned char command);
215 
221 void WriteLCD(unsigned char data);
222 
229 void PrintLCD(char *string, unsigned char wrap);
230 
238 void PrintSetLCD(unsigned char cursor, unsigned char line, char *string);
239 
245 void PrintIntLCD(int value);
246 
254 void PrintAlignLCD(unsigned char line, unsigned char alignment, char *string);
255 
261 void PrintLCD_p(const char *progmem_s);
262 #define PrintLCD_P(_str) PrintLCD_p(PSTR(_str))
263 
270 void SetCharLCD_p(unsigned char AsciiCode, const char *progmem_s);
271 #define SetCharLCD_P(_asc, _str) SetCharLCD_p(_asc, PSTR(_str))
272 
278 int PollSwitchLCD (void);
279 
280 /*----------- FUNCTIONS -------------------*/
281 
282 #endif /* LCD_H */
283 
284