Accellerometer monitor

Hallo, my name is Stefano

I'm new to this nice tool, so be patient if I'm doing a very stupid mistake.

Following the sample in the online documentation I'm trying to do something when the device move.

I'm expecting to see "movement" in the debug log when the board moves whit more than 0,5f. But nothing happen.

Thanks in advance.

This is the part of the code I'm using:

public void connected() {
Log.i(LOG_TAG, "Connected");

try {
accelModule= mwBoard.getModule(Accelerometer.class);

accelModule.setOutputDataRate(50f); ///< Set operating freq to 50Hz
accelModule.routeData().fromAxes()
.process(new Accumulator())
.process(new Threshold(0.5f, Threshold.OutputMode.BINARY))
.split()
.branch().process(new Comparison(Comparison.Operation.EQ, 1))
.monitor(new DataSignal.ActivityHandler() {
@Override
public void onSignalActive(Map<String, DataProcessor> processors, DataSignal.DataToken token) {
Log.e(LOG_TAG, "movement");
}
})
.end()

.commit()


catch (UnsupportedModuleException e) {
Log.e(LOG_TAG, "Cannot find module", e);
}
}

@Override
public void disconnected() {
Log.i(LOG_TAG, "Disconnected");
}
});
        mwBoard.connect();
}

Comments

  • As stated in the documentation, a monitor should only contain metawear functions as it is programming the board to react every time new sensor data is available.  If you want your android device to react instead, you need to stream the data to the device.

    Always attach a CompletionHandler to async operations as the success and failure functions will alert you to if the task succeeded.  In your code, you cannot directly apply an accumulator to the 3-axis data.
This discussion has been closed.