hybridgroup.gobot/examples/neurosky.go

59 lines
1.4 KiB
Go
Raw Normal View History

// +build example
//
// Do not build by default.
package main
import (
"fmt"
2014-07-11 08:21:21 +08:00
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/neurosky"
)
func main() {
adaptor := neurosky.NewAdaptor("/dev/rfcomm0")
neuro := neurosky.NewDriver(adaptor)
work := func() {
neuro.On(neuro.Event("extended"), func(data interface{}) {
fmt.Println("Extended", data)
})
neuro.On(neuro.Event("signal"), func(data interface{}) {
fmt.Println("Signal", data)
})
neuro.On(neuro.Event("attention"), func(data interface{}) {
fmt.Println("Attention", data)
})
neuro.On(neuro.Event("meditation"), func(data interface{}) {
fmt.Println("Meditation", data)
})
neuro.On(neuro.Event("blink"), func(data interface{}) {
fmt.Println("Blink", data)
})
neuro.On(neuro.Event("wave"), func(data interface{}) {
fmt.Println("Wave", data)
})
neuro.On(neuro.Event("eeg"), func(data interface{}) {
eeg := data.(neurosky.EEGData)
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)
2016-07-14 01:21:17 +08:00
fmt.Printf("\n\n")
})
}
2014-07-09 09:36:14 +08:00
robot := gobot.NewRobot("brainBot",
[]gobot.Connection{adaptor},
[]gobot.Device{neuro},
work,
)
robot.Start()
}