Macro Acceleromter
I found an older thread
and looked at the latest android release notes
which indicate there was a problem with starting the acceleromter in a macro... which subsequently has been fixed. However, I am not sure this is fixed. The following segment of code works the first time. I remove the battery and it does not work as I would expect... I have tried several permutations of the code (i.e. not removing routes) to no avail..
final Macro macroModule= mwBoard.getModule(Macro.class);
macroModule.eraseMacros();
macroModule.record(new Macro.CodeBlock() {
@Override
public void commands() {
try {
mwBoard.removeRoutes();
final Accelerometer accelModule = mwBoard.getModule(Accelerometer.class);
final Led ledModule= mwBoard.getModule(Led.class);
accelModule.setOutputDataRate(50.f);
// Set the measurement range to +/- 4g, or closet valid range
accelModule.setAxisSamplingRange((float) 2.0);
accelModule.enableAxisSampling();
accelModule.stop();
accelModule.start();
//Stomach
accelModule.routeData().fromYAxis()
.process(new Maths(Maths.Operation.ADD, 0))
.split()
.process("temp_cond_gate", new Passthrough(Passthrough.Mode.CONDITIONAL, (short) 1))
.process("temp_cond_gate2", new Passthrough(Passthrough.Mode.CONDITIONAL, (short) 1))
.process(new Time(Time.OutputMode.ABSOLUTE, 2))
.monitor(new DataSignal.ActivityHandler() {
@Override
public void onSignalActive(Map<String, DataProcessor> processors,
DataSignal.DataToken token) {
ledModule.stop(true);
ledModule.configureColorChannel(Led.ColorChannel.RED)
.setRiseTime((short) 0)
.setPulseDuration((short) 2000).setRepeatCount((byte) -1)
.setHighTime((short) 1000).setHighIntensity((byte) 31)
.setLowIntensity((byte) 31).commit();
ledModule.play(true);
}
}).end()
.commit();
This discussion has been closed.
Comments