Add generic intent "TRIGGER" whenever a trigger is send.

pull/1995/head
David Peer 2022-06-25 10:52:42 +02:00
parent 70fbd194f1
commit 33dc0c566d
2 changed files with 12 additions and 4 deletions

View File

@ -38,8 +38,11 @@ The following icons are currently supported:
3.) Don't forget to select the action that should be executed at the bottom of each automation. 3.) Don't forget to select the action that should be executed at the bottom of each automation.
*Note: There is also an automatic trigger send when the app is started (APP_STARTED) -- so you could # Default Trigger
add an action also for that.* This app also implements two default trigger that can always be used:
- APP_STARTED -- Will be sent whenever the app is started. So you could do some actions already when the app is sarted without the need of any user interaction.
- TRIGGER -- Will be sent whenever some trigger is executed. So you could generically listen to that.
# FAQ # FAQ

View File

@ -101,15 +101,22 @@ Bangle.on('touch', function(btn, e){
Bangle.buzz(40, 0.6); Bangle.buzz(40, 0.6);
position += 1; position += 1;
position = position >= triggers.length ? 0 : position; position = position >= triggers.length ? 0 : position;
draw();
} }
if(isLeft){ if(isLeft){
Bangle.buzz(40, 0.6); Bangle.buzz(40, 0.6);
position -= 1; position -= 1;
position = position < 0 ? triggers.length-1 : position; position = position < 0 ? triggers.length-1 : position;
draw();
} }
if(!isRight && !isLeft){ if(!isRight && !isLeft){
// Send a default intent that we triggered something.
sendIntent("TRIGGER");
// Now send the selected trigger
Bangle.buzz(80, 0.6).then(()=>{ Bangle.buzz(80, 0.6).then(()=>{
sendIntent(triggers[position].trigger); sendIntent(triggers[position].trigger);
setTimeout(()=>{ setTimeout(()=>{
@ -117,8 +124,6 @@ Bangle.on('touch', function(btn, e){
}, 250); }, 250);
}); });
} }
draw();
}); });
// Send intent that the we started the app. // Send intent that the we started the app.