Doc fixes.
[bertos.git] / drv / lcd_text.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2005 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \brief Generic text LCD driver (interface).
34  *
35  * \version $Id$
36  * \author Bernardo Innocenti <bernie@develer.com>
37  * \author Stefano Fedrigo <aleph@develer.com>
38  */
39
40 /*#*
41  *#* $Log$
42  *#* Revision 1.3  2006/07/19 12:56:26  bernie
43  *#* Convert to new Doxygen style.
44  *#*
45  *#* Revision 1.2  2006/02/23 10:59:14  bernie
46  *#* Documentation fixes.
47  *#*
48  *#* Revision 1.1  2005/11/04 18:00:42  bernie
49  *#* Import into DevLib.
50  *#*
51  *#* Revision 1.5  2005/06/14 14:43:43  bernie
52  *#* Add DevLib headers.
53  *#*
54  *#* Revision 1.4  2005/06/06 17:41:57  batt
55  *#* Add lcd_layerSet function.
56  *#*
57  *#* Revision 1.3  2005/06/01 10:36:23  batt
58  *#* Layer: Rename member variables and Doxygenize.
59  *#*
60  *#* Revision 1.2  2005/05/26 08:31:23  batt
61  *#* Add layer hiding/showing.
62  *#*
63  *#* Revision 1.1  2005/05/24 09:17:58  batt
64  *#* Move drivers to top-level.
65  *#*/
66
67 #ifndef DRV_LCD_H
68 #define DRV_LCD_H
69
70 #include "lcd_hd44.h"
71
72 #include <cfg/macros.h>
73 #include <cfg/compiler.h>
74 #include <mware/list.h>
75
76 #include <stdarg.h> // vprintf()
77
78
79 /* flags for lcd_printf() */
80 #define LCD_NORMAL     0       /* Scrittura normale */
81 #define LCD_FILL       BV(0)   /* Fill rest of line with spaces */
82 #define LCD_CENTER     BV(1)   /* Center string in line */
83 #define LCD_NOCURSOR   BV(2)   /* Scrittura senza spostamento cursore */
84
85 /** Special priority value for lcd_setLayerDepth(). */
86 #define LAYER_HIDDEN   -128
87
88 /* Compute LCD address from x/y coordinates */
89 #define LCD_POS(x,y)  ((lcdpos_t)((uint8_t)(x) + (uint8_t)(y) * (uint8_t)LCD_COLS))
90 #define LCD_ROW0  (LCD_COLS * 0)
91 #define LCD_ROW1  (LCD_COLS * 1)
92 #define LCD_ROW2  (LCD_COLS * 2)
93 #define LCD_ROW3  (LCD_COLS * 3)
94
95 /**
96  * Overwrapping layer context.
97  */
98 typedef struct _Layer
99 {
100         /**
101          * Active layers are linked together in a list
102          * sorted in top to bottom order.
103          */
104         DECLARE_NODE_ANON(struct _Layer)
105
106         /** Current XY address into this layer, for write operations. */
107         lcdpos_t addr;
108
109         /** Priority of this layer (greater in front of lesser). */
110         char pri;
111
112         /**
113          * Layer backing store buffer.
114          *
115          * All writes through the layer are copied into this buffer.
116          * Characters cells with value 0 are transparent with respect
117          * to other layers in the background.
118          */
119         char buf[LCD_COLS * LCD_ROWS];
120 } Layer;
121
122
123 /* Global variables */
124 extern Layer *lcd_DefLayer;
125
126 /* Function prototypes */
127 extern void lcd_init(void);
128 extern void lcd_test(void);
129
130 extern void lcd_moveCursor(lcdpos_t addr);
131 extern char lcd_setCursor(char state);
132
133 extern void lcd_setAddr(Layer *layer, lcdpos_t addr);
134 extern void lcd_putChar(char c, Layer *layer);
135 extern int  lcd_vprintf(Layer *layer, lcdpos_t addr, uint8_t mode, const char *format, va_list ap) FORMAT(printf, 4, 0);
136 extern int  lcd_printf(Layer *layer, lcdpos_t addr, uint8_t mode, const char *format, ...) FORMAT(printf, 4, 5);
137 extern void lcd_clear(Layer *layer);
138 extern void lcd_layerSet(Layer *layer, char c);
139 extern void lcd_clearLine(Layer *layer, int y);
140
141 extern void lcd_setLayerDepth(Layer *layer, char pri);
142 extern Layer *lcd_newLayer(char pri);
143 extern void lcd_deleteLayer(Layer *layer);
144 extern void lcd_lock(void);
145 extern void lcd_unlock(void);
146
147 #endif /* DRV_LCD_H */