Created
November 5, 2011 09:41
-
-
Save simekadam/1341325 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ramp-speed - play with this value until satisfied | |
final float kFilteringFactor = 0.0f; | |
//last result storage - keep definition outside of this function, eg. in wrapping object | |
float accel[] = new float[3]; | |
float result[] = new float[3]; | |
//acceleration.x,.y,.z is the input from the sensor | |
//result.x,.y,.z is the filtered result | |
//high-pass filter to eleminate gravity | |
accel[0] = event.values[0] * kFilteringFactor + accel[0] * (1.0f - kFilteringFactor); | |
accel[1] = event.values[1] * kFilteringFactor + accel[1] * (1.0f - kFilteringFactor); | |
accel[2] = event.values[2] * kFilteringFactor + accel[2] * (1.0f - kFilteringFactor); | |
result[0] = event.values[0] - accel[0]; | |
result[1] = event.values[1] - accel[1]; | |
result[2] = event.values[2] - accel[2]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment