Reputation: 459
I am trying to read both gyroscope and linear_acclerometer data in the highest sample rate on my Moto 360 . I will press a button on the handheld, which will register sensors on the watch and start loggging all the sensor data, and when I press another button, the watch will unregister these sensors and stop logging.
However, the sensor value will become a constant value sometimes. I found if I restart the watch, the sensor will start working and generate meaningful sensor value again.
Does anyone has encounter the similar problem or have some ideas on why this may happen ?
private void startSensorListeners() {
Log.d(TAG, "startSensorListeners");
isCollecting = true;
//Register the motion Sensor Listener
mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SENSOR_DELAY);
mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION), SENSOR_DELAY);
}
public void stopSensorListeners() {
isCollecting = false;
mSensorManager.unregisterListener(this);
}
public final void onSensorChanged(SensorEvent event) {
if(!isCollecting){
mSensorManager.unregisterListener(this, event.sensor);
return ;
}
// Save sensordata into local files, I also output the values[] in event on the logcat to monitor the sensor values in the realtime.
saveData(event);
}
Thanks
Upvotes: 0
Views: 676
Reputation: 2070
I don't have an actual answer for this. I'm just sharing my problem because I feel like they are very similar. The problem occurs on a Moto 360 and was not tested on another device.
I use the Magnetic sensor.
mMagneticSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
I register my Fragment as a listener to new values.
mSensorManager.registerListener(this, mMagneticSensor, SensorManager.SENSOR_DELAY_NORMAL);
I was developing an application. At the beginning, they were changing as expected but, after ~an hour, the values from the sensor just froze, remaining exactly the same no matter what.
I suspect two things: battery level and data rate renewal.
Maybe the battery dropped below some acceptable level (was around 25% when it stopped working)... it would be weird but it would not a big surprise.
Secondly, I remember having changed SensorManager.
SENSOR_DELAY_NORMAL) to SensorManager.
SENSOR_DELAY_UI) at some point, not long before the values froze. Perhaps it's a coincidence. The SensorManager.SENSOR_DELAY_UI is a faster data rate renewal than SensorManager.SENSOR_DELAY_NORMAL and as I was modifying a bitmap each time I got a new value. Maybe a buffer was full and wasn't emptied...maybe
Anyway, if I got some news on this subject I will update this post.
Upvotes: 1