better orbiting
[aversive.git] / modules / devices / ihm / lcd / lcd_protocol.h
1 /*  \r
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)\r
3  * \r
4  *  This program is free software; you can redistribute it and/or modify\r
5  *  it under the terms of the GNU General Public License as published by\r
6  *  the Free Software Foundation; either version 2 of the License, or\r
7  *  (at your option) any later version.\r
8  *\r
9  *  This program is distributed in the hope that it will be useful,\r
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  *  GNU General Public License for more details.\r
13  *\r
14  *  You should have received a copy of the GNU General Public License\r
15  *  along with this program; if not, write to the Free Software\r
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
17  *\r
18  *  Revision : $Id: lcd_protocol.h,v 1.1.10.1 2006-11-26 21:06:04 zer0 Exp $\r
19  *\r
20  */\r
21 \r
22 #ifndef LCD_H\r
23 #define LCD_H\r
24 \r
25 #include "lcd_config.h"\r
26 \r
27 \r
28 // masque des broches concernees sur le port\r
29 \r
30 #define LCD_DATA_MASK (0x0F << LCD_FIRST_DATA_BIT)\r
31 \r
32 /* instruction register bit positions */\r
33 #define LCD_CLR             0      /* DB0: clear display */\r
34 #define LCD_HOME            1      /* DB1: return to home position */\r
35 #define LCD_ENTRY_MODE      2      /* DB2: set entry mode */\r
36 #define LCD_ENTRY_INC       1      /*   DB1: 1=increment, 0=decrement  */\r
37 #define LCD_ENTRY_SHIFT     0      /*   DB2: 1=display shift on        */\r
38 #define LCD_ON              3      /* DB3: turn lcd/cursor on */\r
39 #define LCD_ON_DISPLAY      2      /*   DB2: turn display on */\r
40 #define LCD_ON_CURSOR       1      /*   DB1: turn cursor on */\r
41 #define LCD_ON_BLINK        0      /*     DB0: blinking cursor ? */\r
42 #define LCD_MOVE            4      /* DB4: move cursor/display */\r
43 #define LCD_MOVE_DISP       3      /*   DB3: move display (0-> cursor) ? */\r
44 #define LCD_MOVE_RIGHT      2      /*   DB2: move right (0-> left) ? */\r
45 #define LCD_FUNCTION        5      /* DB5: function set */\r
46 #define LCD_FUNCTION_8BIT   4      /*   DB4: set 8BIT mode (0->4BIT mode) */\r
47 #define LCD_FUNCTION_2LINES 3      /*   DB3: two lines (0->one line) */\r
48 #define LCD_FUNCTION_10DOTS 2      /*   DB2: 5x10 font (0->5x7 font) */\r
49 #define LCD_CGRAM           6      /* DB6: set CG RAM address */\r
50 #define LCD_DDRAM           7      /* DB7: set DD RAM address */\r
51 #define LCD_BUSY            7      /* DB7: LCD is busy */\r
52 \r
53 /* set entry mode: display shift on/off, dec/inc cursor move direction */\r
54 #define LCD_ENTRY_DEC            0x04   /* display shift off, dec cursor move dir */\r
55 #define LCD_ENTRY_DEC_SHIFT      0x05   /* display shift on,  dec cursor move dir */\r
56 #define LCD_ENTRY_INC_           0x06   /* display shift off, inc cursor move dir */\r
57 #define LCD_ENTRY_INC_SHIFT      0x07   /* display shift on,  inc cursor move dir */\r
58 \r
59 /* display on/off, cursor on/off, blinking char at cursor position */\r
60 #define LCD_DISP_OFF             0x08   /* display off                            */\r
61 #define LCD_DISP_ON              0x0C   /* display on, cursor off                 */\r
62 #define LCD_DISP_ON_BLINK        0x0D   /* display on, cursor off, blink char     */\r
63 #define LCD_DISP_ON_CURSOR       0x0E   /* display on, cursor on                  */\r
64 #define LCD_DISP_ON_CURSOR_BLINK 0x0F   /* display on, cursor on, blink char      */\r
65 \r
66 /* move cursor/shift display */\r
67 #define LCD_MOVE_CURSOR_LEFT     0x10   /* move cursor left  (decrement)          */\r
68 #define LCD_MOVE_CURSOR_RIGHT    0x14   /* move cursor right (increment)          */\r
69 #define LCD_MOVE_DISP_LEFT       0x18   /* shift display left                     */\r
70 #define LCD_MOVE_DISP_RIGHT      0x1C   /* shift display right                    */\r
71 \r
72 /* function set: set interface data length and number of display lines */\r
73 #define LCD_FUNCTION_4BIT_1LINE  0x20   /* 4-bit interface, single line, 5x7 dots */\r
74 #define LCD_FUNCTION_4BIT_2LINES 0x28   /* 4-bit interface, dual line,   5x7 dots */\r
75 #define LCD_FUNCTION_8BIT_1LINE  0x30   /* 8-bit interface, single line, 5x7 dots */\r
76 #define LCD_FUNCTION_8BIT_2LINES 0x38   /* 8-bit interface, dual line,   5x7 dots */\r
77 \r
78 #if LCD_LINES==1\r
79 #define LCD_FUNCTION_DEFAULT    LCD_FUNCTION_4BIT_1LINE \r
80 #else\r
81 #define LCD_FUNCTION_DEFAULT    LCD_FUNCTION_4BIT_2LINES \r
82 #endif\r
83 \r
84 \r
85 #define LCD_MODE_DEFAULT     ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) )\r
86 \r
87 /*\r
88 ** macros for automatically storing string constant in program memory\r
89 */\r
90 #ifndef P\r
91 #define P(s) ({static const char c[] __attribute__ ((progmem)) = s;c;})\r
92 #endif\r
93 #define lcd_puts_P(__s)         lcd_puts_p(P(__s))\r
94 \r
95 \r
96 #endif //LCD_PROTOCOLE_H\r