Exception on accelerometer single axis
Hi,
I’m trying to read accelerometer's Z Axis only (or X, Y), I got an exception:
"Subscribing to single axis sources is not supported. Subscribe to the full data source instead"
Here is my code:
final Bmi160Accelerometer accel = mwBoard.getModule(Bmi160Accelerometer.class);
accel.routeData()
.fromZAxis()
// .process(new Average((byte) 8))
// .process(new Threshold(0.9, Threshold.OutputMode.ABSOLUTE, 1.1))
.stream("accel_stream")
.commit()
.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
public void success(RouteManager result) {
result.subscribe("accel_stream", new RouteManager.MessageHandler() {
public void process(Message msg) {
Log.i(TAG, msg.toString());
}
});
accel.configureAxisSampling()
.setFullScaleRange(Bmi160Accelerometer.AccRange.AR_8G)
.setOutputDataRate(Bmi160Accelerometer.OutputDataRate.ODR_6_25_HZ)
.commit();
accel.enableAxisSampling();
accel.start();
}
public void failure(Throwable error) {
Log.e(TAG, "Read Accel failed: ", error);
}
});
Any ideas?
This discussion has been closed.
Comments
If I subscribe the full xyz values, the threshold filter couldn't work. I got an except of "Cannot detect thresholds on data longer than 4 bytes".