-
Notifications
You must be signed in to change notification settings - Fork 1
/
rainbowstripes.ts
50 lines (40 loc) · 1.21 KB
/
rainbowstripes.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
import * as Keychron from '../src/keychron';
const keyboard = new Keychron.Keychron();
async function main() {
await keyboard.setDirectMode();
const Strip: Keychron.Color[] = [];
for (const key of Keychron.Grid) {
const {x, y} = key.position;
switch (Math.floor(y) % 6) {
case 0:
// Red
Strip[key.id] = {r: 255, g: 0, b: 0};
break;
case 1:
// Orange
Strip[key.id] = {r: 255, g: 90, b: 0};
break;
case 2:
// Yellow
Strip[key.id] = {r: 255, g: 180, b: 0};
break;
case 3:
// Green
Strip[key.id] = {r: 0, g: 128, b: 0};
break;
case 4:
// Blue
Strip[key.id] = {r: 0, g: 0, b: 255};
break;
case 5:
// Purple
Strip[key.id] = {r: 75, g: 0, b: 130};
break;
}
}
await keyboard.setStrip(Strip);
await new Promise(resolve => setTimeout(resolve, 5000));
await keyboard.setKeyboardMode();
await keyboard.close();
}
main();