-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBigRedButtonTest.js
44 lines (36 loc) · 910 Bytes
/
BigRedButtonTest.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
// MIT licensed. (C) Dj Walker-Morgan 2018
var BigRedButton = require('./BigRedButton');
function configureButton(button) {
button.on('buttonPressed', function () {
console.log('button pressed');
});
button.on('buttonReleased', function () {
console.log('button released');
});
button.on('lidRaised', function () {
console.log('lid raised');
});
button.on('lidClosed', function () {
console.log('lid closed');
});
button.on('buttonGone', function () {
console.log('button gone');
setTimeout(newButton,1000);
});
}
// Test a new button
function newButton() {
console.log("Getting button 0")
try {
bigRedButton=new BigRedButton.BigRedButton(0);
}
catch(err) {
console.log("No button, waiting");
setTimeout(newButton,1000);
return;
}
configureButton(bigRedButton);
console.log("Configured button 0")
return;
}
newButton();