-
Notifications
You must be signed in to change notification settings - Fork 0
/
node-blink1.d.ts
212 lines (188 loc) · 5.36 KB
/
node-blink1.d.ts
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
declare module 'node-blink1' {
/**
* blink(1) class definition
*/
export = Blink1;
/**
* Get list of blink(1) devices connected
*/
export function devices(): string[];
}
/**
* Declaration for blink(1) LED positions. blink(1) mk2 and mk3
* have support for independently addressable LED's
*
* 0 = All
* 1 = Top
* 2 = Bottom
*/
declare type LedIndex = 0 | 1 | 2;
/**
* Typescript types declaration for node-blink1
*/
declare class Blink1 {
/**
* Create blink(1) object with serial number, to get list of serial numbers use Blink1.devices().
* When no serial number is passed the first device will be used
*
* @param serial
*/
constructor(serial?: string);
/**
* Get version of blink(1) device which will
* be passed to the callback function
*
* @param callback
*/
version(callback: (version: number) => void): void;
/**
* Fade to RGB color
*
* @param fadeMillis Time in ms the transition takes
* @param r Red (0-255)
* @param g Green (0-255)
* @param b Blue (0-255)
* @param index
*/
fadeToRGB(fadeMillis: number, r: number, g: number, b: number, index?: LedIndex): void;
/**
* Fade to RGB color and execute callback function when transition
* has completed
*
* @param fadeMillis Time in ms the transition takes
* @param r Red (0-255)
* @param g Green (0-255)
* @param b Blue (0-255)
* @param index
* @param callback
*/
fadeToRGB(fadeMillis: number, r: number, g: number, b: number, index: LedIndex, callback?: () => void): void;
/**
* Set to RGB color and optionally execute callback function
* when transition has completed
*
* @param r Red (0-255)
* @param g Green (0-255)
* @param b Blue (0-255)
* @param callback
*/
setRGB(r, g, b, callback?: () => void): void;
/**
* Get current RGB values (mk2+ only) for a
* specific LED index and pass them to the callback function
*
* @param index
* @param callback
*/
rgb(index: LedIndex, callback: (r, g, b) => void): void;
/**
* Get current RGB values (mk2+ only) and pass them
* to the callback function. When no index is passed LedIndex.All
* will be used
*
* @param callback
*/
rgb(callback: (r, g, b) => void): void;
/**
* Turn blink(1) device off and call optional
* callback function when device is off
*
* @param callback
*/
off(callback?: () => void): void;
/**
* Disable/Enable gamma correction, default is true (enabled)
*/
enableDegamma: boolean;
/**
* Set server down and call optional callback after millis ms
*
* @param millis
* @param callback
*/
enableServerDown(millis: number, callback?: () => void): void;
/**
* Disable server down and call optional callback after millis ms
*
* @param millis
* @param callback
*/
disableServerDown(millis: number, callback?: () => void): void;
/**
* Start playing the pattern lines at the specified position
*
* @param position
* @param callback
*/
play(position: number, callback?: () => void): void;
/**
* Start playing a subset of the pattern lines at specified
* start and end positions
*
* @param startPosition
* @param endPosition
* @param count Specifying count = 0 will loop pattern forever
* @param callback
*/
playLoop(startPosition: number, endPosition: number, count: number, callback?: () => void): void;
/**
* Stop playing the pattern line
*
* @param callback
*/
pause(callback?: () => void): void;
/**
* Set the parameters for a pattern line, at the specified position
*
* @param fadeMillis Time in ms the transition takes
* @param r Red (0-255)
* @param g Green (0-255)
* @param b Blue (0-255)
* @param position
* @param callback
*/
writePatternLine(fadeMillis: number, r: number, g: number, b: number, position: number, callback?: () => void): void;
/**
* Set 'LedN' Set which LED to address for writePatternLine()
*
* @param index
*/
setLedN(index: LedIndex): void;
/**
* Save RAM pattern (to blink(1) non-volatile memory)
* Note: This command may return an error, but the command did succeed.
* This is because to save to its internal flash memory, the blink(1) must turn off USB for a moment
*
* @param callback
*/
savePattern(callback?: () => void): void;
/**
* Read pattern line (at the position)
*
* @param position
* @param callback
*/
readPatternLine(position, callback?: ({r: number, g: number, b: number, fadeMillis: number}) => void): void;
/**
* Write user note (to blink(1) non-volatile memory)
*
* @param noteId
* @param note
* @param callback
*/
writeNote(noteId: number, note: string, callback?: () => void): void;
/**
* Reads user note (from blink(1) non-volatile memory)
*
* @param noteId
* @param asString
* @param callback
*/
readNote(noteId: number, asString: boolean, callback?: (note: string) => void): void;
/**
* Close the underlying HID device
*
* @param callback
*/
close(callback?: () => void): void;
}