forked from aydinakcasu/ChromeBluetooth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuckAll.html
57 lines (47 loc) · 1.4 KB
/
puckAll.html
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
<html>
<head>
<script src="https://www.puck-js.com/puck.js"></script>
</head>
<body>
<button onclick="connect()">Connect</button>
<button onclick="stop()">Stop</button>
<button onclick="readAll()">Read</button>
<button onclick="magOn()">magOn</button>
<br/>lightSensor_value<input type="text" id="lightSensor_value" value="0" style="width:60px" readonly/>
<br/>mag_value<input type="text" id="mag_value" value="0" style="width:60px" readonly/>
<br/>
<button onclick="Puck.write('LED1.set();\n');">On!</button>
<button onclick="Puck.write('LED1.reset();\n');">Off!</button>
<br/>
<button onclick="Puck.write('LED2.set();\n');">On!</button>
<button onclick="Puck.write('LED2.reset();\n');">Off!</button>
<br/>
<button onclick="Puck.write('LED3.set();\n');">On!</button>
<button onclick="Puck.write('LED3.reset();\n');">Off!</button>
</body>
</html>
<script type="text/javascript">
function connect()
{
Puck.connect();
}
function magOn()
{
Puck.magOn();
}
function stop()
{
Puck.magOff();
}
function readAll() {
Puck.eval("Puck.light()", function(v) {
document.getElementById('lightSensor_value').value = v;
});
Puck.on('mag', function(xyz) {
document.getElementById('mag_value').value = v;
});
setTimeout(function() {
readAll();
}, 250);
}
</script>