Acceleration to response time
in
Android Processing
•
6 months ago
Hi there, I am a noop, so please be patient. I am wondering whether someone has experience of converting accelerometer data into response times. I am using the ketai library to access the accelerometer to measure responses to stimuli. Would people be aware of how to transform te continuos acceleration data into discrete response time. Any ideas and suggestion would be much appreciated.
//Accelerometer app
//01.04.13 measure the xyz accelerometer values over 3 sec and writes data in a file
import ketai.sensors.*;
Table table; //table for data
int time; //time in miliseccond
PVector accelerometer; //accelerometer variable
KetaiSensor sensor; //Ketai Sensor for accelerometer data
PImage catimg,dogimg; //Cat and Dog image variables
void setup() {
table = createTable();
table.addColumn("Time"); //adds a time column
table.addColumn("AccelerometerX"); //adds a accel.x column
table.addColumn("AccelerometerY"); //adds a accel.z column
table.addColumn("AccelerometerZ"); //adds a accel.y column
sensor = new KetaiSensor(this);
sensor.start();
accelerometer = new PVector();
orientation (LANDSCAPE);
frameRate(30);
}
void draw() {
time = millis(); //time before
while (millis() - time < 3000) { //time now minus before smaller 3 seconds do
TableRow newRow = table.addRow();
newRow.setInt("Time", time);
newRow.setFloat("AccelerometerX", accelerometer.x);
newRow.setFloat("AccelerometerY", accelerometer.y);
newRow.setFloat("AccelerometerZ", accelerometer.z);
}
saveTable(table, "/mnt/sdcard/Tom/n2.csv");
println("data saved.");
sensor.stop();
exit();
}
void onAccelerometerEvent(float x, float y, float z) {
accelerometer.x = x;
accelerometer.y = y;
accelerometer.z = z;
}
1