forked from magicmonkey/lifxjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli3.js
63 lines (47 loc) · 1.02 KB
/
cli3.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
62
var lifx = require('./lifx');
var util = require('util');
var lx = lifx.init();
var stdin = process.openStdin();
process.stdin.setRawMode(true);
process.stdin.resume();
console.log("Control 2 lights independently: press numbers 1-8");
stdin.on('data', function (key) {
//process.stdout.write('Got key ' + util.inspect(key) + '\n');
switch (key[0]) {
case 0x31: // 1
console.log("Lights on");
lx.lightsOn();
break;
case 0x32: // 2
console.log("Lights off");
lx.lightsOff();
break;
case 0x33: // 3
console.log(util.inspect(lx));
break;
case 0x34: // 4
lx.lightsOn(lx.bulbs[0]);
break;
case 0x35: // 5
lx.lightsOff(lx.bulbs[0]);
break;
case 0x36: // 6
lx.lightsOn(lx.bulbs[1]);
break;
case 0x37: // 7
lx.lightsOff(lx.bulbs[1]);
break;
case 0x38: // 8
console.log(lx.bulbs);
break;
case 0x39: // 9
lx.findBulbs();
break;
case 0x03: // ctrl-c
console.log("Closing...");
lx.close();
process.stdin.pause();
//process.exit();
break;
}
});