1 /* grove_lcd.h - Public API for the Grove RGB LCD device */
2 /*
3  * Copyright (c) 2015 Intel Corporation
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 #ifndef ZEPHYR_INCLUDE_DISPLAY_GROVE_LCD_H_
8 #define ZEPHYR_INCLUDE_DISPLAY_GROVE_LCD_H_
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 /**
15  * @brief Display Drivers
16  * @defgroup display_interfaces Display Drivers
17  * @{
18  * @}
19  */
20 
21 /**
22  * @brief Grove display APIs
23  * @defgroup grove_display Grove display APIs
24  * @ingroup display_interfaces
25  * @{
26  */
27 
28 #define GROVE_LCD_NAME			"GLCD"
29 
30 /**
31  *  @brief Send text to the screen
32  *
33  *  @param port Pointer to device structure for driver instance.
34  *  @param data the ASCII text to display
35  *  @param size the length of the text in bytes
36  */
37 void glcd_print(const struct device *port, char *data, uint32_t size);
38 
39 
40 /**
41  *  @brief Set text cursor position for next additions
42  *
43  *  @param port Pointer to device structure for driver instance.
44  *  @param col the column for the cursor to be moved to (0-15)
45  *  @param row the row it should be moved to (0 or 1)
46  */
47 void glcd_cursor_pos_set(const struct device *port, uint8_t col, uint8_t row);
48 
49 /**
50  *  @brief Clear the current display
51  *
52  *  @param port Pointer to device structure for driver instance.
53  */
54 void glcd_clear(const struct device *port);
55 
56 /* Defines for the GLCD_CMD_DISPLAY_SWITCH options */
57 #define GLCD_DS_DISPLAY_ON		(1 << 2)
58 #define GLCD_DS_DISPLAY_OFF		(0 << 2)
59 #define GLCD_DS_CURSOR_ON		(1 << 1)
60 #define GLCD_DS_CURSOR_OFF		(0 << 1)
61 #define GLCD_DS_BLINK_ON		(1 << 0)
62 #define GLCD_DS_BLINK_OFF		(0 << 0)
63 /**
64  *  @brief Function to change the display state.
65  *  @details This function provides the user the ability to change the state
66  *  of the display as per needed. Controlling things like powering on or off
67  *  the screen, the option to display the cursor or not, and the ability to
68  *  blink the cursor.
69  *
70  *  @param port Pointer to device structure for driver instance.
71  *  @param opt An 8bit bitmask of GLCD_DS_* options.
72  *
73  */
74 void glcd_display_state_set(const struct device *port, uint8_t opt);
75 
76 /**
77  * @brief return the display feature set associated with the device
78  *
79  * @param port the Grove LCD to get the display features set
80  *
81  * @return the display feature set associated with the device.
82  */
83 uint8_t glcd_display_state_get(const struct device *port);
84 
85 /* Defines for the GLCD_CMD_INPUT_SET to change text direction */
86 #define GLCD_IS_SHIFT_INCREMENT	(1 << 1)
87 #define GLCD_IS_SHIFT_DECREMENT	(0 << 1)
88 #define GLCD_IS_ENTRY_LEFT	(1 << 0)
89 #define GLCD_IS_ENTRY_RIGHT	(0 << 0)
90 /**
91  *  @brief Function to change the input state.
92  *  @details This function provides the user the ability to change the state
93  *  of the text input. Controlling things like text entry from the left or
94  *  right side, and how far to increment on new text
95  *
96  *  @param port Pointer to device structure for driver instance.
97  *  @param opt A bitmask of GLCD_IS_* options
98  *
99  */
100 void glcd_input_state_set(const struct device *port, uint8_t opt);
101 
102 /**
103  * @brief return the input set associated with the device
104  *
105  * @param port the Grove LCD to get the input features set
106  *
107  * @return the input set associated with the device.
108  */
109 uint8_t glcd_input_state_get(const struct device *port);
110 
111 /* Defines for the LCD_FUNCTION_SET */
112 #define GLCD_FS_8BIT_MODE	(1 << 4)
113 #define GLCD_FS_ROWS_2		(1 << 3)
114 #define GLCD_FS_ROWS_1		(0 << 3)
115 #define GLCD_FS_DOT_SIZE_BIG	(1 << 2)
116 #define GLCD_FS_DOT_SIZE_LITTLE	(0 << 2)
117 /* Bits 0, 1 are not defined for this register */
118 
119 /**
120  *  @brief Function to set the functional state of the display.
121  *  @param port Pointer to device structure for driver instance.
122  *  @param opt A bitmask of GLCD_FS_* options
123  *
124  *  @details This function provides the user the ability to change the state
125  *  of the display as per needed.  Controlling things like the number of rows,
126  *  dot size, and text display quality.
127  */
128 void glcd_function_set(const struct device *port, uint8_t opt);
129 
130 /**
131  * @brief return the function set associated with the device
132  *
133  * @param port the Grove LCD to get the functions set
134  *
135  * @return the function features set associated with the device.
136  */
137 uint8_t glcd_function_get(const struct device *port);
138 
139 
140 /* Available color selections */
141 #define GROVE_RGB_WHITE		0
142 #define GROVE_RGB_RED		1
143 #define GROVE_RGB_GREEN		2
144 #define GROVE_RGB_BLUE		3
145 /**
146  *  @brief Set LCD background to a predefined color
147  *  @param port Pointer to device structure for driver instance.
148  *  @param color One of the predefined color options
149  */
150 void glcd_color_select(const struct device *port, uint8_t color);
151 
152 
153 /**
154  *  @brief Set LCD background to custom RGB color value
155  *
156  *  @param port Pointer to device structure for driver instance.
157  *  @param r A numeric value for the red color (max is 255)
158  *  @param g A numeric value for the green color (max is 255)
159  *  @param b A numeric value for the blue color (max is 255)
160  */
161 void glcd_color_set(const struct device *port, uint8_t r, uint8_t g,
162 		    uint8_t b);
163 
164 
165 /**
166  *  @brief Initialize the Grove LCD panel
167  *
168  *  @param port Pointer to device structure for driver instance.
169  *
170  *  @return Returns 0 if all passes
171  */
172 int glcd_initialize(const struct device *port);
173 
174 
175 /**
176  * @}
177  */
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif /* ZEPHYR_INCLUDE_DISPLAY_GROVE_LCD_H_ */
184