All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
AccelerometerService

Detailed Description

Function Documentation

void accel_data_service_subscribe ( uint32_t  samples_per_update,
AccelDataHandler  handler 
)

Subscribe to the accelerometer data event service. Once subscribed, the handler gets called every time there are new accelerometer samples available.

Parameters
handlerA callback to be executed on accelerometer data events
samples_per_updatethe number of samples to buffer, between 0 and 25.
void accel_data_service_unsubscribe ( void  )

Unsubscribe from the accelerometer data event service. Once unsubscribed, the previously registered handler will no longer be called.

int accel_service_peek ( AccelData data)

Peek at the last recorded reading.

Parameters
[out]dataa pointer to a pre-allocated AccelData item
Returns
-1 if the accel is not running
int accel_service_set_samples_per_update ( uint32_t  num_samples)

Change the number of samples buffered between each accelerometer data event.

Parameters
num_samplesthe number of samples to buffer, between 0 and 25.
int accel_service_set_sampling_rate ( AccelSamplingRate  rate)

Change the accelerometer sampling rate.

Parameters
rateThe sampling rate in Hz (1Hz, 10Hz, 25Hz, 50Hz, and 100Hz possible)
void accel_tap_service_subscribe ( AccelTapHandler  handler)

Subscribe to the accelerometer tap event service. Once subscribed, the handler gets called on every tap event emitted by the accelerometer.

Parameters
handlerA callback to be executed on tap event
void accel_tap_service_unsubscribe ( void  )

Unsubscribe from the accelerometer tap event service. Once unsubscribed, the previously registered handler will no longer be called.


Data Structure Documentation

struct AccelData

A single accelerometer sample for all three axes.

Data Fields
int16_t x acceleration along the x axis
int16_t y acceleration along the y axis
int16_t z acceleration along the z axis

Typedef Documentation

typedef void(* AccelDataHandler)(AccelData *data, uint32_t num_samples)

Callback type for accelerometer data events.

Parameters
dataa pointer to data
num_samplesthe number of available samples
typedef void(* AccelTapHandler)(AccelAxisType axis, int32_t direction)

Callback type for accelerometer tap events.

Parameters
axisthe axis on which a tap was registered (x, y, or z)
directionthe direction (-1 or +1) of the tap

Enumeration Type Documentation

Valid accelerometer sampling rates, in Hz.