I need to plot a acceleration change on a chart. I've managed to get the value from the accelerometer
Sensor accel = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sensorManager.registerListener(this, accel, SensorManager.SENSOR_DELAY_NORMAL);
And now I just need to plot the acceleration change to signal for example if the user fall down his phone. What I've done :
@Override
public void onSensorChanged(SensorEvent event) {
if (started) {
double x = event.values[0];
double y = event.values[1];
double z = event.values[2];
long timestamp = System.currentTimeMillis();
double sec = (timestamp-timestampStart)/1000.0;
double e = Math.sqrt(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2));
eSeries.add(sec, e);
mChart.repaint();
}
}
The problem is that the value returned by "e" is always close to 10 when the phone is not moving, this should be 0 when their is no change... Do you know what is wrong ?