00001 #ifndef LCD_H
00002 #define LCD_H
00003
00004
00005
00006
00007
00008
00009
00010
00035
00036 #if (__GNUC__ * 100 + __GNUC_MINOR__) < 303
00037 #error "This library requires AVR-GCC 3.3 or later, update to newer AVR-GCC compiler !"
00038 #endif
00039
00040 #include <inttypes.h>
00041 #include <avr/pgmspace.h>
00042
00047 #define XTAL F_CPU
00053 #define LCD_CONTROLLER_KS0073 0
00059 #define LCD_LINES 2
00060 #define LCD_DISP_LENGTH 16
00061 #define LCD_LINE_LENGTH 0x40
00062 #define LCD_START_LINE1 0x00
00063 #define LCD_START_LINE2 0x40
00064 #define LCD_START_LINE3 0x14
00065 #define LCD_START_LINE4 0x54
00066 #define LCD_WRAP_LINES 0
00068 #define LCD_IO_MODE 1
00070 #if LCD_IO_MODE
00071
00084 #define LCD_PORT PORTB
00085 #define LCD_DATA0_PORT LCD_PORT
00086 #define LCD_DATA1_PORT LCD_PORT
00087 #define LCD_DATA2_PORT LCD_PORT
00088 #define LCD_DATA3_PORT LCD_PORT
00089 #define LCD_DATA0_PIN 0
00090 #define LCD_DATA1_PIN 1
00091 #define LCD_DATA2_PIN 2
00092 #define LCD_DATA3_PIN 3
00093 #define LCD_RS_PORT PORTD
00094 #define LCD_RS_PIN 2
00095 #define LCD_RW_PORT PORTD
00096 #define LCD_RW_PIN 3
00097 #define LCD_E_PORT PORTD
00098 #define LCD_E_PIN 4
00100 #elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \
00101 defined(__AVR_ATmega8515__)|| defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || \
00102 defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__)
00103
00104
00105
00106 #define LCD_IO_DATA 0xC000
00107 #define LCD_IO_FUNCTION 0x8000
00108 #define LCD_IO_READ 0x0100
00109 #else
00110 #error "external data memory interface not available for this device, use 4-bit IO port mode"
00111
00112 #endif
00113
00114
00121
00122 #define LCD_CLR 0
00123 #define LCD_HOME 1
00124 #define LCD_ENTRY_MODE 2
00125 #define LCD_ENTRY_INC 1
00126 #define LCD_ENTRY_SHIFT 0
00127 #define LCD_ON 3
00128 #define LCD_ON_DISPLAY 2
00129 #define LCD_ON_CURSOR 1
00130 #define LCD_ON_BLINK 0
00131 #define LCD_MOVE 4
00132 #define LCD_MOVE_DISP 3
00133 #define LCD_MOVE_RIGHT 2
00134 #define LCD_FUNCTION 5
00135 #define LCD_FUNCTION_8BIT 4
00136 #define LCD_FUNCTION_2LINES 3
00137 #define LCD_FUNCTION_10DOTS 2
00138 #define LCD_CGRAM 6
00139 #define LCD_DDRAM 7
00140 #define LCD_BUSY 7
00141
00142
00143 #define LCD_ENTRY_DEC 0x04
00144 #define LCD_ENTRY_DEC_SHIFT 0x05
00145 #define LCD_ENTRY_INC_ 0x06
00146 #define LCD_ENTRY_INC_SHIFT 0x07
00147
00148
00149 #define LCD_DISP_OFF 0x08
00150 #define LCD_DISP_ON 0x0C
00151 #define LCD_DISP_ON_BLINK 0x0D
00152 #define LCD_DISP_ON_CURSOR 0x0E
00153 #define LCD_DISP_ON_CURSOR_BLINK 0x0F
00154
00155
00156 #define LCD_MOVE_CURSOR_LEFT 0x10
00157 #define LCD_MOVE_CURSOR_RIGHT 0x14
00158 #define LCD_MOVE_DISP_LEFT 0x18
00159 #define LCD_MOVE_DISP_RIGHT 0x1C
00160
00161
00162 #define LCD_FUNCTION_4BIT_1LINE 0x20
00163 #define LCD_FUNCTION_4BIT_2LINES 0x28
00164 #define LCD_FUNCTION_8BIT_1LINE 0x30
00165 #define LCD_FUNCTION_8BIT_2LINES 0x38
00166
00167
00168 #define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) )
00169
00170
00171
00185 void lcd_init(uint8_t dispAttr);
00186
00187
00193 void lcd_clrscr(void);
00194
00195
00201 void lcd_home(void);
00202
00203
00211 void lcd_gotoxy(uint8_t x, uint8_t y);
00212
00213
00219 void lcd_putc(char c);
00220
00221
00227 void lcd_puts(const char *s);
00228
00229
00236 void lcd_puts_p(const char *progmem_s);
00237
00238
00244 void lcd_command(uint8_t cmd);
00245
00246
00254 void lcd_data(uint8_t data);
00255
00256
00260 #define lcd_puts_P(__s) lcd_puts_p(PSTR(__s))
00261
00263 #endif //LCD_H