Channel 11 defaults, ESP-NOW driver config and rig/desktop updates

Moves the controller, bridge and led-driver default ESP-NOW channel to 11 and
updates the led-driver and led-tool submodule pointers. Includes the rest of the
working tree: web UI, desktop and sim-controller changes, API and bridge code,
graphify output, and the .gitea and fixture-driver folders.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Haiku 5.5 committed 2026-11-21 01:19:02 +13:00
1 parent 35207a868a
commit edf35e9c71
280 files changed
+24043 -1756

No files matched your search

+97 -5
View File
@@ -173,7 +173,9 @@ async function runEspnowPing({ btn, dot, statusEl } = {}) {
const res = await fetch('/devices/ping', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({ timeout_s: 3 }),
// Broadcast: one frame every driver hears. A unicast to each known device makes the radio wait out every
// absent board's retries, and the frames queued behind them (live drivers' among them) are dropped.
body: JSON.stringify({ timeout_s: 3, broadcast: true }),
});
const data = await res.json().catch(() => ({}));
if (!res.ok || !data.ok) {
@@ -301,6 +303,14 @@ function applyTransportVisibility(transport) {
if (drvWrap) drvWrap.hidden = !isWifi;
}
/** A whole number from an input, clamped to lo..hi, or null when it is blank. */
function readIntInRange(id, lo, hi) {
const el = document.getElementById(id);
if (!el || el.value === '') return null;
const n = parseInt(el.value, 10);
return Number.isNaN(n) ? null : Math.max(lo, Math.min(hi, n));
}
function readMaxBrightness(id) {
const el = document.getElementById(id);
if (!el || el.value === '') return null;
@@ -389,6 +399,14 @@ function collectDeviceEditPayload() {
if (!Number.isNaN(n) && n >= 1) payload.num_leds = n;
}
if (co && co.value) payload.color_order = co.value;
// Sent to the driver over ESP-NOW (device_config); blank leaves the driver's own value
const pin = readIntInRange('edit-device-espnow-pin', 0, 21);
if (pin != null) {
if (pin > 10 && pin < 20) return { devId, payload, error: 'Data pin must be 0–10, 20 or 21 (11–19 are the flash and USB)' };
payload.pin = pin;
}
const ch = readIntInRange('edit-device-espnow-channel', 1, 13);
if (ch != null) payload.espnow_channel = ch;
}
return { devId, payload };
}
@@ -501,6 +519,35 @@ function createDeviceIdentifyButton(devId) {
return identifyBtn;
}
// "Hide sim devices": a class on the list hides its sim rows (style.css), so it holds across the live
// refresh's re-renders and works alongside the search. Remembered in this browser.
const HIDE_SIM_KEY = 'devices.hideSim';
function readHideSim() {
try {
return localStorage.getItem(HIDE_SIM_KEY) === '1';
} catch (e) {
return false;
}
}
function applyHideSim(hide) {
const list = document.getElementById('devices-list-modal');
if (list) list.classList.toggle('hide-sim', hide);
try {
localStorage.setItem(HIDE_SIM_KEY, hide ? '1' : '0');
} catch (e) {
// private window or blocked storage: the choice lasts until the page reloads
}
}
function updateSimDeviceCount(container) {
const el = document.getElementById('devices-sim-count');
if (!el) return;
const n = container.querySelectorAll(':scope > .profiles-row[data-device-kind="sim"]').length;
el.textContent = n ? `(${n})` : '';
}
function renderDevicesList(devices) {
const container = document.getElementById('devices-list-modal');
if (!container) return;
@@ -551,12 +598,17 @@ function renderDevicesList(devices) {
label.style.minWidth = '100px';
// Simulated (a driver of the rig page at /sim/, heard on the browser bridge) or a real board
// or a fixture of a DMX bridge (a driver the controller runs, sent out as DMX)
const isSim = !!(dev && dev.sim);
const isDmx = !isSim && !!(dev && dev.dmx_fixture);
const kindName = isSim ? 'sim' : isDmx ? 'dmx' : 'real';
row.dataset.deviceKind = kindName; // "Hide sim devices" hides rows by this (style.css)
const kind = document.createElement('span');
kind.className = `device-kind-badge device-kind-badge--${isSim ? 'sim' : 'real'}`;
kind.textContent = isSim ? 'sim' : 'real';
kind.className = `device-kind-badge device-kind-badge--${kindName}`;
kind.textContent = kindName === 'dmx' ? 'DMX' : kindName;
kind.title = isSim
? 'Simulated: a driver on the rig page (/sim/), reached over the browser bridge'
: isDmx ? `A DMX fixture of the bridge ${dev.bridge || ''}: a driver the controller runs, sent out as DMX`
: 'A real board';
const editBtn = document.createElement('button');
@@ -570,7 +622,7 @@ function renderDevicesList(devices) {
deleteBtn.className = 'btn btn-secondary btn-small';
deleteBtn.textContent = 'Delete';
deleteBtn.addEventListener('click', async () => {
if (!confirm(`Delete device "${(dev && dev.name) || devId}"?`)) return;
if (!await uiConfirm(`Delete device "${(dev && dev.name) || devId}"?`)) return;
try {
const res = await fetch(`/devices/${encodeURIComponent(devId)}`, { method: 'DELETE' });
if (res.ok) await loadDevicesModal();
@@ -592,6 +644,7 @@ function renderDevicesList(devices) {
row.appendChild(deleteBtn);
container.appendChild(row);
});
updateSimDeviceCount(container);
// Do not re-apply lastTcpSnapshotIps here: it is only updated on WS open and
// device_tcp events; re-applying after each /devices poll overwrites correct
// API "connected" with a stale list and leaves Wi-Fi rows stuck online.
@@ -630,6 +683,11 @@ function openEditDeviceModal(devId, dev) {
? String(co).toLowerCase()
: 'rgb';
}
// What the driver last announced (blank for a driver whose firmware does not report them)
const ePin = document.getElementById('edit-device-espnow-pin');
const eCh = document.getElementById('edit-device-espnow-channel');
if (ePin) ePin.value = tr === 'espnow' && dev && dev.pin != null ? String(dev.pin) : '';
if (eCh) eCh.value = tr === 'espnow' && dev && dev.espnow_channel != null ? String(dev.espnow_channel) : '';
const wName = document.getElementById('edit-device-wifi-driver-name');
const wLeds = document.getElementById('edit-device-wifi-num-leds');
const wCo = document.getElementById('edit-device-wifi-color-order');
@@ -813,7 +871,37 @@ async function pushWifiDriverConfig(devId, fields) {
}
}
// The Menu's "Hide sim devices" item and the Devices modal's checkbox show the same setting
function syncHideSimControls() {
const hide = readHideSim();
const hideSim = document.getElementById('devices-hide-sim');
if (hideSim) hideSim.checked = hide;
const menuBtn = document.getElementById('menu-hide-sim-btn');
if (menuBtn) {
menuBtn.textContent = hide ? 'Show sim devices' : 'Hide sim devices';
menuBtn.setAttribute('aria-pressed', hide ? 'true' : 'false');
}
}
document.addEventListener('DOMContentLoaded', () => {
const hideSim = document.getElementById('devices-hide-sim');
if (hideSim) {
hideSim.checked = readHideSim();
applyHideSim(hideSim.checked);
hideSim.addEventListener('change', () => {
applyHideSim(hideSim.checked);
syncHideSimControls();
});
}
const menuHideSim = document.getElementById('menu-hide-sim-btn');
if (menuHideSim) {
applyHideSim(readHideSim());
syncHideSimControls();
menuHideSim.addEventListener('click', () => {
applyHideSim(!readHideSim());
syncHideSimControls();
});
}
window.addEventListener('deviceTcpStatus', (ev) => {
const { ip, connected } = ev.detail || {};
if (ip == null || typeof connected !== 'boolean') return;
@@ -926,8 +1014,12 @@ document.addEventListener('DOMContentLoaded', () => {
if (editForm) {
editForm.addEventListener('submit', async (e) => {
e.preventDefault();
const { devId, payload } = collectDeviceEditPayload();
const { devId, payload, error } = collectDeviceEditPayload();
if (!devId) return;
if (error) {
alert(error);
return;
}
const ok = await updateDevice(devId, payload);
if (!ok) return;
// Before the brightness push: a driver's brightness includes its groups' factors.