Skip to content

Instantly share code, notes, and snippets.

@attilavago
Last active April 4, 2020 12:18
Show Gist options
  • Save attilavago/cd42bae3de0b5f3f1df92b0a6f6251f0 to your computer and use it in GitHub Desktop.
Save attilavago/cd42bae3de0b5f3f1df92b0a6f6251f0 to your computer and use it in GitHub Desktop.
PowerPoint presenter using a Puck.js beacon's button only!
var kb = require("ble_hid_keyboard");
NRF.setServices(undefined, { hid : kb.report });
var reset_timer;
var next = "n";
var prev = "p";
function sendPrev(){
sendCharPrev();
LED2.set();
setTimeout("LED2.reset()",1000);
}
function sendNext(){
sendCharNext();
LED2.set();
setTimeout("LED2.reset()",1000);
}
function sendCharNext(){
if (next == next.toLowerCase()){
sk = 0;
} else {
sk = 0x02;
}
// send the "n" keyboard character
kb.tap(kb.KEY[next.toUpperCase()], sk);
}
function sendCharPrev(){
if (prev == prev.toLowerCase()){
sk = 0;
} else {
sk = 0x02;
}
// send the "p" keyboard character
kb.tap(kb.KEY[prev.toUpperCase()], sk);
}
setWatch(function(e) {
if(e.time-e.lastTime > 0.5){ // on long press slide goes one step back
sendPrev();
}
}, BTN, {edge:"falling", debounce:50, repeat:true});
setWatch(function(e) {
if(e.time-e.lastTime < 0.5){ // on short press slide goes one step forward
sendNext();
}
}, BTN, {edge:"falling", debounce:50, repeat:true});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment