stevenlee / EAContextSample

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Atomax icon

#EAContext API

EA stands for "Exercise Analytic", which is used for gathering 3-axies accelerometer data, gyroscope data and other useful information from Atomax curo sensor and also from iPhone sensor.

You can choose connection type that we'll mention it later on.

Curo sensor's data is transmitted via Bluetooth LE. We use CoreBluetooth framework to access Atomax curo sensor to get accelerometer and gyroscope data and provide couple algorithms to figure out some values like user acceleration, gravity, and furthermore the racket swing speed, racket swing velocity, etc.

You should take a look at EAContext.h file. There are specific descriptions for each methods, properties, and constants. Enjoy it!

##Deployment

  1. Open the EAContextSample/EAContext/ folder and drag those of the .h files and libEAContext.a file to your project.

  2. In Build Phases add 3 frameworks as follows:

    • CoreBluetooth.framework
    • CoreMotion.framework
    • GLKit.framwwork

##Get Started

####Initialize Initialize the instance of EAContext class and choose the connection type and desired data type. Here, we select BLE to access our sensor and want a bundle of raw data back(means accelerometer data, gyroscope data, gravity, and user acceleration).

EAContext *context = [[EAContext alloc] initWithSport:EASportTypeRAWData andConnectionType:EAConnectionTypeBLE];

####Assign Delegate

context.delegate = self;

####Implement delegate methods The data we need is a structure type AMXVector3 encapsulated in a NSValue object contained in a NSDictionary object. If an error occurs, the - (void)context:(EAContext *)context didFailToAccessWithError:(NSError *)error method will be invoked.

- (void)context:(EAContext *)context didUpdateCalculatedResultWithUserInfo:(NSDictionary *)userinfo
{

}


- (void)context:(EAContext *)context didFailToAccessWithError:(NSError *)error
{

}

####Get connection This method will display a model view controller that list all the discovered preripherals, once you connect to the curo sensor, the sensor will automatically start to update data.

[context displayBluetoothLowEnergyPickerOnViewController:self WithCompletion:^(NSError *error){
            
            
}];

####Error When an error occurs, callback method will send a NSError object containing an error code, please see EAError.h file.

##Example: EAContextSample

In EAContextSample project, we demostrate you a simple sample code to access the curo sensor data. You will see how we get the accelerometer, gyro, graviry, and user acceleration data then display on the screen.

##Additional Notes

Created by Ryan Chen, engineer at Atomax, on 14/04/30.

Copyright (c) 2014年 Atomax Inc. All rights reserved.

Any feedback is welcomed, please send feekback to service@atomaxinc.com or facebook

About


Languages

Language:Objective-C 97.9%Language:C 2.1%