-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathchroma_example.js
62 lines (48 loc) · 940 Bytes
/
chroma_example.js
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
var Chroma = require('./');
var init = Chroma.InitChroma();
var current_col=0;
var grow=true;
var interval;
var customGrid = [];
for(var r=0; r<6; r++){
customGrid[r]=[];
for(var c=0; c<22; c++){
customGrid[r][c]={
Red: 0,
Green: 0,
Blue: 0
};
}
}
if(init){
console.log("Successfully initialized.");
interval = setInterval(function(){
var color = {
Red: current_col,
Green: 0,
Blue: 0
};
for(var r=0; r<6; r++){
for(var c=0; c<22; c++){
customGrid[r][c]=color;
}
}
Chroma.Keyboard.SetCustom(customGrid);
if(grow) current_col++;
else current_col--;
if(current_col>255){
current_col=255;
grow=false;
}
if(current_col<0){
current_col=0;
grow=true;
}
},10);
setTimeout(function(){
clearInterval(interval);
console.log(Chroma.UnInitChroma());
console.log("Closing");
},30000);
}
else console.log("Couldn't initalize SDK");