-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxxx.js
46 lines (39 loc) · 1.14 KB
/
xxx.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
// JavaScript source code
// Globals
var IsSleeping = false;
var interval;
NRF.setTxPower(-16);
function SetAdvertising() {
// {0x2A19:[E.getBattery()]},{0x2a04:[String(Puck.light())]}
NRF.setAdvertising({},
{interval: 5000, showName:false, manufacturer: 0x0590, manufacturerData:[E.getBattery(),Math.round(Puck.light()*100)]});
}
//[E.getBattery(),Math.round(Puck.light()*100)/100]
// manufacturer: 0x0590
//["a","bbb","ccc"]
setWatch(function (e) {
if (IsSleeping) {
LED2.write(true); // Green = wake
//NRF.wake();
setTimeout(function () {
//DoTheDo();
LED2.write(false);
IsSleeping = false;
}, 200);
}
else {
LED1.write(true); // Red = sleep
//clearInterval(interval);
setTimeout(function () {
//NRF.setAdvertising({});
//NRF.sleep();
LED1.write(false);
IsSleeping = true;
}, 200);
}
}, BTN, { edge: "rising", repeat: true, debounce: 50 });
(function DoTheDo() {
interval = setInterval(function () {
SetAdvertising();
}, 10000);
})();