Files
led-driver/web/index.html
T
jimmyandClaude Haiku 5.5 d32f3d69cf feat: control several drivers from one web UI
- Device dropdown: All devices, this device by name, then drivers found by
  mDNS (tagged app=led-strip) and any added by hand.
- POST /api/relay: a driver calls another driver's API for the page, so the
  browser only talks to its own board. Limited to /api/*, /ota and /reboot.
- All devices sends brightness and preset plays to every device.
- Settings: sync this device's presets, order and startup to the others.
- CORS for LAN and localhost origins, and an OPTIONS handler for /ota.
- Header labels are removed; the controls keep aria-labels.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-11 02:48:48 +13:00

213 lines
8.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>LED strip</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<header>
<h1>LED strip</h1>
<button id="menuToggle" type="button" class="menu-toggle" aria-controls="menu" aria-expanded="false" aria-label="Menu">
<span class="menu-bars" aria-hidden="true"></span>
</button>
<nav id="menu">
<button class="tab active" data-tab="presets">Presets</button>
<button class="tab" data-tab="settings">Settings</button>
<button id="modeToggle" type="button" class="mode-toggle" aria-pressed="false">Edit mode</button>
<button id="newPreset" type="button" class="tab-action" hidden>+ New preset</button>
<div class="header-device">
<select id="deviceSelect" aria-label="Device"></select>
</div>
<div class="header-bright">
<input type="range" id="globalBright" min="0" max="255" step="1" aria-label="Brightness">
<output id="globalOut"></output>
</div>
</nav>
</header>
<main>
<!-- Front: the preset buttons, each with an Edit button -->
<section id="presets">
<div id="presetList" class="preset-grid"></div>
<p id="status" class="muted" role="status"></p>
</section>
<section id="settings" hidden>
<h2>Devices</h2>
<p class="muted">Control other LED drivers from this page. Add each one by its address, such as 10.1.1.50 or led-desk.local. The list is kept in this browser.</p>
<ul id="devList" class="list"></ul>
<form id="devAdd">
<label>Address
<input id="devHost" maxlength="80" autocomplete="off" placeholder="10.1.1.50">
</label>
<button type="submit">Add device</button>
</form>
<p id="devMsg" class="muted" role="status"></p>
<h2>Presets</h2>
<p class="muted">Adds the default presets (Rainbow, Chase, Aurora, Candle, Twinkle, Flame, Sweep, Off) that are not in the list yet. Your own presets are kept.</p>
<button id="addDefaults" type="button">Add default presets</button>
<p id="defaultsMsg" class="muted" role="status"></p>
<h2>Sync presets</h2>
<p class="muted">Copy this device's presets, their order and its startup preset to every other device. A preset with the same name is replaced. Presets that only the other devices have are kept.</p>
<button id="syncPresets" type="button">Sync presets to other devices</button>
<p id="syncMsg" class="muted" role="status"></p>
<h2>LED strip</h2>
<form id="hwForm">
<label>Number of LEDs
<input type="number" id="hwLeds" min="1" max="512" step="1" required>
</label>
<label>Data pin (GPIO)
<input type="number" id="hwPin" min="0" max="21" step="1" required>
</label>
<p class="muted">0-10 or 20-21. Pins 11-19 are used by the flash and USB.</p>
<label>Colour order
<select id="hwOrder">
<option value="rgb">RGB</option>
<option value="rbg">RBG</option>
<option value="grb">GRB (WS2812 default)</option>
<option value="gbr">GBR</option>
<option value="brg">BRG</option>
<option value="bgr">BGR</option>
</select>
</label>
<label>Max brightness <output id="hwMaxOut"></output>
<input type="range" id="hwMax" min="0" max="255" step="1">
</label>
<button type="submit">Save strip settings</button>
</form>
<p id="hwMsg" class="muted" role="status"></p>
<h2>Firmware</h2>
<p>Running <span id="fwInfo">…</span></p>
<form id="fwForm">
<label>Firmware file (.bin)
<input type="file" id="fwFile" accept=".bin,application/octet-stream">
</label>
<button type="submit" id="fwUpload">Update firmware</button>
</form>
<div class="row">
<button id="fwReboot" type="button" class="btn-secondary">Reboot</button>
</div>
<p id="fwMsg" class="muted" role="status"></p>
<h2>Access point</h2>
<p>Network <strong id="apName">…</strong> (open). Address <strong>192.168.4.1</strong>.</p>
<h2>Wi-Fi client</h2>
<p>Status: <span id="staState">…</span></p>
<button id="scan" type="button">Scan for networks</button>
<ul id="networks" class="list"></ul>
<form id="wifiForm">
<label>Network name (SSID)
<input id="ssid" required maxlength="32" autocomplete="off">
</label>
<label>Password <span class="muted">(blank for open networks)</span>
<input id="pass" type="password" maxlength="64" autocomplete="off">
</label>
<button type="submit">Save and connect</button>
</form>
<p id="wifiMsg" class="muted" role="status"></p>
<h2>Device name and address</h2>
<form id="netForm">
<label>Name (<span id="mdnsName">led</span>.local)
<input id="hostname" required maxlength="63" pattern="[-A-Za-z0-9]+" autocomplete="off">
</label>
<label>Client address
<select id="ipMode">
<option value="dhcp">Automatic (DHCP)</option>
<option value="static">Static</option>
</select>
</label>
<div id="staticFields" hidden>
<label>IP address
<input id="sIp" inputmode="decimal" placeholder="192.168.1.50" autocomplete="off">
</label>
<label>Netmask
<input id="sMask" inputmode="decimal" placeholder="255.255.255.0" autocomplete="off">
</label>
<label>Gateway
<input id="sGw" inputmode="decimal" placeholder="192.168.1.1" autocomplete="off">
</label>
<label>DNS <span class="muted">(optional, blank uses the gateway)</span>
<input id="sDns" inputmode="decimal" autocomplete="off">
</label>
</div>
<button type="submit">Save network settings</button>
</form>
<p id="netMsg" class="muted" role="status"></p>
<p class="muted">The access point always stays at 192.168.4.1, so you can get back in if a setting breaks the client connection.</p>
</section>
</main>
<!-- Preset editor: a child window opened from Edit or New preset -->
<div id="editor-modal" class="modal" hidden>
<div class="modal-content" role="dialog" aria-modal="true" aria-labelledby="editor-title">
<div class="modal-head">
<h2 id="editor-title">Preset</h2>
<button id="editorClose" type="button" class="modal-close" aria-label="Close">×</button>
</div>
<label>Preset name
<input id="presetName" maxlength="31" autocomplete="off" placeholder="e.g. warm chase">
</label>
<label>Pattern
<select id="pattern"></select>
</label>
<div class="field">
<span class="label">Colours</span>
<div id="colours" class="swatches"></div>
<div class="row">
<button id="addColour" type="button">Add colour</button>
<button id="removeColour" type="button">Remove colour</button>
</div>
</div>
<label>Background
<input type="color" id="bg" value="#000000">
</label>
<label>Delay <output id="delayOut"></output>
<input type="range" id="delay" min="10" max="3000" step="10">
</label>
<label>Brightness <output id="brightOut"></output>
<input type="range" id="bright" min="0" max="255" step="1">
</label>
<label>Fade in <output id="fadeOut"></output>
<input type="range" id="fade" min="0" max="5000" step="50">
</label>
<div class="checks">
<label class="check"><input type="checkbox" id="auto"> Keep running (auto)</label>
<label class="check"><input type="checkbox" id="reverse"> Reverse direction</label>
<label class="check"><input type="checkbox" id="beatTime"> Beat timing (quarter beats)</label>
</div>
<label id="styleRow" hidden>Style
<select id="style"></select>
</label>
<div id="numbers" class="numbers"></div>
<p id="presetMsg" class="muted" role="status"></p>
<div class="modal-actions">
<button id="apply" type="button" class="btn-secondary">Apply to strip</button>
<button id="presetStartup" type="button" class="btn-secondary" disabled>Use at startup</button>
<button id="presetDelete" type="button" class="btn-danger" disabled>Delete</button>
<button id="presetSave" type="button">Save preset</button>
</div>
</div>
</div>
<script src="/app.js"></script>
</body>
</html>