Contiki-NG
rgb-bl-lcd.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Zolertia <http://www.zolertia.com>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOcFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 /*---------------------------------------------------------------------------*/
33 /**
34  * \addtogroup zoul-sensors
35  * @{
36  *
37  * \defgroup zoul-lcd-backlight-lcd Grove LCD with RGB backlight
38  * @{
39  *
40  * \file
41  * Grove LCD with RGB backlight header
42  * \author
43  * Antonio Lignan <alinan@zolertia.com>
44  */
45 /*---------------------------------------------------------------------------*/
46 #include "lib/sensors.h"
47 /* -------------------------------------------------------------------------- */
48 #ifndef RGB_BL_LCD_H_
49 #define RGB_BL_LCD_H_
50 /* -------------------------------------------------------------------------- */
51 /**
52  * \name LCD w/ backlight enums
53  * @{
54  */
55 enum {
56  LCD_RGB_WHITE = 0x00,
57  LCD_RGB_RED = 0x01,
58  LCD_RGB_GREEN = 0x02,
59  LCD_RGB_BLUE = 0x03,
60  LCD_RGB_BLACK = 0x04,
61  LCD_RGB_YELLOW = 0x05,
62  LCD_RGB_PURPLE = 0x06,
63 };
64 /* -------------------------------------------------------------------------- */
65 enum {
66  LCD_RGB_1ST_ROW = 0x00,
67  LCD_RGB_2ND_ROW = 0x01,
68 };
69 /** @} */
70 /* -------------------------------------------------------------------------- */
71 /**
72  * \name LCD w/ backlight address, registers and bitmasks
73  * @{
74  */
75 #define LCD_ADDR 0x3E
76 #define LCD_RGB_ADDR 0x62
77 /* -------------------------------------------------------------------------- */
78 #define LCD_RGB_REG_MODE1 0x00
79 #define LCD_RGB_REG_MODE2 0x01
80 #define LCD_RGB_REG_OUTPUT 0x08
81 /* -------------------------------------------------------------------------- */
82 #define LCD_RGB_COMMAND_BYTE 0x80
83 /* -------------------------------------------------------------------------- */
84 #define LCD_RGB_CLEAR_DISPLAY 0x01
85 #define LCD_RGB_RETURN_HOME 0x02
86 #define LCD_RGB_ENTRY_MODE_SET 0x04
87 #define LCD_RGB_DISPLAY_CONTROL 0x08
88 #define LCD_RGB_CURSOR_SHIFT 0x10
89 #define LCD_RGB_FUNCTION_SET 0x20
90 #define LCD_RGB_SETCGRAM_ADDR 0x40
91 #define LCD_RGB_SETDDRAM_ADDR 0x80
92 /* -------------------------------------------------------------------------- */
93 #define LCD_RGB_ENTRY_MODE_RIGHT 0x00
94 #define LCD_RGB_ENTRY_MODE_LEFT 0x02
95 #define LCD_RGB_ENTRY_SHIFT_INCREMENT 0x01
96 #define LCD_RGB_ENTRY_SHIFT_DECREMENT 0x00
97 /* -------------------------------------------------------------------------- */
98 #define LCD_RGB_DISPLAY_ON 0x04
99 #define LCD_RGB_DISPLAY_OFF 0x00
100 #define LCD_RGB_DISPLAY_CURSOR_ON 0x02
101 #define LCD_RGB_DISPLAY_CURSOR_OFF 0x00
102 #define LCD_RGB_DISPLAY_BLINK_ON 0x01
103 #define LCD_RGB_DISPLAY_BLINK_OFF 0x00
104 /* -------------------------------------------------------------------------- */
105 #define LCD_RGB_CURSOR_DISPLAY_MOVE 0x08
106 #define LCD_RGB_CURSOR_MOVE 0x00
107 #define LCD_RGB_CURSOR_MOVE_RIGHT 0x04
108 #define LCD_RGB_CURSOR_MOVE_LEFT 0x00
109 /* -------------------------------------------------------------------------- */
110 #define LCD_RGB_FUNCTION_SET_8BIT 0x10
111 #define LCD_RGB_FUNCTION_SET_4BIT 0x00
112 #define LCD_RGB_FUNCTION_SET_2_LINE 0x08
113 #define LCD_RGB_FUNCTION_SET_1_LINE 0x00
114 #define LCD_RGB_FUNCTION_SET_5x10_DOTS 0x04
115 #define LCD_RGB_FUNCTION_SET_5x8_DOTS 0x00
116 /* -------------------------------------------------------------------------- */
117 #define LCD_RGB_LED_MODE_1 0x00
118 #define LCD_RGB_LED_MODE_2 0x01
119 #define LCD_RGB_LED_OUT 0x08
120 /* -------------------------------------------------------------------------- */
121 #define LCD_RGB_LED_RED 0x04
122 #define LCD_RGB_LED_GREEN 0x03
123 #define LCD_RGB_LED_BLUE 0x02
124 /* -------------------------------------------------------------------------- */
125 #define LCD_RGB_LED_MODE_DEFAULT 0x00
126 #define LCD_RGB_LED_OUT_PWM_CTRL 0xAA
127 /* -------------------------------------------------------------------------- */
128 #define LCD_RGB_DELAY_50MS 50000
129 #define LCD_RGB_DELAY_4_5MS 4500
130 #define LCD_RGB_DELAY_150US 150
131 #define LCD_RGB_DELAY_2MS 2000
132 /* -------------------------------------------------------------------------- */
133 #define LCD_RGB_START_1ST_ROW 0x80
134 #define LCD_RGB_START_2ND_ROW 0xC0
135 /* -------------------------------------------------------------------------- */
136 #define LCD_RGB_ACTIVE SENSORS_ACTIVE
137 #define LCD_RGB_ERROR (-1)
138 #define LCD_RGB_SUCCESS 0x00
139 /** @} */
140 /* -------------------------------------------------------------------------- */
141 /**
142  * \name TSL2563 return and command values
143  * @{
144  */
145 /* LCD functions */
146 uint8_t lcd_write(const char *s);
147 int lcd_set_cursor(uint8_t col, uint8_t row);
148 int lcd_autoscroll(uint8_t state);
149 int lcd_scroll_display(uint8_t direction, uint8_t num);
150 int lcd_blink(uint8_t state);
151 int lcd_clear_display(void);
152 int lcd_return_home(void);
153 int lcd_display(uint8_t state);
154 int lcd_cursor(uint8_t state);
155 int lcd_text_direction(uint8_t direction);
156 
157 /* Backlight functions */
158 int lcd_backlight_color(uint8_t color);
159 /** @} */
160 /* -------------------------------------------------------------------------- */
161 #define RGB_BACKLIGHT_LCD "LCD with RGB backlight"
162 extern const struct sensors_sensor rgb_bl_lcd;
163 /* -------------------------------------------------------------------------- */
164 #endif /* ifndef RGB_BL_LCD_ */
165 /**
166  * @}
167  * @}
168  */