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