aboutsummaryrefslogtreecommitdiff
path: root/docs/grove_lcd.md
blob: 3b764b4b5668d9e337aac27e4359710daa37889d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
Zephyr.js API for Grove LCD
===========================

* [Introduction](#introduction)
* [Web IDL](#web-idl)
* [API Documentation](#api-documentation)
* [Sample Apps](#sample-apps)

Introduction
------------
The Grove LCD API is the JavaScript version of the Zephyr API that supports the
Grove LCD.  It works over I2C to allow user to send text to the LCD screen
and also configure LCD to different RGB backlight colors.

Web IDL
-------
This IDL provides an overview of the interface; see below for documentation of
specific API functions.

```javascript
// require returns a GroveLCD object
// var grove_lcd = require('grove_lcd');

[NoInterfaceObject]
interface GroveLCD {
    GroveLCDDevice init();
    unsigned long GLCD_FS_8BIT_MODE;
    unsigned long GLCD_FS_ROWS_2;
    unsigned long GLCD_FS_ROWS_1;
    unsigned long GLCD_FS_DOT_SIZE_BIG;
    unsigned long GLCD_FS_DOT_SIZE_LITTLE;

    unsigned long GLCD_DS_DISPLAY_ON;
    unsigned long GLCD_DS_DISPLAY_OFF;
    unsigned long GLCD_DS_CURSOR_ON;
    unsigned long GLCD_DS_CURSOR_OFF;
    unsigned long GLCD_DS_BLINK_ON;
    unsigned long GLCD_DS_BLINK_OFF;

    unsigned long GLCD_IS_SHIFT_INCREMENT;
    unsigned long GLCD_IS_SHIFT_DECREMENT;
    unsigned long GLCD_IS_ENTRY_LEFT;
    unsigned long GLCD_IS_ENTRY_RIGHT;

    unsigned long GROVE_RGB_WHITE;
    unsigned long GROVE_RGB_RED;
    unsigned long GROVE_RGB_GREEN;
    unsigned long GROVE_RGB_BLUE;
};

[NoInterfaceObject]
interface GroveLCDDevice {
    void print(string text);
    void clear();
    void setCursorPos(unsigned long col, unsigned long row);
    void selectColor(unsigned long index);
    void setColor(unsigned long r, unsigned long g, unsigned long b);
    void setFunction(unsigned long config);
    unsigned long getFunction();
    void setDisplayState(unsigned long config);
    unsigned long getDisplayState();
    void setInputState(unsigned long config);
    unsigned long getInputState();
};
```

API Documentation
-----------------
### GroveLCD.init

`GroveLCDDevice init();`

Initialize the Grove LCD panel

*NOTE: Zephyr's Grove LCD API is on top of the I2C which is only accessible
from the ARC side on the Arduino 101, so all the API in here will use the
IPM to send commands over to the API, and all the API will be synchronous*

The function returns a GroveLCDDevice object instance that can be used to
talk to the Grove LCD panel.

### GroveLCDDevice.print

`void print(string text);`

Send text to the screen on the current line cursor is set to,
if the text is longer than number of characters it can fit on that line,
any additional characters will not wrap around and be dropped,
so a 16x2 LCD will have a maximum of 16 characters.

### GroveLCDDevice.clear

`void clear();`

Clear the current display.

### GroveLCDDevice.setCursorPos

`void setCursorPos(unsigned long col, unsigned long row);`

Set text cursor position for next additions.
The `col` is the column for the cursor to be moved to (0-15).
The `row` is the row it should be moved to (0 or 1).

### GroveLCDDevice.selectColor

`void selectColor(unsigned long index);`

Set LCD background to a predfined color.

The `index` should be a one of the following color selections:

GroveLCD.GROVE_RGB_WHITE

GroveLCD.GROVE_RGB_RED

GroveLCD.GROVE_RGB_GREEN

GroveLCD.long GROVE_RGB_BLUE

### GroveLCDDevice.setColor

`void setColor(unsigned long r, unsigned long g, unsigned long b);`

Set LCD background to custom RGB color value

The `r` is a numeric value for the red color (max is 255).
The `g` is a numeric value for the green color (max is 255).
The `b` is a numeric value for the blue color (max is 255).

### GroveLCDDevice.setFunction

`void setFunction(unsigned long config);`

This function provides the user the ability to change the state
of the display, controlling things like the number of rows,
dot size, and text display quality.

The `config` is bit mask of the following configurations:

GroveLCD.GLCD_FS_8BIT_MODE

GroveLCD.GLCD_FS_ROWS_2

GroveLCD.GLCD_FS_ROWS_1

GroveLCD.GLCD_FS_DOT_SIZE_BIG

GroveLCD.GLCD_FS_DOT_SIZE_LITTLE

### GroveLCDDevice.getFunction

`unsigned long getFunction();`

Return the function features set associated with the device.

### GroveLCDDevice.setDisplayState

`void setDisplayState(unsigned long config);`

This function provides the user the ability to change the state
of the display, controlling things like powering on or off
the screen, the option to display the cursor or not, and the ability to
blink the cursor.

The `config` is bit mask of the following configurations:

GroveLCD.GLCD_DS_DISPLAY_ON

GroveLCD.GLCD_DS_DISPLAY_OFF

GroveLCD.GLCD_DS_CURSOR_ON

GroveLCD.GLCD_DS_CURSOR_OFF

GroveLCD.GLCD_DS_BLINK_ON

GroveLCD.GLCD_DS_BLINK_OFF

### GroveLCDDevice.getDisplayState

`unsigned long getDisplayState();`

Return the display feature set associated with the device.

### GroveLCDDevice.setInputState

`void setInputState(unsigned long config);`

This function provides the user the ability to change the state
of the text input. Controlling things like text entry from the left or
right side, and how far to increment on new text.

The `config` is bit mask of the following configurations:

GroveLCD.GLCD_IS_SHIFT_INCREMENT

GroveLCD.GLCD_IS_SHIFT_DECREMENT

GroveLCD.GLCD_IS_ENTRY_LEFT

GroveLCD.GLCD_IS_ENTRY_RIGHT

### GroveLCDDevice.getInputState

`unsigned long getInputState();`

Return the input set associated with the device.

Sample Apps
-----------
* Grove LCD only
  * [Grove LCD sample](../samples/GroveLCD.js)
* Demos
  * [WebBluetooth Grove LCD Demo](../samples/WebBluetoothGroveLcdDemo.js)
  * [Heart Rate Demo](../samples/HeartRateDemo.js)