<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="not_webusb.js"></script>
<script>
async function read_write() {
let input_slider = document.getElementById("input");
let output_div = document.getElementById("output");
let input = new Uint8Array([input_slider.value]);
console.log(input);
try {
await not_webusb_read_write(input);
} catch (e) {
if (!(e instanceof NotWebusbInUseException)) {
output_div.innerText = "Failed to communicate with device:\n" + e;
output_div.style = "color: red";
throw e;
}
}
}
async function set_up() {
document.getElementById("input").oninput = read_write
}
window.onload = set_up;
</script>
</head>
<body>
<h1>blinker</h1>
<p>
Flash the firmware by running:
<pre>
cd examples/pico
cargo run --release --bin blinker</pre>
Then move the slider below and observe the changing rate of blinking on the device.</p>
<input type="range" min="1" max="255" value="128" class="slider" id="input" style="width:100%">
<div id="output"></div>
</body>
</html>