-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
35 lines (33 loc) · 1.23 KB
/
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
33
34
35
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Tomu WebUSB LED</title>
</head>
<body>
<h1>Tomu WebUSB Simple LED Demo</h1>
<p>This interacts with the <a href="https://github.com/im-tomu/tomu-samples/tree/master/usb_simple">usb_simple</a> sample.</p>
<button id="connect">Grab device</button>
<button id="off" disabled>Off</button>
<button id="green" disabled>Green</button>
<button id="red" disabled>Red</button>
<button id="both" disabled>Green + Red</button>
<script type="module">
import TomuLight from "./tomu-light.js";
let light;
connect.addEventListener("click", async function () {
light = await TomuLight.get();
console.log("Connected:", light);
for (let button of [off, red, green, both])
button.disabled = false;
});
off.addEventListener("click", () => light.off());
green.addEventListener("click", () => light.green());
red.addEventListener("click", () => light.red());
both.addEventListener("click", () => light.both());
</script>
<p>On Linux, you will need a udev rule similar to this:</p>
<pre><code>ACTION=="add|change", SUBSYSTEM=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="70b1", TAG+="uaccess"</code></pre>
</body>
</html>