Accel is a simple library written in C that uses accelerometer data to find gestures in realtime. Though it is written with the Pebble in mind, it should work with other embedded devices as well.
All methods in the accel API return a success value or error codes.
Return values are as follows:
ACCEL_SUCCESS
- the method being called is successful.ACCEL_PARAM_ERROR
- parameters being passed are invalid.ACCEL_MALLOC_ERROR
- returned when malloc failsACCEL_NO_VALID_GESTURE
- when gestures are queried, this value is returned when there are no applicable gestures.ACCEL_INTERNAL_ERROR
- there is an internal error in the accel library, usually due to consistency issues in parameter attributes. It's best to report these.
int accel_generate_state(accel_state **state, int dimensions, int window_size)
- Generates and sets up a valid
accel_state
object that tracks input ofdimensions
dimensions, using a rolling window of sizewindow_size
to smooth measurements.
- Generates and sets up a valid
int accel_destroy_state(accel_state **state)
- Destroys any
accel_state
objects passed in, and resetsstate
to point to theNULL
value.
- Destroys any
int accel_start_record_gesture(accel_state *state, int *gesture)
- Starts to record a gesture, saving the gesture id to
gesture
.
- Starts to record a gesture, saving the gesture id to
int accel_end_record_gesture(accel_state *state, int gesture_id)
- Completes recording the gesture at gesture id
gesture_id
.
- Completes recording the gesture at gesture id
int accel_process_timer_tick(accel_state *state, int *accel_data)
- Called whenever a tick happens, this allows
accel
to update projected most-likely gestures.
- Called whenever a tick happens, this allows
int accel_find_most_likely_gesture(accel_state *state, int *gesture_id, int *distance)
- Returns the id of the gesture that is most likely to have occurred.
Getting the accel source is easy. Simply clone the github repository as follows:
git clone https://github.com/shalecraig/accel.git
Simply copy all files from the accel/src
directory in accel into the accel/src
directory in your pebble app. The pebble build
command will find the newly added files, so everything should work smoothly.
cp accel/src/* myproject/src/
A sample of library usage is in the accel/samples
directory.
The source code is in the accel/src
directory. Simply include accel.h
and make sure you compile all files. If you needed to make changes, feel free to submit pull requests to the accel repo.
After going to the test directory (cd test/
), running make run
should execute tests successfully.
TODO: As of right now, C tests are compiled by the C++ compiler. We should fix this.
The accel version is currently 1.0.0b.
This version is defined in accel.h
as ACCEL_VERSION_CODE
, which is generated using the ACCEL_VERSION_GEN
macro.
Gesture recognition adapted from:
- Jiayang Liu, Zhen Wang, Lin Zhong, Jehan Wickramasuriya, and Venu Vasudevan, "uWave: Accelerometer-based personalized gesture recognition and its applications," in Proc. IEEE Int. Conf. Pervasive Computing and Communication (PerCom), March 2009.