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();

Comments

  • What board are you using?
  • The Metawear C is what I'm currently testing against....  I believe for production though we are going to look at Metawear R so if it is not an issue there we are good to go...
  • Huh ok.  I'll test it out on a C board.  We definitely addressed this bug in firmware v1.1.3 but it's possible something broke again when we added support for the env and detect accelerometer.
  • Thanks Eric...  please let me know... it is possible i made a mistake.. i am just the optimist and don't think it's likely.
  • Turns out the bug is from the API.  I've fixed the issue and will be releasing it in the next update.
This discussion has been closed.