Pebble Foundation Classes
0.2.0
C++ for Pebble
|
Using the Pebble accelerometer. More...
Typedefs | |
typedef void(* | AccelDataHandler) (AccelData *data, uint32_t num_samples) |
typedef void(* | AccelRawDataHandler) (AccelRawData *data, uint32_t num_samples, uint64_t timestamp) |
typedef void(* | AccelTapHandler) (AccelAxisType axis, int32_t direction) |
typedef void(* | AccelDataHandler) (AccelData *data, uint32_t num_samples) |
typedef void(* | AccelRawDataHandler) (AccelRawData *data, uint32_t num_samples, uint64_t timestamp) |
typedef void(* | AccelTapHandler) (AccelAxisType axis, int32_t direction) |
Enumerations | |
enum | AccelAxisType { ACCEL_AXIS_X = 0, ACCEL_AXIS_Y = 1, ACCEL_AXIS_Z = 2, ACCEL_AXIS_X = 0, ACCEL_AXIS_Y = 1, ACCEL_AXIS_Z = 2 } |
Enumerated values defining the three accelerometer axes. More... | |
enum | AccelSamplingRate { ACCEL_SAMPLING_10HZ = 10, ACCEL_SAMPLING_25HZ = 25, ACCEL_SAMPLING_50HZ = 50, ACCEL_SAMPLING_100HZ = 100, ACCEL_SAMPLING_10HZ = 10, ACCEL_SAMPLING_25HZ = 25, ACCEL_SAMPLING_50HZ = 50, ACCEL_SAMPLING_100HZ = 100 } |
Valid accelerometer sampling rates, in Hz. More... | |
enum | AccelAxisType { ACCEL_AXIS_X = 0, ACCEL_AXIS_Y = 1, ACCEL_AXIS_Z = 2, ACCEL_AXIS_X = 0, ACCEL_AXIS_Y = 1, ACCEL_AXIS_Z = 2 } |
Enumerated values defining the three accelerometer axes. More... | |
enum | AccelSamplingRate { ACCEL_SAMPLING_10HZ = 10, ACCEL_SAMPLING_25HZ = 25, ACCEL_SAMPLING_50HZ = 50, ACCEL_SAMPLING_100HZ = 100, ACCEL_SAMPLING_10HZ = 10, ACCEL_SAMPLING_25HZ = 25, ACCEL_SAMPLING_50HZ = 50, ACCEL_SAMPLING_100HZ = 100 } |
Valid accelerometer sampling rates, in Hz. More... | |
Functions | |
struct | __attribute__ ((__packed__)) |
A single accelerometer sample for all three axes. More... | |
int | accel_service_peek (AccelData *data) |
int | accel_service_set_sampling_rate (AccelSamplingRate rate) |
int | accel_service_set_samples_per_update (uint32_t num_samples) |
void | accel_data_service_subscribe (uint32_t samples_per_update, AccelDataHandler handler) |
void | accel_data_service_unsubscribe (void) |
void | accel_tap_service_subscribe (AccelTapHandler handler) |
void | accel_tap_service_unsubscribe (void) |
void | accel_raw_data_service_subscribe (uint32_t samples_per_update, AccelRawDataHandler handler) |
Variables | |
AccelData | |
AccelRawData | |
AccelData | |
AccelRawData | |
Using the Pebble accelerometer.
The AccelerometerService enables the Pebble accelerometer to detect taps, perform measures at a given frequency, and transmit samples in batches to save CPU time and processing.
For available code samples, see the feature-accel-discs example app.
typedef void(* AccelDataHandler) (AccelData *data, uint32_t num_samples) |
Callback type for accelerometer data events
data | Pointer to the collected accelerometer samples. |
num_samples | the number of samples stored in data. |
typedef void(* AccelDataHandler) (AccelData *data, uint32_t num_samples) |
Callback type for accelerometer data events
data | Pointer to the collected accelerometer samples. |
num_samples | the number of samples stored in data. |
typedef void(* AccelRawDataHandler) (AccelRawData *data, uint32_t num_samples, uint64_t timestamp) |
Callback type for accelerometer raw data events
data | Pointer to the collected accelerometer samples. |
num_samples | the number of samples stored in data. |
timestamp | the timestamp, in ms, of the first sample. |
typedef void(* AccelRawDataHandler) (AccelRawData *data, uint32_t num_samples, uint64_t timestamp) |
Callback type for accelerometer raw data events
data | Pointer to the collected accelerometer samples. |
num_samples | the number of samples stored in data. |
timestamp | the timestamp, in ms, of the first sample. |
typedef void(* AccelTapHandler) (AccelAxisType axis, int32_t direction) |
Callback type for accelerometer tap events
axis | the axis on which a tap was registered (x, y, or z) |
direction | the direction (-1 or +1) of the tap |
typedef void(* AccelTapHandler) (AccelAxisType axis, int32_t direction) |
Callback type for accelerometer tap events
axis | the axis on which a tap was registered (x, y, or z) |
direction | the direction (-1 or +1) of the tap |
enum AccelAxisType |
Enumerated values defining the three accelerometer axes.
enum AccelAxisType |
Enumerated values defining the three accelerometer axes.
enum AccelSamplingRate |
Valid accelerometer sampling rates, in Hz.
enum AccelSamplingRate |
Valid accelerometer sampling rates, in Hz.
struct __attribute__ | ( | (__packed__) | ) |
A single accelerometer sample for all three axes.
A single accelerometer sample for all three axes including timestamp and vibration rumble status.
Data structure for one serialized key/value tuple
acceleration along the x axis
acceleration along the y axis
acceleration along the z axis
true if the watch vibrated when this sample was collected
timestamp, in milliseconds
acceleration along the x axis
acceleration along the y axis
acceleration along the z axis
The key
The type of data that the .value
fields contains.
The length of .value
in bytes
The value itself.
The different union fields are provided for convenience, avoiding the need for manual casts.
The byte array value. Valid when .type
is TUPLE_BYTE_ARRAY.
The C-string value. Valid when .type
is TUPLE_CSTRING.
The 8-bit unsigned integer value. Valid when .type
is TUPLE_UINT and .length
is 1 byte.
The 16-bit unsigned integer value. Valid when .type
is TUPLE_UINT and .length
is 2 byte.
The 32-bit unsigned integer value. Valid when .type
is TUPLE_UINT and .length
is 4 byte.
The 8-bit signed integer value. Valid when .type
is TUPLE_INT and .length
is 1 byte.
The 16-bit signed integer value. Valid when .type
is TUPLE_INT and .length
is 2 byte.
The 32-bit signed integer value. Valid when .type
is TUPLE_INT and .length
is 4 byte.
acceleration along the x axis
acceleration along the y axis
acceleration along the z axis
true if the watch vibrated when this sample was collected
timestamp, in milliseconds
acceleration along the x axis
acceleration along the y axis
acceleration along the z axis
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.
handler | A callback to be executed on accelerometer data events |
samples_per_update | the 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.
void accel_raw_data_service_subscribe | ( | uint32_t | samples_per_update, |
AccelRawDataHandler | handler | ||
) |
Subscribe to the accelerometer raw data event service. Once subscribed, the handler gets called every time there are new accelerometer samples available.
handler | A callback to be executed on accelerometer data events |
samples_per_update | the number of samples to buffer, between 0 and 25. |
int accel_service_peek | ( | AccelData * | data | ) |
Peek at the last recorded reading.
[out] | data | a pointer to a pre-allocated AccelData item |
int accel_service_set_samples_per_update | ( | uint32_t | num_samples | ) |
Change the number of samples buffered between each accelerometer data event
num_samples | the number of samples to buffer, between 0 and 25. |
int accel_service_set_sampling_rate | ( | AccelSamplingRate | rate | ) |
Change the accelerometer sampling rate.
rate | The sampling rate in Hz (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.
handler | A 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.