diff --git a/platforms/neurosky/neurosky_adaptor.go b/platforms/neurosky/neurosky_adaptor.go index f836e13a..222da413 100644 --- a/platforms/neurosky/neurosky_adaptor.go +++ b/platforms/neurosky/neurosky_adaptor.go @@ -7,10 +7,11 @@ import ( "github.com/tarm/goserial" ) -var _ gobot.AdaptorInterface = (*NeuroskyAdaptor)(nil) +var _ gobot.Adaptor = (*NeuroskyAdaptor)(nil) type NeuroskyAdaptor struct { - gobot.Adaptor + name string + port string sp io.ReadWriteCloser connect func(*NeuroskyAdaptor) (err error) } @@ -18,11 +19,8 @@ type NeuroskyAdaptor struct { // NewNeuroskyAdaptor creates a neurosky adaptor with specified name func NewNeuroskyAdaptor(name string, port string) *NeuroskyAdaptor { return &NeuroskyAdaptor{ - Adaptor: *gobot.NewAdaptor( - name, - "NeuroskyAdaptor", - port, - ), + name: name, + port: port, connect: func(n *NeuroskyAdaptor) (err error) { sp, err := serial.OpenPort(&serial.Config{Name: n.Port(), Baud: 57600}) if err != nil { @@ -33,6 +31,8 @@ func NewNeuroskyAdaptor(name string, port string) *NeuroskyAdaptor { }, } } +func (n *NeuroskyAdaptor) Name() string { return n.name } +func (n *NeuroskyAdaptor) Port() string { return n.port } // Connect returns true if connection to device is successful func (n *NeuroskyAdaptor) Connect() (errs []error) { diff --git a/platforms/neurosky/neurosky_driver.go b/platforms/neurosky/neurosky_driver.go index 42f7b641..7e1afedf 100644 --- a/platforms/neurosky/neurosky_driver.go +++ b/platforms/neurosky/neurosky_driver.go @@ -6,7 +6,7 @@ import ( "github.com/hybridgroup/gobot" ) -var _ gobot.DriverInterface = (*NeuroskyDriver)(nil) +var _ gobot.Driver = (*NeuroskyDriver)(nil) const BTSync byte = 0xAA @@ -32,7 +32,9 @@ const CodeWave byte = 0x80 const CodeAsicEEG byte = 0x83 type NeuroskyDriver struct { - gobot.Driver + name string + connection gobot.Connection + gobot.Eventer } type EEG struct { @@ -58,11 +60,9 @@ type EEG struct { // eeg - showing eeg data func NewNeuroskyDriver(a *NeuroskyAdaptor, name string) *NeuroskyDriver { n := &NeuroskyDriver{ - Driver: *gobot.NewDriver( - name, - "NeuroskyDriver", - a, - ), + name: name, + connection: a, + Eventer: gobot.NewEventer(), } n.AddEvent("extended") @@ -76,10 +76,12 @@ func NewNeuroskyDriver(a *NeuroskyAdaptor, name string) *NeuroskyDriver { return n } +func (n *NeuroskyDriver) Connection() gobot.Connection { return n.connection } +func (n *NeuroskyDriver) Name() string { return n.name } // adaptor returns neurosky adaptor func (n *NeuroskyDriver) adaptor() *NeuroskyAdaptor { - return n.Adaptor().(*NeuroskyAdaptor) + return n.Connection().(*NeuroskyAdaptor) } // Start creates a go routine to listen from serial port