More test
This commit is contained in:
parent
130be13b3e
commit
6f8f5bbaf8
26
test.css
Normal file
26
test.css
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
body {
|
||||||
|
font-family: Verdana;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td {
|
||||||
|
width: 150px;
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table thead.headings td {
|
||||||
|
background-color: #666666;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr td {
|
||||||
|
background-color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.button {
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background-color: #666666;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
27
test.html
27
test.html
@ -4,6 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>node-poweredup Web Bluetooth Test</title>
|
<title>node-poweredup Web Bluetooth Test</title>
|
||||||
<script src="./dist/browser/poweredup.js"></script>
|
<script src="./dist/browser/poweredup.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="./test.css" />
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
const poweredUP = new PoweredUP.PoweredUP();
|
const poweredUP = new PoweredUP.PoweredUP();
|
||||||
@ -22,30 +23,24 @@ poweredUP.on("discover", async (hub) => { // Wait to discover hubs
|
|||||||
});
|
});
|
||||||
|
|
||||||
const scan = async function () {
|
const scan = async function () {
|
||||||
alert("ok");
|
|
||||||
poweredUP.scan(); // Start scanning for hubs
|
poweredUP.scan(); // Start scanning for hubs
|
||||||
}
|
}
|
||||||
|
|
||||||
let color = 1;
|
|
||||||
setInterval(() => {
|
|
||||||
|
|
||||||
const hubs = poweredUP.getConnectedHubs(); // Get an array of all connected hubs
|
|
||||||
hubs.forEach((hub) => {
|
|
||||||
hub.setLEDColor(color); // Set the color
|
|
||||||
})
|
|
||||||
color++;
|
|
||||||
if (color > 10) {
|
|
||||||
color = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div><h1>Web Bluetooth node-poweredup Test Suite</h1></div>
|
||||||
<div>
|
<div>
|
||||||
<button onclick="scan()" on>Scan</button>
|
<a class="button" href="#" onclick="scan();">Add new Hub</a>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<table id="log">
|
||||||
|
<thead class="headings"><td>Hub</td><td>Event</td><td>Port/Button</td><td>Values</td></thead>
|
||||||
|
<tr><td>NK_WeDo2_1</td><td>Attach</td><td>A</td><td>Train Motor</td></tr>
|
||||||
|
<tr><td>NK_WeDo2_1</td><td>Button</td><td>GREEN</td><td>Down</td></tr>
|
||||||
|
<tr><td>NK_WeDo2_1</td><td>Button</td><td>GREEN</td><td>Up</td></tr>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user