4f138471d1bdac5915bd6a7ef193b78e10784f4f
[bertos.git] / drv / lcd_text.h
1 /**
2  * \file
3  * <!--
4  * Copyright 2005 Develer S.r.l. (http://www.develer.com/)
5  * This file is part of DevLib - See README.devlib for information.
6  * -->
7  *
8  * \brief Generic text LCD driver (interface).
9  *
10  * \version $Id$
11  * \author Bernardo Innocenti <bernie@develer.com>
12  * \author Stefano Fedrigo <aleph@develer.com>
13  */
14
15 /*#*
16  *#* $Log$
17  *#* Revision 1.3  2006/07/19 12:56:26  bernie
18  *#* Convert to new Doxygen style.
19  *#*
20  *#* Revision 1.2  2006/02/23 10:59:14  bernie
21  *#* Documentation fixes.
22  *#*
23  *#* Revision 1.1  2005/11/04 18:00:42  bernie
24  *#* Import into DevLib.
25  *#*
26  *#* Revision 1.5  2005/06/14 14:43:43  bernie
27  *#* Add DevLib headers.
28  *#*
29  *#* Revision 1.4  2005/06/06 17:41:57  batt
30  *#* Add lcd_layerSet function.
31  *#*
32  *#* Revision 1.3  2005/06/01 10:36:23  batt
33  *#* Layer: Rename member variables and Doxygenize.
34  *#*
35  *#* Revision 1.2  2005/05/26 08:31:23  batt
36  *#* Add layer hiding/showing.
37  *#*
38  *#* Revision 1.1  2005/05/24 09:17:58  batt
39  *#* Move drivers to top-level.
40  *#*/
41
42 #ifndef DRV_LCD_H
43 #define DRV_LCD_H
44
45 #include "lcd_hd44.h"
46
47 #include <cfg/macros.h>
48 #include <cfg/compiler.h>
49 #include <mware/list.h>
50
51 #include <stdarg.h> // vprintf()
52
53
54 /* flags for lcd_printf() */
55 #define LCD_NORMAL     0       /* Scrittura normale */
56 #define LCD_FILL       BV(0)   /* Fill rest of line with spaces */
57 #define LCD_CENTER     BV(1)   /* Center string in line */
58 #define LCD_NOCURSOR   BV(2)   /* Scrittura senza spostamento cursore */
59
60 /** Special priority value for lcd_setLayerDepth(). */
61 #define LAYER_HIDDEN   -128
62
63 /* Compute LCD address from x/y coordinates */
64 #define LCD_POS(x,y)  ((lcdpos_t)((uint8_t)(x) + (uint8_t)(y) * (uint8_t)LCD_COLS))
65 #define LCD_ROW0  (LCD_COLS * 0)
66 #define LCD_ROW1  (LCD_COLS * 1)
67 #define LCD_ROW2  (LCD_COLS * 2)
68 #define LCD_ROW3  (LCD_COLS * 3)
69
70 /**
71  * Overwrapping layer context.
72  */
73 typedef struct _Layer
74 {
75         /**
76          * Active layers are linked together in a list
77          * sorted in top to bottom order.
78          */
79         DECLARE_NODE_ANON(struct _Layer)
80
81         /** Current XY address into this layer, for write operations. */
82         lcdpos_t addr;
83
84         /** Priority of this layer (greater in front of lesser). */
85         char pri;
86
87         /**
88          * Layer backing store buffer.
89          *
90          * All writes through the layer are copied into this buffer.
91          * Characters cells with value 0 are transparent with respect
92          * to other layers in the background.
93          */
94         char buf[LCD_COLS * LCD_ROWS];
95 } Layer;
96
97
98 /* Global variables */
99 extern Layer *lcd_DefLayer;
100
101 /* Function prototypes */
102 extern void lcd_init(void);
103 extern void lcd_test(void);
104
105 extern void lcd_moveCursor(lcdpos_t addr);
106 extern char lcd_setCursor(char state);
107
108 extern void lcd_setAddr(Layer *layer, lcdpos_t addr);
109 extern void lcd_putChar(char c, Layer *layer);
110 extern int  lcd_vprintf(Layer *layer, lcdpos_t addr, uint8_t mode, const char *format, va_list ap) FORMAT(printf, 4, 0);
111 extern int  lcd_printf(Layer *layer, lcdpos_t addr, uint8_t mode, const char *format, ...) FORMAT(printf, 4, 5);
112 extern void lcd_clear(Layer *layer);
113 extern void lcd_layerSet(Layer *layer, char c);
114 extern void lcd_clearLine(Layer *layer, int y);
115
116 extern void lcd_setLayerDepth(Layer *layer, char pri);
117 extern Layer *lcd_newLayer(char pri);
118 extern void lcd_deleteLayer(Layer *layer);
119 extern void lcd_lock(void);
120 extern void lcd_unlock(void);
121
122 #endif /* DRV_LCD_H */