00001 /* 00002 * Copyright Droids Corporation, Microb Technology, Eirbot (2005) 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Revision : $Id: lcd_protocol.h,v 1.1 2005-11-11 16:45:11 enseirb Exp $ 00019 * 00020 */ 00021 00022 #ifndef LCD_H 00023 #define LCD_H 00024 00025 #include "lcd_config.h" 00026 00027 00028 // masque des broches concernees sur le port 00029 00030 #define LCD_DATA_MASK (0x0F << LCD_FIRST_DATA_BIT) 00031 00032 /* instruction register bit positions */ 00033 #define LCD_CLR 0 /* DB0: clear display */ 00034 #define LCD_HOME 1 /* DB1: return to home position */ 00035 #define LCD_ENTRY_MODE 2 /* DB2: set entry mode */ 00036 #define LCD_ENTRY_INC 1 /* DB1: 1=increment, 0=decrement */ 00037 #define LCD_ENTRY_SHIFT 0 /* DB2: 1=display shift on */ 00038 #define LCD_ON 3 /* DB3: turn lcd/cursor on */ 00039 #define LCD_ON_DISPLAY 2 /* DB2: turn display on */ 00040 #define LCD_ON_CURSOR 1 /* DB1: turn cursor on */ 00041 #define LCD_ON_BLINK 0 /* DB0: blinking cursor ? */ 00042 #define LCD_MOVE 4 /* DB4: move cursor/display */ 00043 #define LCD_MOVE_DISP 3 /* DB3: move display (0-> cursor) ? */ 00044 #define LCD_MOVE_RIGHT 2 /* DB2: move right (0-> left) ? */ 00045 #define LCD_FUNCTION 5 /* DB5: function set */ 00046 #define LCD_FUNCTION_8BIT 4 /* DB4: set 8BIT mode (0->4BIT mode) */ 00047 #define LCD_FUNCTION_2LINES 3 /* DB3: two lines (0->one line) */ 00048 #define LCD_FUNCTION_10DOTS 2 /* DB2: 5x10 font (0->5x7 font) */ 00049 #define LCD_CGRAM 6 /* DB6: set CG RAM address */ 00050 #define LCD_DDRAM 7 /* DB7: set DD RAM address */ 00051 #define LCD_BUSY 7 /* DB7: LCD is busy */ 00052 00053 /* set entry mode: display shift on/off, dec/inc cursor move direction */ 00054 #define LCD_ENTRY_DEC 0x04 /* display shift off, dec cursor move dir */ 00055 #define LCD_ENTRY_DEC_SHIFT 0x05 /* display shift on, dec cursor move dir */ 00056 #define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */ 00057 #define LCD_ENTRY_INC_SHIFT 0x07 /* display shift on, inc cursor move dir */ 00058 00059 /* display on/off, cursor on/off, blinking char at cursor position */ 00060 #define LCD_DISP_OFF 0x08 /* display off */ 00061 #define LCD_DISP_ON 0x0C /* display on, cursor off */ 00062 #define LCD_DISP_ON_BLINK 0x0D /* display on, cursor off, blink char */ 00063 #define LCD_DISP_ON_CURSOR 0x0E /* display on, cursor on */ 00064 #define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */ 00065 00066 /* move cursor/shift display */ 00067 #define LCD_MOVE_CURSOR_LEFT 0x10 /* move cursor left (decrement) */ 00068 #define LCD_MOVE_CURSOR_RIGHT 0x14 /* move cursor right (increment) */ 00069 #define LCD_MOVE_DISP_LEFT 0x18 /* shift display left */ 00070 #define LCD_MOVE_DISP_RIGHT 0x1C /* shift display right */ 00071 00072 /* function set: set interface data length and number of display lines */ 00073 #define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */ 00074 #define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */ 00075 #define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */ 00076 #define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */ 00077 00078 #if LCD_LINES==1 00079 #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE 00080 #else 00081 #define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES 00082 #endif 00083 00084 00085 #define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) ) 00086 00087 /* 00088 ** macros for automatically storing string constant in program memory 00089 */ 00090 #ifndef P 00091 #define P(s) ({static const char c[] __attribute__ ((progmem)) = s;c;}) 00092 #endif 00093 #define lcd_puts_P(__s) lcd_puts_p(P(__s)) 00094 00095 00096 #endif //LCD_PROTOCOLE_H