-
-
Save HongyiZhu/b8cdb07a88cf8dbd89ac866f277dfd4d to your computer and use it in GitHub Desktop.
The Macro to enable offline button actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_module.record(new Macro.CodeBlock() { | |
@Override | |
public void commands() { | |
switch_module.routeData().fromSensor().monitor(new DataSignal.ActivityHandler() { | |
@Override | |
public void onSignalActive(Map<String, DataProcessor> map, DataSignal.DataToken dataToken) { | |
settings_module.configure().setDeviceName("BtnPrs").commit(); | |
led_module.configureColorChannel(Led.ColorChannel.RED) | |
.setHighIntensity((byte) 31) | |
.setPulseDuration((short) 2000) | |
.setHighTime((short) 1500) | |
.setRiseTime((short) 0) | |
.setFallTime((short) 0) | |
.commit(); | |
led_module.play(true); | |
} | |
}).commit().onComplete(new AsyncOperation.CompletionHandler<RouteManager>() { | |
@Override | |
public void success(RouteManager result) { | |
Log.i("Btn Press Route", String.valueOf(result.id())); | |
} | |
@Override | |
public void failure(Throwable error) { | |
error.printStackTrace(); | |
} | |
}); | |
} | |
@Override | |
public boolean execOnBoot() { | |
return false; | |
} | |
}).onComplete(new AsyncOperation.CompletionHandler<Byte>() { | |
@Override | |
public void success(Byte result) { | |
macro_ID = result; | |
} | |
@Override | |
public void failure(Throwable error) { | |
error.printStackTrace(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment