-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
33 lines (26 loc) · 880 Bytes
/
index.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
<!doctype html>
<html>
<head>
<title>Thingy:52 Web Bluetooth</title>
</head>
<body>
<button id="connectBtn">Connect</button>
<div id="temperature"></div>
<script type="module">
import {Thingy} from "./js/thingy.js";
const thingy = new Thingy({logEnabled: true});
async function start(device) {
await device.connect();
await device.ledBreathe({color: "red", intensity: 10, delay: 1500});
await device.temperatureEnable(onTemperatureUpdate, true);
}
function onTemperatureUpdate(data) {
const el = document.querySelector("#temperature");
el.innerHTML = `Temperature: ${data.value.toFixed(1)} ${data.unit}`;
}
document.querySelector("#connectBtn").addEventListener("click", async () => {
await start(thingy);
})
</script>
</body>
</html>