00001
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef LCD_H
00041 #define LCD_H
00042
00043 #include "asuro.h"
00044
00045
00046
00047
00049
00051
00052
00053
00054
00055 #define LCD_INIT {(LCD_4BIT | LCD_2LINE | LCD_5X7), 0}
00056
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
00142
00143 unsigned char portLCD;
00144 unsigned char lineLCD;
00145 unsigned char cursorLCD;
00146
00147
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
00248
00249 #endif
00250
00251