-
Notifications
You must be signed in to change notification settings - Fork 0
/
puck-loader.js
66 lines (60 loc) · 1.99 KB
/
puck-loader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
NRF.nfcURL("ms-outlook://compose?to=jason@tesseractventures.io"); // MS Outlook
NRF.nfcURL("googlegmail:///co?to=dave@tesseractventures.io"); // Google Mail
NRF.nfcURL("mailto://jason@tesseractventures.io"); // default Apple Mail handler
*/
var puckName = NRF.getAddress();
puckName = puckName.replace(/\W/ig,'');
puckName = puckName.substr(puckName.length - 4).toUpperCase();
NRF.setAdvertising({},{name:"TESS-PIN "+ puckName});
var clickTimer = null;
var resetTimer = null;
var clickCount = 0;
var activeLight = null;
setWatch(function() {
if (clickTimer !== null) {
clearTimeout(clickTimer);
clickTimer = null;
}
clickCount+=1;
clickTimer = setTimeout(function () {
clickTimer = null;
if(clickCount == 1){
setLight(LED1,10);
NRF.nfcURL("mailto:johnb@tesseractventures.io"); // default Apple Mail handler
//NRF.nfcURL("ms-outlook://compose?to=johnb@tesseractventures.io"); // MS Outlook
}else if(clickCount == 2){
setLight(LED2,20);
NRF.nfcURL("googlegmail:///co?to=johnb@tesseractventures.io"); // Google Mail
}else if(clickCount >= 3){
setLight(LED3,30);
//NRF.nfcURL("mailto:johnb@tesseractventures.io"); // default Apple Mail handler
NRF.nfcURL("https://www.linkedin.com/in/johnboucard/");
}
}, 400);
}, BTN, {edge:"falling", debounce:50, repeat:true});
function setLight(light,v) {
NRF.setAdvertising({
0x180F : [v]
},{interval:200});
clickCount = 0;
if (activeLight !== null) {
activeLight.reset();
}
light.set();
activeLight = light;
if (resetTimer !== null) {
clearTimeout(resetTimer);
resetTimer = null;
}
resetTimer = setTimeout(function() {
resetTimer = null;
activeLight.reset();
NRF.setAdvertising({
0x180F : [0]
},{interval:200});
resetTime = setTimeout(function() {
NRF.setAdvertising({});
},1000);
},3000);
}