Adding a delay or wait component in a offline connection
Hi,
I am trying to use a MetaWear c sensor to detect shocks applied to a body using accelerometer and turn a LED on for 4 seconds. And in this case, sensor should detect the shocks in offline mode. I developed a code with the help of freefall example and react component to detect and turn the led on.
But now I need to stop detecting any more shocks while the LED is on and resume detecting shocks when LED is off. I couldn't figure out how to achieve this.
Here is the code snippet I used to configure the MetaWear Sensor.
return accelerometer.acceleration().addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteComponent source) {
source.map(Function1.RMS).average((byte) 4).filter(ThresholdOutput.BINARY, 0.8)
.filter(Comparison.EQ, 1)
.react(new RouteComponent.Action() {
@Override
public void execute(DataToken token) {
led.editPattern(Led.Color.GREEN)
.riseTime((short) 0)
.pulseDuration((short) 1000)
.repeatCount((byte) 4)
.highTime((short) 500)
.highIntensity((byte) 16)
.lowIntensity((byte) 16)
.commit();
led.play();
}
});
}
});
Can anyone please help me regarding this ?
Thanks.
Comments
Wrap your code with Markdown code tags so it renders correctly
Hi Eric,
Please find my code below. It would be great if you can help me on this matter.
`board.connectAsync().onSuccessTask(new Continuation<Void, Task>() {
@Override
public Task then(Task task) {
Hi All,
Can I start or stop a task created using timer from inside a MetaWear react component. When I try to implement that MetaWear board fails to configure.
Below is my code
`board.connectAsync().onSuccessTask(new Continuation<Void, Task>() {
@Override
public Task then(Task task) {
Markdown code blocks are 3 ticks not 1. Please fix your posts and double check that your code blocks are rendering correctly.
Post the exceptions / error messages generated by your timer code.