-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
executable file
·41 lines (34 loc) · 786 Bytes
/
example.js
File metadata and controls
executable file
·41 lines (34 loc) · 786 Bytes
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
var Mindwave = require('./index.js');
var kefir = require('kefir')
var mw = new Mindwave();
function toObj (objs) {
return objs.reduce(function (acc,o) {
var k = Object.keys(o)[0]
acc[k] = o[k]
return acc
}, {})
}
function prop (p) {
return (v) => {
var r = {}
r[p] = v
return r
}
}
function asProp (ev) {
return kefir.fromEvents(mw, ev).map(prop(ev))
}
var waveS = kefir.fromEvents(mw, 'wave').bufferWithCount(256).map(prop('wave'))
var outS = kefir.zip([
asProp('wave'),
asProp('eeg'),
asProp('signal'),
asProp('meditation'),
asProp('attention'),
//waveS,
]).map(toObj)
console.log('connecting')
//mw.connect('/dev/cu.MindWaveMobile-DevA');
//mw.connect('/dev/cu.MindWaveMobile-SerialPo', 57600);
mw.connect('', 57600);
outS.log()