So I'm writing an app that detects movement, and needs to be calibrated to various movements. Over the past few days, I've noticed that right after a SensorEventListener
is registered, onSensorChanged(SensorEvent)
throws out incomplete (and therefore erroneous) .values[]
. This behavior screws up my calibration process, and the amount of force that signifies a movement is way too high. I have verified that this is the case for every accelerometer logging app I have downloaded and tested, so its not an error specific to my code. I think this might be caused by bad hardware (possibly specific to my moto droid 1), or a software bug by the custom ROM I'm using (Simply Stunning 4.9, from Froyo 2.2.1 source.)
Example:
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SENSOR_DELAY);
....
onSensorChanged(SensorEvent event){
// event.values[0] = 0.0
// event.values[1] = -0.47
// event.values[2] = 0.0
}
....
onSensorChanged(SensorEvent event){
// event.values[0] = 0.08
// event.values[1] = -0.47
// event.values[2] = 0.0
}
....
onSensorChanged(SensorEvent event){
// event.values[0] = 0.08
// event.values[1] = -0.47
// event.values[2] = 10.1
}
As you can see, it often takes 2 readings before all of the correct values are accessible.
Can anyone confirm or deny this behavior on the moto droid 1 or other phone? Do you think a good solution is to just drop the first 2 or 3 readings so that they don't warp my calibration?