Hi there,
Is it possible to save acceleration data from Spatial 3/3/3 in an array, in order to apply the FFT? How can I do that on android studio?
Thanks
Can you explain how to do that? I think that I might misunderstand that.Patrick wrote:Hi,
Dump acceleration data into a queue from the AccelerationChange event, and then operate on that queue as you like. I have done this in C#, not sure what FFT libraries are available on Android, but it should be fairly straightforward.
-Patrick
Code: Select all
public class AccelerometerExample extends Activity {
//... Initialization code, etc.
double[][] accelerationArray = new double[10][3];
double[] timestampArray = new double[10];
int accelerationIndex = 0;
class AccelerometerAccelerationChangeEventHandler implements Runnable {
Phidget ch;
AccelerometerAccelerationChangeEvent accelerationChangeEvent;
public AccelerometerAccelerationChangeEventHandler(Phidget ch,
AccelerometerAccelerationChangeEvent accelerationChangeEvent) {
this.ch = ch;
this.accelerationChangeEvent = accelerationChangeEvent;
}
public void run() {
//Adds data to an array
accelerationArray[accelerationIndex][0] =
accelerationChangeEvent.getAcceleration()[0];
accelerationArray[accelerationIndex][1] =
accelerationChangeEvent.getAcceleration()[1];
accelerationArray[accelerationIndex][2] =
accelerationChangeEvent.getAcceleration()[2];
timestampArray[accelerationIndex] =
accelerationChangeEvent.getTimestamp();
accelerationIndex = (accelerationIndex + 1) % 10;
}
}
}
Users browsing this forum: No registered users and 0 guests