neurosky

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2018 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 0

README

Neurosky

NeuroSky delivers fully integrated, single chip EEG biosensors. NeuroSky enables its partners and developers to bring their brainwave application ideas to market with the shortest amount of time, and lowest end consumer price.

This package contains the Gobot adaptor and driver for the Neurosky Mindwave Mobile EEG.

How to Install

Installing Gobot with Neurosky support is pretty easy.

go get -d -u gobot.io/x/gobot/...

How To Connect

OSX

In order to allow Gobot running on your Mac to access the Mindwave, go to "Bluetooth > Open Bluetooth Preferences > Sharing Setup" and make sure that "Bluetooth Sharing" is checked.

Now you must pair with the Mindwave. Open System Preferences > Bluetooth. Now with the Bluetooth devices windows open, hold the On/Pair button on the Mindwave towards the On/Pair text until you see "Mindwave" pop up as available devices. Pair with that device. Once paired your Mindwave will be accessable through the serial device similarly named as /dev/tty.MindWaveMobile-DevA

Ubuntu

Connecting to the Mindwave from Ubuntu or any other Linux-based OS can be done entirely from the command line using Gort CLI commands. Here are the steps.

Find the address of the Mindwave, by using:

gort scan bluetooth

Pair to Mindwave using this command (substituting the actual address of your Mindwave):

gort bluetooth pair <address>

Connect to the Mindwave using this command (substituting the actual address of your Mindwave):

gort bluetooth connect <address>
Windows

You should be able to pair your Mindwave using your normal system tray applet for Bluetooth, and then connect to the COM port that is bound to the device, such as COM3.

How to Use

This small program lets you connect the Neurosky an load data.

package main

import (
	"fmt"

	"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)
			fmt.Println("\n")
		})
	}

	robot := gobot.NewRobot("brainBot",
		[]gobot.Connection{adaptor},
		[]gobot.Device{neuro},
		work,
	)

	robot.Start()
}

Documentation

Overview

Package neurosky contains the Gobot adaptor and driver for the Neurosky Mindwave Mobile EEG.

Installing:

go get gobot.io/x/gobot/platforms/neurosky

Example:

package main

import (
	"fmt"

	"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)
			fmt.Println("\n")
		})
	}

	robot := gobot.NewRobot("brainBot",
		[]gobot.Connection{adaptor},
		[]gobot.Device{neuro},
		work,
	)

	robot.Start()
}

For further information refer to neuroky README: https://github.com/hybridgroup/gobot/blob/master/platforms/neurosky/README.md

Package neurosky is the Gobot platform for the Neurosky Mindwave EEG

Index

Constants

View Source
const (
	// BTSync is the sync code
	BTSync byte = 0xAA

	// CodeEx Extended code
	CodeEx byte = 0x55

	// CodeSignalQuality POOR_SIGNAL quality 0-255
	CodeSignalQuality byte = 0x02

	// CodeAttention ATTENTION eSense 0-100
	CodeAttention byte = 0x04

	// CodeMeditation MEDITATION eSense 0-100
	CodeMeditation byte = 0x05

	// CodeBlink BLINK strength 0-255
	CodeBlink byte = 0x16

	// CodeWave RAW wave value: 2-byte big-endian 2s-complement
	CodeWave byte = 0x80

	// CodeAsicEEG ASIC EEG POWER 8 3-byte big-endian integers
	CodeAsicEEG byte = 0x83

	// Extended event
	Extended = "extended"

	// Signal event
	Signal = "signal"

	// Attention event
	Attention = "attention"

	// Meditation event
	Meditation = "meditation"

	// Blink event
	Blink = "blink"

	// Wave event
	Wave = "wave"

	// EEG event
	EEG = "eeg"

	// Error event
	Error = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptor added in v1.0.0

type Adaptor struct {
	// contains filtered or unexported fields
}

Adaptor is the Gobot Adaptor for the Neurosky Mindwave

func NewAdaptor added in v1.0.0

func NewAdaptor(port string) *Adaptor

NewAdaptor creates a neurosky adaptor with specified port

func (*Adaptor) Connect added in v1.0.0

func (n *Adaptor) Connect() error

Connect returns true if connection to device is successful

func (*Adaptor) Finalize added in v1.0.0

func (n *Adaptor) Finalize() (err error)

Finalize returns true if device finalization is successful

func (*Adaptor) Name added in v1.0.0

func (n *Adaptor) Name() string

Name returns the Adaptor Name

func (*Adaptor) Port added in v1.0.0

func (n *Adaptor) Port() string

Port returns the Adaptor port

func (*Adaptor) SetName added in v1.0.0

func (n *Adaptor) SetName(name string)

SetName sets the Adaptor Name

type Driver added in v1.0.0

type Driver struct {
	gobot.Eventer
	// contains filtered or unexported fields
}

Driver is the Gobot Driver for the Mindwave

func NewDriver added in v1.0.0

func NewDriver(a *Adaptor) *Driver

NewDriver creates a Neurosky Driver and adds the following events:

extended - user's current extended level
signal - shows signal strength
attention - user's current attention level
meditation - user's current meditation level
blink - user's current blink level
wave - shows wave data
eeg - showing eeg data

func (*Driver) Connection added in v1.0.0

func (n *Driver) Connection() gobot.Connection

Connection returns the Driver's connection

func (*Driver) Halt added in v1.0.0

func (n *Driver) Halt() (err error)

Halt stops neurosky driver (void)

func (*Driver) Name added in v1.0.0

func (n *Driver) Name() string

Name returns the Driver name

func (*Driver) SetName added in v1.0.0

func (n *Driver) SetName(name string)

SetName sets the Driver name

func (*Driver) Start added in v1.0.0

func (n *Driver) Start() (err error)

Start creates a go routine to listen from serial port and parse buffer readings

type EEGData added in v1.0.0

type EEGData struct {
	Delta    int
	Theta    int
	LoAlpha  int
	HiAlpha  int
	LoBeta   int
	HiBeta   int
	LoGamma  int
	MidGamma int
}

EEGData is the EEG raw data returned from the Mindwave

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL