ThinkGear Development Guide For Android Think Gear
User Manual:
Open the PDF directly: View PDF
.
Page Count: 31
| Download | |
| Open PDF In Browser | View PDF |
ThinkGear Development Guide for Android December 14, 2012 e NeuroSky® product families consist of hardware and software components for simple integration of this biosensor technology into consumer and industrial end-applications. All products are designed and manufactured to meet consumer thresholds for quality, pricing, and feature sets. NeuroSky sets itself apart by providing building block component solutions that offer friendly synergies with related and complementary technological solutions. NO WARRANTIES: THE NEUROSKY PRODUCT FAMILIES AND RELATED DOCUMENTATION IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT OF INTELLECTUAL PROPERTY, INCLUDING PATENTS, COPYRIGHTS OR OTHERWISE, OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT SHALL NEUROSKY OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, COST OF REPLACEMENT GOODS OR LOSS OF OR DAMAGE TO INFORMATION) ARISING OUT OF THE USE OF OR INABILITY TO USE THE NEUROSKY PRODUCTS OR DOCUMENTATION PROVIDED, EVEN IF NEUROSKY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. , SOME OF THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU BECAUSE SOME JURISDICTIONS PROHIBIT THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES. USAGE OF THE NEUROSKY PRODUCTS IS SUBJECT OF AN END-USER LICENSE AGREEMENT. “Made for iPod,” “Made for iPhone,” and “Made for iPad” mean that an electronic accessory has been designed to connect specifically to iPod, iPhone, or iPad, respectively, and has been certified by the developer to meet Apple performance standards. Apple is not responsible for the operation of this device or its compliance with safety and regulatory standards. Please note that the use of this accessory with iPod, iPhone, or iPad may affect wireless performance. Contents Introduction inkGear SDK for Android Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . Supported inkGear Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4 4 Your First Project: HelloEEG 6 Developing Your Own inkGear-enabled Apps for Android Preparing Your Android Project . . . . . . . . . . . . . . . . Creating the TGDevice Object . . . . . . . . . . . . . . . . Receiving and Handling Data Messages . . . . . . . . . . . . TGDevice Message Types (msg.what) . . . . . . . . . . TGDevice States . . . . . . . . . . . . . . . . . . . . . Using the TGDevice Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 7 7 8 9 12 12 inkGear Data Types General . . . . . . . . . . . . . . . . . . . . . POOR_SIGNAL/SENSOR_STATUS . RAW_DATA . . . . . . . . . . . . . . . RAW_MULTI . . . . . . . . . . . . . . EEG . . . . . . . . . . . . . . . . . . . . . . . ATTENTION . . . . . . . . . . . . . . MEDITATION . . . . . . . . . . . . . BLINK . . . . . . . . . . . . . . . . . . EEG_POWER . . . . . . . . . . . . . . THINKCAP_RAW . . . . . . . . . . . POSITIVITY . . . . . . . . . . . . . . FAMILIARITY . . . . . . . . . . . . . DIFFICULTY . . . . . . . . . . . . . . ECG/EKG . . . . . . . . . . . . . . . . . . . HEART_RATE . . . . . . . . . . . . . Smoothed Heart Rate . . . . . . . . . . Heart Rate Acceleration . . . . . . . . . Target Heart Rate for Physical Training . Heart Fitness Level . . . . . . . . . . . . RELAXATION . . . . . . . . . . . . . RESPIRATION . . . . . . . . . . . . . Heart Risk Awareness . . . . . . . . . . HEART_AGE . . . . . . . . . . . . . . Personalization . . . . . . . . . . . . . . EKG_RRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 14 14 15 15 15 15 16 16 17 17 17 17 17 17 17 18 18 18 19 20 20 21 22 24 25 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Proper App Design 26 Troubleshooting 27 Important Notices 28 3 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 0 – APPENDIX A: Additional References 29 APPENDIX B: UART (Non-Bluetooth) Connections 30 4 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 1 Introduction is guide will teach you how to use NeuroSky's inkGear SDK for Android to write Android apps that can utilize bio-signal data from NeuroSky's inkGear family of bio-sensors (which includes the CardioChip family of products). is will enable your Android apps to receive and use bio-signal data such as EEG and ECG/EKG acquired from NeuroSky's sensor hardware. is guide (and the entire inkGear SDK for Android for that matter) is intended for programmers who are already familiar with standard Android development using Eclipse and Google's AndroidSDK. If you are not already familiar with developing for Android, please rst visit http://developer.android.com to learn how to set up your Eclipse+AndroidSDK development environment and create typical Android apps. If you are already familiar with creating typical Android apps, then the next step is to make sure you have downloaded NeuroSky's inkGear SDK for Android. Chances are, if you're reading this document, then you already have it. If not, the SDK can be downloaded from http://store.neurosky.com/products/developer-tools-3-android. ThinkGear SDK for Android Contents • inkGear SDK for Android: Development Guide (this document) • inkGear SDK for Android: API Reference • inkGearBase.jar library • inkGearPackX.jar library • HelloEEG example inkGear project for Android • HelloEKG example inkGear project for Android You'll nd the "API Reference" in the reference/ folder of the TG-SDK, the "inkGearBase.jar" and "inkGearPackX.jar" in the lib/ folder, and the "HelloEEG and HelloEKG example projects" in the Sample Projects/ folder. Supported ThinkGear Hardware e inkGear SDK for Android must be used with a inkGear-compatible hardware sensor device. e following inkGear-compatible hardware devices are currently supported: • MindWave Mobile • MindBand • MindTune 5 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 1 – Introduction • MindSet • inkCap 1.0 • BrainAthlete • CardioChip Starter Kit Unit Important: Before using any Android app that uses the TG-SDK for Android, make sure you have paired the inkGear sensor hardware to your Android device by carefully following the instructions in the User Manual that came with each inkGear hardware device! Supported ThinkGear Hardware December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 6 Chapter 2 Your First Project: HelloEEG HelloEEG is a sample project we've included in the inkGear SDK for Android that demonstrates how to setup, connect, and handle data to a inkGear device. Add the project to your Eclipse IDE by following these steps. (Tested with Eclipse IDE for Java Developers Version: Juno Service Release 1 on Mac OS 10.8.2) 1. In Eclipse, select File > New > Project… 2. In the New Project wizard, expand the Android section and select Android Project from Existing Code and click Next 3. Click on Browse… and locate the HelloEEG project folder in the Sample Projects folder and click Open 4. Click the checkbox for Copy projects to workspace and click Finish 5. Click Finish to exit the wizard. 6. Have your Android device connected to your computer. 7. At this point, you should be able to browse the code, make modi cations, compile, and deploy the app to your device or emulator just like any typical Android app. Note: If there are problems, try the following: • Right-click on the project and select Properties. Click on the Android section and make sure a build target of at least Android 2.3.3 is selected. • Before trying to connect, make sure you have paired your inkGear hardware device to your Android device via your Android device's Bluetooth settings! • In Eclipse's Package Explorer, expand the libs/ folder of your project, right-click (or Ctrl-click for Mac users) on inkGearBase.jar, and select Build Path > Add to Build Path ALSO add the inkGearPackX.jar that is in the folder. • Check the Eclipse! Run! Run Con gurations.. to make sure the application is running on the correct device. On the Target tab you can pick "Always prompt to pick device". • Take a look in the Eclipse Console, sometimes it indicates that it needs to be restarted, so exit Eclipse and restart it. • If you see the message e selection cannot be launched, and there are no recent launches." en right click on the project in the Package or Project Explorer, choose "Run As"and pick "Android Application". en try to Run again. You may use this same process to build the HelloEKG sample project. 7 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 3 Developing Your Own ThinkGear-enabled Apps for Android Preparing Your Android Project • First, make sure the "Android build target" for your project is at least Android 2.3.3. 1. Right-click on your project and select Properties. 2. Click on the Android section and make sure a build target of at least Android 2.3.3 is selected. • en, you must add the ThinkGearBase.jar and ThinkGearPackX.jarlibrary les to your project: 1. With your Android project open in Eclipse, use the Package Explorer in Eclipse to create a lib folder at the root folder of your project 2. Use Windows Explorer (or Finder on Mac) to copy the ThinkGear jar les from the lib folder of your TG-SDK for Android to your Eclipse project's lib folder. 3. In the Eclipse Package Explorer, right-click (Ctrl-click for Mac users) on ThinkGearBase.jar select Build Path » Add to build path. ALSO add the ThinkGearPackX.jar • Assuming your app will be connecting to the inkGear hardware device via bluetooth, you will need to enable the BLUETOOTH permission in your app's manifest le:Creating the TGDevice Object A TGDevice object is used to manage a single connection to a single inkGear hardware device. is guide will only cover the most common connecting case, which is where your Android app will be connecting to the inkGear hardware device via standard Android Bluetooth using the TGDevice(BluetoothAdapter, Handler) constructor. (e alternate TGDevice(InputStream, OutputStream, Handler) constructor should only be used for special, uncommon use cases). • Import the following packages into your Activity: import com.neurosky.thinkgear.*; import com.android.bluetooth.*; import com.android.util.Log; 8 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 3 – Developing Your Own ThinkGear-enabled Apps for Android • Declare a TGDevice object and a BluetoothAdapter object in your Activity: public class HelloEEGActivity extends Activity { //... TGDevice tgDevice = null; BluetoothAdapter btAdapter = null; //... • Initialize the btAdapter and tgDevice in the onCreate() method: public void onCreate(Bundle savedInstanceState) { //... btAdapter = BluetoothAdapter.getDefaultAdapter(); if( btAdapter != null ) { tgDevice = new TGDevice( btAdapter, handler ); } //... } Note: We'll discuss the handler object in the next section. Receiving and Handling Data Messages e TGDevice will communicate to your app via messages sent to a Handler object. To create a Handler object in your app to process incoming data: private final Handler handler = new Handler() { @Override public void handleMessage( Message msg ) { switch( msg.what ) { case TGDevice.MSG_STATE_CHANGE: switch( msg.arg1 ) { case TGDevice.STATE_IDLE: break; case TGDevice.STATE_ERR_BT_OFF: break; case TGDevice.STATE_CONNECTING: break; case TGDevice.STATE_ERR_NO_DEVICE: break; case TGDevice.STATE_NOT_FOUND: break; case TGDevice.STATE_CONNECTED: device.start(); break; case TGDevice.STATE_DISCONNECTED: break; default: break; } /* end switch on state change type */ break; Receiving and Handling Data Messages December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 9 Chapter 3 – Developing Your Own ThinkGear-enabled Apps for Android case TGDevice.POOR_SIGNAL: Log.v( "HelloEEG", "PoorSignal: " + msg.arg1 ); break; case TGDevice.MSG_ATTENTION: Log.v( "HelloEEG", "Attention: " + msg.arg1 ); break; case TGDevice.MSG_RAW_DATA: int rawValue = msg.arg1; break; case TGDevice.MSG_EEG_POWER: TGEegPower ep = (TGEegPower)msg.obj; Log.v( "HelloEEG", "Delta: " + ep.delta ); break; default: break; } /* end switch on message type */ } /* end handleMessage() */ }; /* end Handler */ e type of each Message is determined by examining the value of msg.what, while the actual data value for the Message is available from either msg.arg1 (for simple values) or msg.obj (for more complex values). TGDevice Message Types (msg.what) msg.what MSG_STATE_CHANGE Description e TGDevice changed state MSG_POOR_SIGNAL Bio-signal quality/status MSG_RAW_DATA Raw sample value MSG_RAW_MULTI Multi-channel raw values Receiving and Handling Data Messages December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. has Data e state change info is stored in the arg1 eld of the Message (see TGDevice States table below) e status or quality of the biosignal is stored in the arg1 eld of the Message e single-channel raw sample value (most inkGear devices) is stored as an int in the arg1 eld of the Message e multi-channel raw sample data (only available from certain inkGear devices) are stored as a TGRawMulti object in the obj eld of the Message 10 Chapter 3 – Developing Your Own ThinkGear-enabled Apps for Android msg.what MSG_ATTENTION Description Attention level MSG_MEDITATION Meditation level MSG_BLINK Strength blink MSG_EEG_POWER EEG powers MSG_THINKCAP_RAW Multi-channel raw values MSG_POSITIVITY -100.0 to 100.0 of detected MSG_FAMILIARITY MSG_DIFFICULTY Receiving and Handling Data Messages December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Data e attention level of the user is stored in the arg1 eld of the Message e meditation level of the user is stored in the arg1 eld of the Message e blink strength of the user's blink is stored in the arg1 eld of the Message e EEG powers of the user are stored as a TGEegPower object in the obj eld of the Message e multi-channel raw sample data (only available from inkCap devices) are stored as a TGRawMulti object in the obj eld of the Message Values indicate the subject's emotion or mood. e more positive values mean the subject is in a positive emotion or approach motivation, and the more negative values mean more negative emotion or withdrawal motivation. Can be used to compare a test subjects familiarity with a newly learned motor skill. One minute of collected data could constitute a trial, and will produce a familiarity index value. e familiarity index of separate trials of the motor skill can be compared. Can be used to compare the difcult a test subjects nds a newly learned motor skill. One minute of collected data could constitute a trial, and will produce a difficulty index value. e difficulty index of separate trials of the motor skill can be compared. 11 Chapter 3 – Developing Your Own ThinkGear-enabled Apps for Android msg.what MSG_HEART_RATE Description Heart rate MSG_EKG_RRINT R-to-R interval MSG_RELAXATION Relaxation level MSG_RESPIRATION Respiration Rate MSG_HEART_AGE Heart Age MSG_HEART_AGE_5MIN Heart Age MSG_EKG_TRAIN_STEP Train Step MSG_EKG_TRAINED MSG_EKG_IDENTIFIED Trained Identi ed Data e heart rate data is stored as an int in the arg1 eld of the Message e R-to-R interval in milliseconds is stored as an int in the arg1 eld of the Message e relaxation level of the user is stored as an int in the arg1 eld of the Message e respiration rate of the user is stored as a Float object in the obj eld of the Message e heart age of the user is stored as an int in the arg1 eld of the Message e heart age of the user is stored as an int in the arg1 eld of the Message e train step value is stored as an int in the arg1 eld of the Message Does not return anything e identi ed result is stored as a string in the arg1 eld of the Message Note: Depending on the type of inkGear hardware device that your TGDevice is connected to, some of the data types listed above will never be sent to your app's Handler, since those data types may not be applicable for that inkGear hardware device. See the developer specs for each inkGear hardware device that your app may support for details. Important: Pay particular attention to MSG_STATE_CHANGE messages (which indicate what the TGDevice object is currently doing), and to MSG_POOR_SIGNAL messages (which indicates the current state of the physical inkGear hardware device). For example, if the MSG_POOR_SIGNAL is indicating that the physical inkGear hardware device isn't even being worn by a user at the moment (a value of 200 on inkGear EEG devices, or a value of 0 on ECG devices), then the app needs to treat any incoming raw data values or EEG power values accordingly, possibly by ignoring them as appropriate for the app. For more detailed information about each data type such as Attention, Meditation, or Relaxation, please use the inkGear Data Types section below as a reference guide. For information that may be device-speci c, additionally refer to the specs and development notes that are available for each speci c inkGear hardware device. Receiving and Handling Data Messages December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 12 Chapter 3 – Developing Your Own ThinkGear-enabled Apps for Android TGDevice States State STATE_IDLE STATE_ERR_BT_OFF STATE_CONNECTING STATE_ERR_NO_DEVICE STATE_NOT_FOUND STATE_CONNECTED STATE_DISCONNECTED Description Initial state of the TGDevice. Not connected to any inkGear hardware device after stop() e Android device's Bluetooth adapter is not turned on or enabled during TGDevice() constructor or connect() Attempting to connect to a inkGear hardware device during connect() ere are no Bluetooth devices paired to this Android device Could not nd any of the inkGear hardware devices that are paired to this Android device e data stream has been opened e connection to the module is lost after close() Using the TGDevice Object With the Handler object ready to receive data and the TGDevice object created, your app can now instruct the TGDevice object to try to connect to your physical inkGear hardware device and start processing the incoming data. • Call the connect() method of your tgDevice to start the connection process. e tgDevice will search through your Android device's list of all paired Bluetooth devices, and try to connect to the rst one that it recognizes as a inkGear-compatible device (see Supported Devices): tgDevice.connect( true ); Note: Setting the connect() method's rawEnabled parameter to true allows raw sample data to be sent to your app. Setting to false will prevent raw data from being parsed and sent to your app, possibly saving some CPU from parsing and saving your app's Handler from having to receive many raw sample messages that your app may not need to use. • After successfully nding and connecting to a inkGear hardware device through Bluetooth, the tgDevice will send a STATE_CONNECTED Message to your app's Handler. To start receiving data upon receiving this message, call the tgDevice's start() method: tgDevice.start(); • When your app no longer needs data from the TGDevice, close the connection by calling the close() method: tgDevice.close(); At this point, your app should now be able to connect to a inkGear hardware device and receive values! To learn more details about the TGDevice class, you may refer to the inkGear SDK for Using the TGDevice Object December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 13 Chapter 3 – Developing Your Own ThinkGear-enabled Apps for Android Android: API docs at any time, found in the reference/ folder of your inkGear SDK for Android. Or, read on to the next section below to nd out what your app can (or should) do with some of those inkGear values it's now receiving. Using the TGDevice Object December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 14 Chapter 4 ThinkGear Data Types e inkGear data types are generally divided into three groups: data types that are only applicable for EEG sensor devices, types that are only applicable for ECG/EKG (CardioChip) sensor devices, and data types that are typically applicable to all inkGear-based devices, including EEG and ECG/EKG. General ese data types are generally available from most or all types of inkGear hardware devices. POOR_SIGNAL/SENSOR_STATUS is integer value provides an indication of how good or how poor the bio-signal is at the sensor. is value is typically output by all inkGear hardware devices once per second. is is an extremely important value for any app using inkGear sensor hardware to always read, understand, and handle. Depending on the use cases for your app and users, your app may need to alter the way it uses other data values depending on the current value of POOR_SIGNAL/SIGNAL_STATUS. For example, if this value is indicating that the bio-sensor is not currently contacting the subject, then any received RAW_DATA or EEG_POWER values during that time should be treated as oating noise not from a human subject, and possibly discarded based on the needs of the app. e value should also be used as a basis to prompt the user to possibly adjust their sensors, or to put them on in the rst place. In order to interpret this value you must rst decide which type of NeuroSky sensor you are using. As the interpretation is different for the different types of sensors. For EEG sensor hardware: A value of 0 indicates that the bio-sensor is not able to detect any obvious problems with the signal at the sensor. Higher values from 1 to 199 indicate increasingly more detected problems with the signal. A value of 200 means the sensor contacts detect that they are not even all properly in contact with a conductive subject (for example, the EEG headset may currently not even be worn on any person's head). For ECG/EKG (CardioChip) sensor hardware: A value of 200 indicates the bio-sensor contacts are all currently in contact with a conductive subject (such as a user's skin), while a value of 0 indicates the opposite: that not all the contacts are in proper contact with a conductive subject. Poor signal may be caused by a number of different things. In order of severity, they are: • Sensor, ground, or reference electrodes not being on a person's head/body (i.e. when nobody is wearing the inkGear equipment). • Poor contact of the sensor, ground, or reference electrodes to a person's skin (i.e. hair in the way, or headset which does not properly t a person's head, or headset not properly placed on the head). 15 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 4 – ThinkGear Data Types • Excessive motion of the wearer (i.e. moving head or body excessively, jostling the headset/sensor). • Excessive environmental electrostatic noise (some environments have strong electric signals or static electricity buildup in the person wearing the sensor). • Excessive biometric noise (i.e. unwanted EMG, EKG/ECG, EOG, EEG, etc. signals) For EEG modules, a certain amount of noise is unavoidable in normal usage of inkGear sensor hardware, and both NeuroSky's ltering technology and algorithms have been designed to detect, correct, compensate for, account for, and tolerate many types of signal noise. Most typical users who are only interested in using the eSense values, such as Attention and Meditation, do not need to worry as much about the POOR_SIGNAL Quality value, except to note that the Attention and Meditation values will not be updated while POOR_SIGNAL is greater than zero, and that the headset is not being worn while POOR_SIGNAL is 200. e POOR_SIGNAL Quality value is more useful to some applications which need to be more sensitive to noise (such as some medical or research applications), or applications which need to know right away when there is even minor noise detected. RAW_DATA is data type supplies the raw sample values acquired at the bio-sensor. e sampling rate (and therefore output rate), possible range of values, and interpretations of those values (conversion from raw units to volt) for this data type are dependent on the hardware characteristics of the inkGear hardware device performing the sampling. You must refer to the documented development specs of each type of inkGear hardware that your app will support for details. As an example, the majority of inkGear devices sample at 512Hz, with a possible value range of -32768 to 32767. As another example, to convert TGAT-based EEG sensor values (such as TGAT, TGAM, MindWave Mobile, MindWave, MindSet) to voltage values, use the following conversion: (rawValue * (1.8/4096) / 2000 Note that ECG/EKG raw values from CardioChip/BMD10X-based devices must use a different conversion. RAW_MULTI is data type is not currently used by any current commercially-available inkGear products. It is kept here for backwards compatibility with some end-of-life products, and as a placeholder for possible future products. EEG ese data types are only available from EEG sensor hardware devices, such as the MindWave Mobile, MindSet, MindBand, and TGAM chips and modules. ATTENTION is int value reports the current eSense Attention meter of the user, which indicates the intensity of a user's level of mental "focus" or "attention", such as that which occurs during intense concentration EEG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 16 Chapter 4 – ThinkGear Data Types and directed (but stable) mental activity. Its value ranges from 0 to 100. Distractions, wandering thoughts, lack of focus, or anxiety may lower the Attention meter levels. See eSense\texttrademark Meters below for details about interpreting eSense levels in general. By default, output of this Data Value is enabled. It is typically output once a second. MEDITATION is unsigned one-byte value reports the current eSense Meditation meter of the user, which indicates the level of a user's mental "calmness" or "relaxation". Its value ranges from 0 to 100. Note that Meditation is a measure of a person's mental levels, not physical levels, so simply relaxing all the muscles of the body may not immediately result in a heightened Meditation level. However, for most people in most normal circumstances, relaxing the body often helps the mind to relax as well. Meditation is related to reduced activity by the active mental processes in the brain, and it has long been an observed effect that closing one's eyes turns off the mental activities which process images from the eyes, so closing the eyes is often an effective method for increasing the Meditation meter level. Distractions, wandering thoughts, anxiety, agitation, and sensory stimuli may lower the Meditation meter levels. See "eSense Meters" below for details about interpreting eSense levels in general. By default, output of this Data Value is enabled. It is typically output once a second. eSense™ Meters For all the different types of eSenses (i.e. Attention, Meditation), the meter value is reported on a relative eSense scale of 1 to 100. On this scale, a value between 40 to 60 at any given moment in time is considered "neutral", and is similar in notion to "baselines" that are established in conventional EEG measurement techniques (though the method for determining a inkGear baseline is proprietary and may differ from conventional EEG). A value from 60 to 80 is considered "slightly elevated", and may be interpreted as levels being possibly higher than normal (levels of Attention or Meditation that may be higher than normal for a given person). Values from 80 to 100 are considered "elevated", meaning they are strongly indicative of heightened levels of that eSense. Similarly, on the other end of the scale, a value between 20 to 40 indicates "reduced" levels of the eSense, while a value between 1 to 20 indicates "strongly lowered" levels of the eSense. ese levels may indicate states of distraction, agitation, or abnormality, according to the opposite of each eSense. An eSense meter value of 0 is a special value indicating the inkGear is unable to calculate an eSense level with a reasonable amount of reliability. is may be (and usually is) due to excessive noise as described in the POOR_SIGNAL section above. e reason for the somewhat wide ranges for each interpretation is that some parts of the eSense algorithm are dynamically learning, and at times employ some "slow-adaptive" algorithms to adjust to natural uctuations and trends of each user, accounting for and compensating for the fact that EEG in the human brain is subject to normal ranges of variance and uctuation. is is part of the reason why inkGear sensors are able to operate on a wide range of individuals under an extremely wide range of personal and environmental conditions while still giving good accuracy and reliability. Developers are encouraged to further interpret and adapt these guideline ranges to be ne-tuned for their application (as one example, an application could disregard values below 60 and only react to values between 60-100, interpreting them as the onset of heightened attention levels). BLINK is int value reports the intensity of the user's most recent eye blink. Its value ranges from 1 to 255 and it is reported whenever an eye blink is detected. e value indicates the relative intensity of the blink, and has no units. EEG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 17 Chapter 4 – ThinkGear Data Types EEG_POWER is Data Value represents the current magnitude of 8 commonly-recognized types of EEG frequency bands. e eight EEG powers are: delta (0.5 - 2.75Hz), theta (3.5 - 6.75Hz), low-alpha (7.5 - 9.25Hz), high-alpha (10 - 11.75Hz), low-beta (13 - 16.75Hz), high-beta (18 - 29.75Hz), low-gamma (31 39.75Hz), and mid-gamma (41 - 49.75Hz). ese values have no units and are only meaningful for comparison to the values for the other frequency bands within a sample. By default, output of this Data Value is enabled, and it is output approximately once a second. THINKCAP_RAW is data type is not currently used by any current commercially-available inkGear products. It is kept here for backwards compatibility with some end-of-life products, and as a placeholder for possible future products. POSITIVITY Values -100 to +100, indicates that the subject is attentive, the more negative values mean the subject is less attentive and the more positive values mean more attentive. FAMILIARITY Can be used to compare a test subjects familiarity with a newly learned motor skill. One minute of collected data could constitute a trial, and will produce a familiarity index value for this subject. e familiarity index of separate trials of the motor skill can be compared for the same subject. DIFFICULTY Can be used to compare a difficult a test subjects nds a newly learned motor skill. One minute of collected data could constitute a trial, and will produce a difficulty index value for this subject. e difficulty index of separate trials of the motor skill can be compared for the same subject. ECG/EKG ese data types are only available from ECG/EKG sensor (CardioChip) hardware devices, such as the CardioChip Starter Kit Unit and BMD10X chips and modules. HEART_RATE is int value reports the current heart rate of the user, in units of beats per minute (BPM). Unlike many other commonly seen reports of heart rate from other devices, this value is calculated precisely in real time based on the actual time between each and every one of the user's actual R-peaks. is results in a very precise and continuous reporting of Heart Rate that changes with the actual beat-tobeat uctuations of every single one of the user's actual heart beats. To easily get an "smoothed, averaged" heart rate value which is more commonly seen as reported by other ECG/EKG devices, use these values as inputs to the Smoothed Heart Rate described below. ECG/EKG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 18 Chapter 4 – ThinkGear Data Types Smoothed Heart Rate Typically, when viewing a "Heart Rate" value on many ECG/EKG devices, a "smoothed" value is displayed so that there aren't rhythmic uctuations in the viewed heart rate based on the subject's natural HRV rhythms. e same sort of "smoothed" effect can be achieved against the precise HEART\_RATE values, by using the getAcceleration() method of the HeartRateAcceleration class provided in this SDK. See the section on Heart Rate Acceleration for a description of how to calculate the Smoothed Heart Rate, and then refer to the API Reference for full details on the HeartRateAcceleration class. Heart Rate Acceleration A potentially useful metric of Heart Rate is the acceleration rate. A positive acceleration value indicates the user's heart rate is speeding up by a certain number of BPM over a given period of time (such as over 10 seconds), while a negative acceleration value indicates the user's heart rate is slowing down by a certain number of BPM over a given period. When starting exercise, or during rest after exercise, this acceleration metric could be used as an indicator of how quickly a person's heart is speeding up to match the activity, or how quickly it is slowing down back to normal, respectively. To calculate Heart Rate Acceleration (and/or Smoothed Heart Rate), rst initialize a HeartRateAcceleration() object in your app: HeartRateAcceleration heartRateAcceleration = new HeartRateAcceleration(); is will initialize the calculation to use a period of 10 second. (You can instead choose to use the overloaded constructors to initialize the calculation using a longer or shorter period of time, as appropriate for your app). en, whenever a new Heart Rate value becomes available to your app, get the Smoothed Heart Rate and acceleration values like this: int[] result = heartRateAcceleration.getAcceleration( heartRate, poorSignal ); if( result[0] != -1 ) { int smoothedHeartRate = result[0]; int heartRateAcceleration = result[1]; } Refer to the API Reference documentation for full details of the HeartRateAcceleration class. Target Heart Rate for Physical Training Given information about a user's age and gender, it is possible to determine a target range of heart rates for them to achieve particular physical training "zones". Combined with the HEART\_RATE information reported by the sensor, an app could advise a user whether their current heart rate is within their target training zone (such as right after a workout). To determine the target range of heart rates for a person, rst create a TargetHeartRate object: TargetHeartRate targetHeartRate = new TargetHeartRate(); en, at any time, to determine the target range of heart rates (min to max values) for a a user to achieve a particular physical training zone, use the getTargetHeartRate() method: ECG/EKG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 19 Chapter 4 – ThinkGear Data Types int age = 25; String gender = "Male"; String zone = "Aerobic"; int[] range = targetHeartRate.getTargetHeartRate( age, gender, zone ); int lowerBound = range[0]; int upperBound = range[1]; e lowerBound and upperBound could then be compared to the user's HEART\_RATE or Smoothed Heart Rate to determine if the user is within the their target range for the target physical training zone. e gender must be either "Male" or "Female". e zone must be one of: • "Light Exercise" • "Weight Loss" • "Aerobic" • "Conditioning" • "Athletic" If any of the arguments are incorrect, then the method will return an int[] of -1, -1 . Important: e heart rate should not be measured while the user is engaged in physical activity; the user should temporarily stop the activity and then measure their heart rate. (References) 1. http://www.heart.org/HEARTORG/GettingHealthy/PhysicalActivity/Target-Heart-Rates\_UCM\_434341\_A 2. http://www.cdc.gov/physicalactivity/everyone/measuring/heartrate.html 3. http://www.heart.com/heart-rate-chart.html 4. http://www.thewalkingsite.com/thr.html Heart Fitness Level Given a person's age, gender, and current resting heart rate, it is possible to get a general idea of the person's current heart health and tness, labeling them as one of "Poor", "Below Average", "Average", "Above Average", "Good", "Excellent", or "Athlete". To determine the heart tness level for a person, rst create a HeartFitnessLevel object: HeartFitnessLevel heartFitnessLevel = new HeartFitnessLevel(); en, once you have the age, gender, and current resting heart rate of the person, use the getHeartFitnessLevel() method: int age = 25; String gender = "Male"; String restingHR = 60; string heartFitnessLevel = heartFitnessLevel.getHeartFitnessLevel( age, gender, restingHR ); ECG/EKG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 20 Chapter 4 – ThinkGear Data Types e gender must be one of "Male" or "Female", otherwise the method will simply return the empty string (""). e heartFitnessLevel will be returned as one of "Poor", "Below Average", "Average", "Above Average", "Good", "Excellent", or "Athlete". (References) 1. http://www.topendsports.com/testing/heart-rate-resting-chart.htm RELAXATION e Relaxation data value gives an indication of whether a user's heart is showing indications of relaxation, or is instead showing indications of excitation, stress, or fatigue, based on the user's Heart Rate Variability (HRV) characteristics. It is reported on a scale from 1 to 100. High Relaxation values tend to indicate a state of relaxation, while low values tend to indicate excitation, stress, or fatigue. To receive these values via MSG_RELAXATION messages to your app's Handler, simply have the TGDevice connected to a inkGear ECG/EKG sensor (CardioChip), and a user contacting the ECG/EKG sensor hardware properly for at least one minute continuously with a good, clean signal (SENSOR_STATUS == 200 for 1 minute). If the signal is interrupted, and SENSOR_STATUS becomes anything other than 200, then this calculation is reset and starts over, requiring another minute of clean data to report a MSG_RELAXATION. For best results, the user should be sitting calmly during data collection. (References) 1. Neurosci Biobehav Rev. 2009 Feb; 33(2): 71-80. Epub 2008 Jul 30. Heart rate variability explored in the frequency domain: a tool to investigate the link between heart and behavior. Montano N, Porta A, Cogliati C, Costantino G, Tobaldini E, Casali KR, Iellamo F. 2. Int J Cardiol. 2002 Jul; 84(1): 1-14. Functional assessment of heart rate variability: physiological basis and practical applications. Pumprla J, Howorka K, Groves D, Chester M, Nolan J. 3. International Conference on Computer and Automation Engineering. A Review of Measurement and Analysis of Heart Rate Variability. Dipali Bansal, Munna Khan, A. K. Salhan. 4. Neurosci Biobehav Rev. 2009 Feb; 33(2): 81-8. Epub 2008 Aug 13. Claude Bernard and the heart-brain connection: further elaboration of a model of neurovisceral integration. ayer JF, Lane RD. RESPIRATION e Respiration data value reports a user's approximate respiration rate in breaths per minute. It is calculated from the user's ECG/EKG and Heart Rate Variability (HRV) characteristics. To receive these values via MSG_RESPIRATION Messages to your app's Handler, simply have the TGDevice connected to a inkGear ECG/EKG sensor (CardioChip), and a user contacting the ECG/EKG sensor hardware properly for at least 64 seconds continuously with a good, clean signal (SENSOR_STATUS >= 200 for 64 seconds). Once the rst MSG_RESPIRATION Message is received, updated values will be sent via subsequent MSG_RESPIRATION Messages every 10 seconds. If the signal is ever interrupted, and SENSOR_STATUS becomes anything less than 200, then this calculation is reset and starts over, requiring another 64 seconds of clean data to report a MSG_RESPIRATION. ECG/EKG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 21 Chapter 4 – ThinkGear Data Types For best results, the user should be sitting calmly during data collection. (References) 1. Rosenthal, Talma, Ariela Alter, Edna Peleg, and Benjamin Gavish. "Device-guided breathing exercises reduce blood pressure: ambulatory and home measurements." American Journal of Hypertension. 14. (2001): 74–76. Heart Risk Awareness e Heart Risk Awareness data value aims to raise awareness if the HRV is very low, as low HRV has been shown to be associated with increased risk of mortality. To determine the Heart Risk Awareness for a person, rst create a NeuroSkyHeartMeters object: NeuroSkyHeartMeters neuroSkyHeartMeters = new NeuroSkyHeartMeters(); en, use one of the following two methods to calculate: Using R-R Intervals Collection Whenever your app's Handler receives a MSG_EKG_RRINT Message, save the R-R Interval value into a buffer. Once you have at least 60 R-R Intervals in the buffer, use the calculateHeartRiskAware( Integer[] rrIntervalInMS ) method of the NeuroSkyHeartMeters class: private final Handler handler = new Handler() { ArrayList ... temp_rrintBuffer = new ArrayList (); Integer[] rrinterBuffer = new Integer[60]; @Override public void handleMessage( Message msg ) { switch( msg.what ) { //... case MSG_EKG_RRINT: temp_rrintBuffer.add( msg.arg1 ); if( temp_rrintBuffer.size()==60 ) { for( int i = 0; i<60; i++ ) { rrintBuffer[i] = temp_rrintBuffer.get(i); } temp_rrintBuffer.clear(); int heartRiskAwareness = neuroSkyHeartMeters.calculateHeartRiskAware( rrintBuffer ); } break; //... } /* end switch on message type */ } /* end handleMessage() */ }; /* end Handler */ ECG/EKG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 22 Chapter 4 – ThinkGear Data Types Using Storage Data Simply use the calculateHeartRiskAware( String fileName ) method in the NeuroSkyHeartMeters class: int heartRiskAwarness = neuroSkyHeartMeters.calculateHeartRiskAware( "john" ); Note: e parameter " leName" in the method is the name of the le that stored calculated heart age. Results e return value will be a "Heart Risk Awareness" index that will be one of "0", "1","2" or "3". e following information could be provided by the app to the user based on their "Heart Risk Awareness": HeartRiskAwareness = 0 Your HRV does not appear to be low at this time. Low HRV has been shown to be related to increased risk of heart attack and mortality. is means your HRV suggests you currently have limited or no risk. HeartRiskAwareness = 1 Your HRV is a relatively low. Low HRV has been shown to be related to increased risk of heart attack and mortality. It is recommended that you stay active and be careful about what you eat. You could eat foods that can prevent heart attack, such as nuts, sh, coarse grains, vegetables, and you may also drink green tea. HeartRiskAwareness = 2 Your HRV is low. Low HRV has been shown to be related to increased risk of heart attack and mortality. Bad habits that in uence the health of your heart include consumption of food with high fat and sugar content, smoking, drinking alcohol, lack of exercise, high mental pressure, and long periods of sleep deprivation. It is recommended that you change your bad habits by drinking only a moderate amount of alcohol, eating healthy, getting appropriate exercise, controlling your body weight, developing good sleeping habits, and keeping a peaceful state of mind. HeartRiskAwareness = 3 Your HRV is very low. Low HRV has been shown to be related to increased risk of heart attack and mortality. It is recommended that you change some of your habits. You may consider to quit smoking, stop drinking alcohol. You should also make sure to get appropriate amount of exercise, control your body weight, develop good sleeping habits, eat more ber and less salt, and keep a peaceful state of mind. Symptoms of heart attack include chest pain, shoulder pain, trouble breathing, poor digestion, and severe fatigue. Please see a doctor if these symptoms occur to you. (for References, see Heart Age) HEART_AGE e Heart Age data value provides an indication of the relative age of a subject heart, based on their Heart Rate Variability (HRV) characteristics as compared to the general population. A low HRV is associated with an increased risk of mortality, and is represented by a Heart Age that is possibly higher than the user's biological age (such as a 35 year old with HRV characteristics that suggest a heart age of 45). e calculation will take into account the user's reported biological age. Use of this data value is only recommended for subjects that are at least 10 years old (biological age). ECG/EKG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 23 Chapter 4 – ThinkGear Data Types To receive these values via MSG_HEART_AGE Messages to your app's Handler, rst set the user's biological age via the TGDevice object: tgDevice.inputAge = 25 (of course replacing 25 with the user's actual age). en, simply have the TGDevice connected to a inkGear ECG/EKG sensor (CardioChip), and a user contacting the ECG/EKG sensor hardware properly for at least 60 heart beats continuously with a good, clean signal (SENSOR_STATUS >= 200 for 60 heart beats). If the signal is ever interrupted, and SENSOR_STATUS becomes anything less than 200, then this calculation is reset and starts over, requiring another 60 heart beats of clean data before it can report a MSG_HEART_AGE. For best results, the user should be sitting calmly during data collection. An example of how your app and users could potentially use this information would be if your app displayed messages like the following to the user based on their Heart Age value: Adolescent heart: < 25 years old Your heart age is xx years old, which is greater/less than your actual age by xx years. Your young heart age allows you to be energetic and to think actively, which helps you deal with demanding work and exercise. A young heart also needs to be taken care of. It is recommended that you avoid staying up late at night, get appropriate amounts of exercise, and maintain a peaceful and positive attitude. You should also eat more fresh fruits and vegetables and cut down on fatty foods to keep your heart at its young state. Young heart: 26 – 39 Your heart age is xx years old, which is greater/less than your actual age by xx years. You have a mature heart. While in a tense working environment, please don’t forget to get good amounts of sleep and exercise, eat well, and take good care of yourself. Middle-aged heart: 40 – 55 Your heart age is xx years old, which is greater/less than your actual age by xx years. Please pay close attention to your heart health and plan your work and life accordingly to lessen the burden on your heart. It is recommenced that you eat foods that are good for your heart, such as sh, whole grains, beans, nuts, vegetables, red wine, and green tea. You should also get a reasonable amount of exercise to strengthen your heart. Young elderly heart: 56 – 70 Your heart age is xx years old, which is greater/less than your actual age by xx years. Your heart’s function is taking a step towards old age. It is recommended that you live with discipline and avoid straining your body or becoming overly excited or nervous. You should also have regular physical examinations and eat more foods that are good for your heart, such as sh, coarse grains, beans, nuts, vegetables, red wine, and green tea. It is also important for you to get a reasonable amount of exercise so that your heart continues to work effectively. Elderly heart: >70 years old Your heart age is xx years old, which is greater/less than your actual age by xx years. It is recommended that you regularly visit your doctor to get physical examinations and carefully follow your doctor’s instructions in order to prevent and treat heart disease. You should also get appropriate amounts of exercise and keep a peaceful state of mind. Living with discipline and eating healthy can improve the function of your cardiovascular system and prevent heart disease. (References) 1. Res Sports Med. 2010 Oct; 18(4):263-9. Age and heart rate variability after soccer games. Yu S, Katoh T, Makino H, Mimuno S, Sato S. ECG/EKG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 24 Chapter 4 – ThinkGear Data Types 2. J Am Coll Cardiol. 1998 Mar 1; 31(3): 593-601. Twenty four hour time domain heart rate variability and heart rate: relations to age and gender over nine decades. Umetani K, Singer DH, McCraty R, Atkinson M. 3. Am J Cardiol. 2010 Apr 15; 105(8): 1181-5. Epub 2010. Relation of high heart rate variability to healthy longevity. Zul qar U, Jurivich DA, Gao W, Singer DH. 4. Cardiovasc Electrophysiol. 2003 Aug; 14(8): 791-9. Circadian pro le of cardiac autonomic nervous modulation in healthy subjects: differing effects of aging and gender on heart rate variability. Bonnemeier H, Richardt G, Potratz J, Wiegand UK, Brandes A, Kluge N, Katus HA. 5. Pacing Clin Electrophysiol. 1996 Nov; 19(11 Pt 2): 1863-6. Changes in heart rate variability with age. Reardon M, Malik M. Personalization is algorithm allows the TGDevice to try to recognize a connected user based on their ECG/EKG data. To use it, one or more users should "train" their ECG/EKG data into the TGDevice. en, whenever the TGDevice is reading ECG data from a user, it can attempt to identify which of the trained users (if any) is the one it is reading from. ere are two steps to use the Personalization algorithm: Training e rst part records ECG/EKG data of user, using the EKGstartLongTraining( String userName ) method in the TGDevice class. If the user then keeps good, clean contact with the ECG/EKG sensor hardware properly, a MSG_EKG_TRAIN_STEP Message will be sent to your app's Handler to show which step you are currently on. After two steps are nished, it will send a MSG_EKG_TRAINED Message to your app's Handler to indicate that the recording is nished, then your Handler should use the EKGstopTraining() method to stop. Detection is part is used to recognize user based on saved data from the rst part. To recognize user, invoke the EKGstartDetection() method. en, if the user keeps a good, clean contact with the ECG/EKG sensor hardware, the TGDevice will send a MSG_EKG_IDENTIFIED Message to your app's Handler. e return value will be one of the registered user names, or "Unknown". private final Handler handler = new Handler() { @Override public void handleMessage( Message msg ) { switch( msg.what ) { //... case MSG_EKG_TRAIN_STEP: int trainStep = msg.arg1; break; case MSG_EKG_TRAINED: tgDevice.EKGstopTraining(); break; ECG/EKG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 25 Chapter 4 – ThinkGear Data Types case MSG_EKG_IDENTIFIED: String result = msg.arg1; tgDevice.EKGstopDetection(); break; //... } /* end switch on message type */ } /* end handleMessage() */ }; /* end Handler */ //... tgDevice.EKGstartLongTraining( "John" ); //... tgDevice.EKGstartDetection(); EKG_RRINT Whenever an R-peak is detected along a user's PQRST ECG/EKG, then a MSG_EKG_RRINT Message is sent to your app's Handler indicating the R-R interval, in milliseconds, since the last R-peak. ECG/EKG December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. 26 Chapter 5 Proper App Design Important: Before releasing an app for real-world use, make sure your app considers or handles the following: • If your app's Handler receives a MSG_STATE_CHANGE Message with any value other than STATE_CONNECTING or STATE_CONNECTED, it should carefully handle each possible error situation with an appropriate message to the user via the app's UI. Not handling these error cases well in the UI almost always results in an extremely poor user experience of the app. Here are some examples: – If a STATE_ERR_BT_OFF Message is received, the user should be prompted to turn on their Bluetooth adapter, and then they can try again. – If a STATE_ERR_NO_DEVICE Message is received, the user should be reminded to rst pair their inkGear hardware device to their Android device's Bluetooth, according to the instructions they received with their inkGear hardware device. – If a STATE_NOT_FOUND Message is received, the user should be reminded to check that their inkGear hardware device is properly paired to their Android device (same as the STATE_ERR_NO_DEVICE case), and if so, that their inkGear hardware device is turned on, in range, and has enough battery or charge. – See TGDevice States for more info. • Always make sure your app is handling the POOR\_SIGNAL/SENSOR\_STATUS Data Type. It is output by almost all inkGear devices, and provides important information about whether the sensor is properly in contact with the user. If it is indicating some sort of problem (problem == not 0 for EEG devices, or not 200 for ECG/EKG devices), then your app should notify the user to properly wear the inkGear hardware device, and/or disregard any other reported data values while the POOR\_SIGNAL/SENSOR\_STATUS continues to indicate a problem, as appropriate for your app. • To make the user experience consistent, familiar, and easy-to-learn and use for end customers across platforms and devices, your app should be designed to follow the guidelines and conventions described in NeuroSky's App Standards. 27 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 6 Troubleshooting Note: ere are currently no known issues. If you encounter any bugs or issues, please visit http://support.neurosky.com, or contact support@neurosky.com. If you need further help, you may visit http://developer.neurosky.com to see if there is any new information. To contact NeuroSky for support, please visit http://support.neurosky.com, or send email to support@neurosky.com. For developer community support, please visit our community forum on http://www.linkedin.com/groups/NeuroSkyBrain-Computer-Interface-Technology-3572341 28 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 7 Important Notices e algorithms included in this SDK are solely for promoting the awareness of personal wellness and health and are not a substitute for medical care. e algorithms are not to be used to diagnose, treat, cure or prevent any disease, to prescribe any medication, or to be a substitute for a medical device or treatment. In some circumstances, the algorithm may report false or inaccurate results. e descriptions of the algorithms or data displayed in the SDK documentation, are only examples of the particular uses of the algorithms, and NeuroSky disclaims responsibility for the nal use and display of the algorithms internally and as made publically available. e algorithms may not function well or may display accurate data if the user has a pacemaker. All ECG data should be collected while the user is seated quietly, breathing regularly, with minimal movement, for best results. Warnings and Disclaimer of Liability THE ALGORITHMS MUST NOT BE USED FOR ANY ILLEGAL USE, OR AS COMPONENTS IN LIFE SUPPORT OR SAFETY DEVICES OR SYSTEMS, OR MILITARY OR NUCLEAR APPLICATIONS, OR FOR ANY OTHER APPLICATION IN WHICH THE FAILURE OF THE ALGORITHMS COULD CREATE A SITUATION WHERE PERSONAL INJURY OR DEATH MAY OCCUR. YOUR USE OF THE SOFTWARE DEVELOPMENT KIT, THE ALGORITHMS AND ANY OTHER NEUROSKY PRODUCTS OR SERVICES IS “AS-IS,” AND NEUROSKY DOES NOT MAKE, AND HEREBY DISCLAIMS, ANY AND ALL OTHER EXPRESS AND IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, AND ANY WARRANTIES ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT SHALL NEUROSKY BE LIABLE FOR ANY SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS OR INCOME, WHETHER OR NOT NEUROSKY HAD KNOWLEDGE, THAT SUCH DAMAGES MIGHT BE INCURRED. 29 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 8 APPENDIX A: Additional References • http://developer.android.com/guide/topics/wireless/bluetooth.html 30 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved. Chapter 9 APPENDIX B: UART (Non-Bluetooth) Connections For Android devices, such as phones or tablets, that are designed to be physically connected to inkGear hardware devices via UART (especially CardioChip), the TG-SDK for Android offers an alternate constructor and connect method: public TGDevice( InputStream s, OutputStream o, Handler h ); public synchronized void connectStream( boolean rawEnabled ); Instead of taking a BluetoothAdapter in the constructor and using Bluetooth for communication, it instead takes an InputStream and OutputStream for communication. e connectStream() method is then analogous for this constructor as the connect() method for the Bluetooth-based constructor. To use this API of the SDK, you must rst prepare the Android/Linux system as follows: 1. Physically connect the UART pins of the inkGear hardware device to the UART pins of the Android device 2. Make sure the Linux OS layer beneath the Android OS layer makes the UART port available as a serial port, such as "/mnt/uart1" en, because Android does not provide APIs to directly access serial ports, we must go around the Android layer to the Linux serial port layer using JNI: 1. Compile the uart.cpp le (provided separately by NeuroSky, along with a make le) into a native library le called libJRDBCM.lib that JNI will be able to call. is library will make it possible for your app to open the serial port. 2. Use JNI in your app to call the SerialJNI_open() method from within your app. is will open a FileDescriptor, from which you can obtain a FileInputStream and FileOutputStream for use with the TGDevice constructor: public class Native { static { System.loadLibrary( "JRDBCM" ); } } String dev = "/mnt/uart1"; FileDescriptor serialPort = Native.SerialJNI_open( dev ); InputStream iStream = new FileInputStream( serialPort ); OutputStream oStream = new FileOutputStream( serialPort ); TGDevice tgDevice = new TGDevice( iStream, oStream, handler ); tgDevice.connectStream( true ); From here on out, the TG API is exactly the same as for Bluetooth described in the rest of this document. Just remember to close your FileDescriptor using Native.SerialNJI.close() when you are done with the TGDevice, after the TGDevice is closed. 31 December 14, 2012 | © 2012 NeuroSky, Inc. All Rights Reserved.
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.4 Linearized : No Page Mode : UseOutlines Page Count : 31 Creator : DokuTeXit Title : ThinkGear Development Guide for Android Author : NeuroSky, Inc. Producer : xdvipdfmx (0.6) Create Date : 2012:12:14 16:34:39-08:00EXIF Metadata provided by EXIF.tools