4 * This file is part of BeRTOS.
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.
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.
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
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.
29 * Copyright 2005 Develer S.r.l. (http://www.develer.com/)
33 * \brief Generic text LCD driver (interface).
35 * \author Bernie Innocenti <bernie@codewiz.org>
36 * \author Stefano Fedrigo <aleph@develer.com>
38 * $WIZ$ module_name = "lcd_text"
39 * $WIZ$ module_depends = "lcd_hd44", "timer", "formatwr"
47 #include <cfg/macros.h>
48 #include <cfg/compiler.h>
49 #include <struct/list.h>
51 #include <stdarg.h> // vprintf()
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 */
60 /** Special priority value for lcd_setLayerDepth(). */
61 #define LAYER_HIDDEN -127
63 /* Compute LCD address from x/y coordinates */
64 #define LCD_POS(x,y) ((lcdpos_t)((uint8_t)(x) + (uint8_t)(y) * (uint8_t)CONFIG_LCD_COLS))
65 #define LCD_ROW0 (CONFIG_LCD_COLS * 0)
66 #define LCD_ROW1 (CONFIG_LCD_COLS * 1)
67 #define LCD_ROW2 (CONFIG_LCD_COLS * 2)
68 #define LCD_ROW3 (CONFIG_LCD_COLS * 3)
71 * Overwrapping layer context.
76 * Active layers are linked together in a list
77 * sorted in top to bottom order.
79 DECLARE_NODE_ANON(struct _Layer)
81 /** Current XY address into this layer, for write operations. */
84 /** Priority of this layer (greater in front of lesser). */
88 * Layer backing store buffer.
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.
94 char buf[CONFIG_LCD_COLS * CONFIG_LCD_ROWS];
98 /* Global variables */
99 extern Layer *lcd_DefLayer;
101 /* Function prototypes */
102 extern void lcd_init(void);
103 extern void lcd_test(void);
105 extern void lcd_moveCursor(lcdpos_t addr);
106 extern char lcd_setCursor(char state);
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);
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);
122 #endif /* DRV_LCD_H */