forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
neurosky.go
57 lines (50 loc) · 1.41 KB
/
neurosky.go
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
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/neurosky"
)
func main() {
gbot := gobot.NewGobot()
adaptor := neurosky.NewNeuroskyAdaptor("neurosky", "/dev/rfcomm0")
neuro := neurosky.NewNeuroskyDriver(adaptor, "neuro")
work := func() {
gobot.On(neuro.Event("extended"), func(data interface{}) {
fmt.Println("Extended", data)
})
gobot.On(neuro.Event("signal"), func(data interface{}) {
fmt.Println("Signal", data)
})
gobot.On(neuro.Event("attention"), func(data interface{}) {
fmt.Println("Attention", data)
})
gobot.On(neuro.Event("meditation"), func(data interface{}) {
fmt.Println("Meditation", data)
})
gobot.On(neuro.Event("blink"), func(data interface{}) {
fmt.Println("Blink", data)
})
gobot.On(neuro.Event("wave"), func(data interface{}) {
fmt.Println("Wave", data)
})
gobot.On(neuro.Event("eeg"), func(data interface{}) {
eeg := data.(neurosky.EEG)
fmt.Println("Delta", eeg.Delta)
fmt.Println("Theta", eeg.Theta)
fmt.Println("LoAlpha", eeg.LoAlpha)
fmt.Println("HiAlpha", eeg.HiAlpha)
fmt.Println("LoBeta", eeg.LoBeta)
fmt.Println("HiBeta", eeg.HiBeta)
fmt.Println("LoGamma", eeg.LoGamma)
fmt.Println("MidGamma", eeg.MidGamma)
fmt.Println("\n")
})
}
robot := gobot.NewRobot("brainBot",
[]gobot.Connection{adaptor},
[]gobot.Device{neuro},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}