-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
60 lines (47 loc) · 1.25 KB
/
test.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
var Myo = require('myo');
var http = require("http");
var myMyo = Myo.create();
myMyo.on('connected', function(){
myMyo.unlock();
});
var options = {
hostname: "169.254.58.228",
port: 1337,
method: "GET"
};
myMyo.on('fist', function(edge){
if(!edge) return;
myMyo.unlock(30000);
console.log("fist == power off");
options.path = "/index?key=KEY_POWER";
var request = http.request(options, function(res) {});
request.end();
myMyo.vibrate();
});
myMyo.on('fingers_spread', function(edge){
if(!edge) return;
myMyo.unlock(30000);
console.log("spread == power on");
options.path = "/index?key=KEY_POWER";
var request = http.request(options, function(res) {});
request.end();
myMyo.vibrate();
});
myMyo.on('wave_in', function(edge){
if(!edge) return;
myMyo.unlock(30000);
console.log("wave_in == channel down");
options.path = "/index?key=KEY_CHANNELDOWN";
var request = http.request(options, function(res) {});
request.end();
myMyo.vibrate();
});
myMyo.on('wave_out', function(edge){
if(!edge) return;
myMyo.unlock(30000);
console.log("wave_out == channel up");
options.path = "/index?key=KEY_CHANNELUP";
var request = http.request(options, function(res) {});
request.end();
myMyo.vibrate();
});