2014-04-26 18:11:51 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-07-11 08:21:21 +08:00
|
|
|
|
2014-04-26 18:11:51 +08:00
|
|
|
"github.com/hybridgroup/gobot"
|
2014-05-23 11:43:00 +08:00
|
|
|
"github.com/hybridgroup/gobot/platforms/neurosky"
|
2014-04-26 18:11:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-05-23 11:43:00 +08:00
|
|
|
gbot := gobot.NewGobot()
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-05-23 11:43:00 +08:00
|
|
|
adaptor := neurosky.NewNeuroskyAdaptor("neurosky", "/dev/rfcomm0")
|
|
|
|
neuro := neurosky.NewNeuroskyDriver(adaptor, "neuro")
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
work := func() {
|
2014-07-09 09:36:14 +08:00
|
|
|
gobot.On(neuro.Event("extended"), func(data interface{}) {
|
2014-04-26 18:11:51 +08:00
|
|
|
fmt.Println("Extended", data)
|
|
|
|
})
|
2014-07-09 09:36:14 +08:00
|
|
|
gobot.On(neuro.Event("signal"), func(data interface{}) {
|
2014-04-26 18:11:51 +08:00
|
|
|
fmt.Println("Signal", data)
|
|
|
|
})
|
2014-07-09 09:36:14 +08:00
|
|
|
gobot.On(neuro.Event("attention"), func(data interface{}) {
|
2014-04-26 18:11:51 +08:00
|
|
|
fmt.Println("Attention", data)
|
|
|
|
})
|
2014-07-09 09:36:14 +08:00
|
|
|
gobot.On(neuro.Event("meditation"), func(data interface{}) {
|
2014-04-26 18:11:51 +08:00
|
|
|
fmt.Println("Meditation", data)
|
|
|
|
})
|
2014-07-09 09:36:14 +08:00
|
|
|
gobot.On(neuro.Event("blink"), func(data interface{}) {
|
2014-04-26 18:11:51 +08:00
|
|
|
fmt.Println("Blink", data)
|
|
|
|
})
|
2014-07-09 09:36:14 +08:00
|
|
|
gobot.On(neuro.Event("wave"), func(data interface{}) {
|
2014-04-26 18:11:51 +08:00
|
|
|
fmt.Println("Wave", data)
|
|
|
|
})
|
2014-07-09 09:36:14 +08:00
|
|
|
gobot.On(neuro.Event("eeg"), func(data interface{}) {
|
2014-06-11 06:16:11 +08:00
|
|
|
eeg := data.(neurosky.EEG)
|
2014-04-26 18:11:51 +08:00
|
|
|
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")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-09 09:36:14 +08:00
|
|
|
robot := gobot.NewRobot("brainBot",
|
|
|
|
[]gobot.Connection{adaptor},
|
|
|
|
[]gobot.Device{neuro},
|
|
|
|
work,
|
|
|
|
)
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-07-09 09:36:14 +08:00
|
|
|
gbot.AddRobot(robot)
|
2014-05-23 11:43:00 +08:00
|
|
|
gbot.Start()
|
2014-04-26 18:11:51 +08:00
|
|
|
}
|