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