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