Skip to content

Instantly share code, notes, and snippets.

@HongyiZhu
Created Oct 10, 2016
Embed
What would you like to do?
The Macro to enable offline button actions
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