Skip to content

Commit 570b976

Browse files
committed
fix indent
1 parent 53daf7c commit 570b976

File tree

1 file changed

+84
-84
lines changed

1 file changed

+84
-84
lines changed

apps/bleeverything/app.js

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -3,124 +3,124 @@ NRF.setTxPower(4); // Full Power advertising
33

44
//Send MQTT Advertisements & Console Logs Every Minute while Button State === 1
55
setInterval(function () {
6-
setTimeout(function(){
7-
if(state === 1){
8-
console.log("temperature : " + [Math.round((E.getTemperature()*9/5)+32)]);
9-
NRF.setAdvertising({
10-
0x1809 : [Math.round((E.getTemperature()*9/5)+32)]
11-
});
12-
}
13-
},1);
6+
setTimeout(function(){
7+
if(state === 1){
8+
console.log("temperature : " + [Math.round((E.getTemperature()*9/5)+32)]);
9+
NRF.setAdvertising({
10+
0x1809 : [Math.round((E.getTemperature()*9/5)+32)]
11+
});
12+
}
13+
},1);
1414

15-
setTimeout(function(){
16-
if(state === 1){
17-
console.log("battery : " + [Puck.getBatteryPercentage()]);
18-
NRF.setAdvertising({
19-
0x180F : [Puck.getBatteryPercentage()]
20-
});
21-
}
22-
},5000);
15+
setTimeout(function(){
16+
if(state === 1){
17+
console.log("battery : " + [Puck.getBatteryPercentage()]);
18+
NRF.setAdvertising({
19+
0x180F : [Puck.getBatteryPercentage()]
20+
});
21+
}
22+
},5000);
2323

24-
setTimeout(function(){
25-
if(state === 1){
26-
console.log("Voltage : " + [String(Math.round(analogRead(D30)*6.6 * 100) / 100)]);
27-
NRF.setAdvertising({
28-
0x182a : [String(Math.round(analogRead(D30)*6.6 * 100) / 100)]
29-
});
30-
}
31-
},10000);
24+
setTimeout(function(){
25+
if(state === 1){
26+
console.log("Voltage : " + [String(Math.round(analogRead(D30)*6.6 * 100) / 100)]);
27+
NRF.setAdvertising({
28+
0x182a : [String(Math.round(analogRead(D30)*6.6 * 100) / 100)]
29+
});
30+
}
31+
},10000);
3232

33-
setTimeout(function(){
34-
if(state === 1){
35-
console.log("Light : " + [String(Puck.light())]);
36-
NRF.setAdvertising({
37-
0x182b : [String(Puck.light())]
38-
});
39-
}
40-
},15000);
33+
setTimeout(function(){
34+
if(state === 1){
35+
console.log("Light : " + [String(Puck.light())]);
36+
NRF.setAdvertising({
37+
0x182b : [String(Puck.light())]
38+
});
39+
}
40+
},15000);
4141

42-
setTimeout(function(){
43-
if(state === 1){
44-
console.log("LEDs: " + [[digitalRead(LED1).toString(16)], [digitalRead(LED2).toString(16)], [digitalRead(LED2).toString(16)]]);
45-
NRF.setAdvertising({
46-
0x183d : [[digitalRead(LED1).toString(16)], [digitalRead(LED2).toString(16)], [digitalRead(LED2).toString(16)]]
47-
});
48-
}
49-
},20000);
42+
setTimeout(function(){
43+
if(state === 1){
44+
console.log("LEDs: " + [[digitalRead(LED1).toString(16)], [digitalRead(LED2).toString(16)], [digitalRead(LED2).toString(16)]]);
45+
NRF.setAdvertising({
46+
0x183d : [[digitalRead(LED1).toString(16)], [digitalRead(LED2).toString(16)], [digitalRead(LED2).toString(16)]]
47+
});
48+
}
49+
},20000);
5050
},60000);
5151

5252

5353
//Button Press
5454
//Turn Off/On MQTT Advertising
5555
var pressCount = 0;
5656
setWatch(function() {
57-
pressCount++;
58-
state = (pressCount+1)%2;
59-
if ((pressCount+1)%2) digitalPulse(LED3,1,1500); //long flash blue light
60-
else
61-
digitalPulse(LED3,1,100); //short flash blue light
62-
console.log('button_press_count : [' + pressCount + ']');
63-
console.log('button_state : [' + (pressCount+1) + ']');
64-
console.log('state: ' + state);
65-
NRF.setAdvertising({
66-
0xFFFF : [pressCount],
67-
0x183c: [((pressCount+1)%2)],
68-
});
57+
pressCount++;
58+
state = (pressCount+1)%2;
59+
if ((pressCount+1)%2) digitalPulse(LED3,1,1500); //long flash blue light
60+
else
61+
digitalPulse(LED3,1,100); //short flash blue light
62+
console.log('button_press_count : [' + pressCount + ']');
63+
console.log('button_state : [' + (pressCount+1) + ']');
64+
console.log('state: ' + state);
65+
NRF.setAdvertising({
66+
0xFFFF : [pressCount],
67+
0x183c: [((pressCount+1)%2)],
68+
});
6969
}, BTN, { edge:"rising", repeat:true, debounce:50 });
7070

7171

7272
//Movement Sensor
7373
require("puckjsv2-accel-movement").on();
7474
var idleTimeout;
7575
Puck.on('accel',function(a) {
76-
digitalWrite(LED1,1); //turn on red light
76+
digitalWrite(LED1,1); //turn on red light
7777
if (idleTimeout) clearTimeout(idleTimeout);
7878
else
79+
if (state === 1) {
80+
console.log('movement : 1');
81+
NRF.setAdvertising({
82+
0x182e: [1],
83+
});
84+
}
85+
idleTimeout = setTimeout(function() {
86+
idleTimeout = undefined;
87+
digitalWrite(LED1,0);//turn off red light
7988
if (state === 1) {
80-
console.log('movement : 1');
81-
NRF.setAdvertising({
82-
0x182e: [1],
83-
});
89+
console.log('movement : 0');
90+
NRF.setAdvertising({
91+
0x182e: [0],
92+
});
8493
}
85-
idleTimeout = setTimeout(function() {
86-
idleTimeout = undefined;
87-
digitalWrite(LED1,0);//turn off red light
88-
if (state === 1) {
89-
console.log('movement : 0');
90-
NRF.setAdvertising({
91-
0x182e: [0],
92-
});
93-
}
94-
},500);
94+
},500);
9595
});
9696

9797

9898
//Magnetic Field Sensor
9999
require("puckjsv2-mag-level").on();
100100
Puck.on('field',function(m) {
101-
digitalPulse(LED2, 1, 200);//flash green light
102-
if (state === 1) {
103-
console.log('magnetic_field : [' + m.state + ']');
104-
NRF.setAdvertising({
105-
0x183a: [m.state],
106-
});
107-
}
101+
digitalPulse(LED2, 1, 200);//flash green light
102+
if (state === 1) {
103+
console.log('magnetic_field : [' + m.state + ']');
104+
NRF.setAdvertising({
105+
0x183a: [m.state],
106+
});
107+
}
108108
});
109109

110110

111111
//NFC Detection
112112
NRF.nfcURL("http://espruino.com");
113113
NRF.on('NFCon', function() {
114-
digitalPulse(LED2, 1, 500);//flash on green light
115-
console.log('nfc_field : [1]');
116-
NRF.setAdvertising({
117-
0x183e: [1],
118-
});
114+
digitalPulse(LED2, 1, 500);//flash on green light
115+
console.log('nfc_field : [1]');
116+
NRF.setAdvertising({
117+
0x183e: [1],
118+
});
119119
});
120120
NRF.on('NFCoff', function() {
121-
digitalPulse(LED2, 1, 200);//flash on green light
122-
console.log('nfc_field : [0]');
123-
NRF.setAdvertising({
124-
0x183e: [0],
125-
});
121+
digitalPulse(LED2, 1, 200);//flash on green light
122+
console.log('nfc_field : [0]');
123+
NRF.setAdvertising({
124+
0x183e: [0],
125+
});
126126
});

0 commit comments

Comments
 (0)