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:
1 parent
35207a868a
commit
edf35e9c71
280 files changed
+24043
-1756
No files matched your search
+156
-61
@@ -84,7 +84,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const rebootButton = document.getElementById('reboot-btn');
|
||||
if (rebootButton) {
|
||||
rebootButton.addEventListener('click', async () => {
|
||||
if (!confirm('Reboot the controller now? The page will be unavailable for a few seconds.')) return;
|
||||
if (!await uiConfirm('Reboot the controller now? The page will be unavailable for a few seconds.')) return;
|
||||
rebootButton.disabled = true;
|
||||
try {
|
||||
await fetch('/reboot', { method: 'POST' });
|
||||
@@ -266,7 +266,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const bridgeSection = document.getElementById('bridge-section');
|
||||
const bridgeList = document.getElementById('bridge-list');
|
||||
const bridgeAddBtn = document.getElementById('bridge-add-btn');
|
||||
const bridgeAddInput = document.getElementById('bridge-add-input');
|
||||
const bridgePorts = document.getElementById('bridge-ports');
|
||||
const bridgeRefresh = document.getElementById('bridge-refresh-btn');
|
||||
let bridgeAddrs = [];
|
||||
@@ -279,18 +278,29 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
function bridgeName(b) {
|
||||
if (b.kind === 'dmx') return (b.status && b.status.name) || b.addr;
|
||||
return bridgeMac(b) || b.addr;
|
||||
}
|
||||
|
||||
const dmxId = (b) => b.addr.slice(4); // "dmx:<id>"
|
||||
|
||||
// 'up' (linked), 'down' (not linked yet) or 'local' (the rig page of this controller)
|
||||
function bridgeState(b) {
|
||||
if (b.kind === 'browser') return 'local';
|
||||
if (b.kind === 'stopped') return 'down';
|
||||
return b.status && b.status.linked ? 'up' : 'down';
|
||||
}
|
||||
|
||||
function describeBridge(b) {
|
||||
const st = b.status || {};
|
||||
if (b.kind === 'browser') return 'Rig page of this controller · sent ' + (st.tx || 0) + ' · received ' + (st.rx || 0);
|
||||
if (b.kind === 'stopped') return 'DMX bridge, not running';
|
||||
if (b.kind === 'dmx') {
|
||||
const parts = ['DMX', (st.universes || 0) + (st.universes === 1 ? ' universe' : ' universes'),
|
||||
(st.running || 0) + '/' + (st.fixtures || 0) + ' fixtures', (st.hz || 40) + ' Hz', 'sent ' + (st.packets || 0)];
|
||||
if (st.last_error) parts.push('last error: ' + st.last_error);
|
||||
return parts.join(' · ');
|
||||
}
|
||||
if (b.kind === 'udp' || (b.kind !== 'serial' && !b.addr.startsWith('usb:'))) {
|
||||
if (!st.linked) return 'Not connected (no answer from ' + b.addr + ')';
|
||||
return ['Connected', 'channel ' + st.channel, 'microphone ' + (st.mic ? 'yes' : 'no'),
|
||||
@@ -327,15 +337,48 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
editBtn.type = 'button';
|
||||
editBtn.className = 'btn btn-secondary btn-small';
|
||||
editBtn.textContent = 'Edit';
|
||||
const dmx = b.kind === 'dmx' || b.kind === 'stopped';
|
||||
editBtn.addEventListener('click', () => openBridgeEditor(b));
|
||||
if (b.kind === 'stopped') {
|
||||
const startBtn = document.createElement('button');
|
||||
startBtn.type = 'button';
|
||||
startBtn.className = 'btn btn-primary btn-small';
|
||||
startBtn.textContent = 'Start';
|
||||
startBtn.addEventListener('click', async () => {
|
||||
try {
|
||||
await window.DmxBridges.start(dmxId(b));
|
||||
showSettingsMessage('DMX bridge started.', 'success');
|
||||
} catch (error) {
|
||||
showSettingsMessage(`Error: ${error.message}`, 'error');
|
||||
}
|
||||
loadBridgeSettings();
|
||||
});
|
||||
actions.append(startBtn);
|
||||
}
|
||||
actions.append(editBtn);
|
||||
if (b.kind !== 'browser') { // the rig page's own bridge is not removable
|
||||
if (dmx) {
|
||||
const delBtn = document.createElement('button');
|
||||
delBtn.type = 'button';
|
||||
delBtn.className = 'btn btn-danger btn-small';
|
||||
delBtn.textContent = 'Delete';
|
||||
delBtn.addEventListener('click', () => {
|
||||
if (!confirm(`Delete bridge "${bridgeName(b)}"?`)) return;
|
||||
delBtn.addEventListener('click', async () => {
|
||||
if (!await uiConfirm(`Delete DMX bridge "${bridgeName(b)}" and its fixtures?`)) return;
|
||||
try {
|
||||
await window.DmxBridges.remove(dmxId(b));
|
||||
showSettingsMessage('DMX bridge deleted.', 'success');
|
||||
} catch (error) {
|
||||
showSettingsMessage(`Error: ${error.message}`, 'error');
|
||||
}
|
||||
loadBridgeSettings();
|
||||
});
|
||||
actions.append(delBtn);
|
||||
} else if (b.kind !== 'browser') { // the rig page's own bridge is not removable
|
||||
const delBtn = document.createElement('button');
|
||||
delBtn.type = 'button';
|
||||
delBtn.className = 'btn btn-danger btn-small';
|
||||
delBtn.textContent = 'Delete';
|
||||
delBtn.addEventListener('click', async () => {
|
||||
if (!await uiConfirm(`Delete bridge "${bridgeName(b)}"?`)) return;
|
||||
putBridges(bridgeAddrs.filter((a) => a !== b.addr), 'Bridge removed.');
|
||||
});
|
||||
actions.append(delBtn);
|
||||
@@ -367,6 +410,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (bridgeTab) bridgeTab.hidden = !data.supported; // nothing to show where bridges are not supported
|
||||
if (!data.supported) return;
|
||||
bridgeAddrs = (data.bridges || []).map((b) => b.addr);
|
||||
// DMX bridge records that are not running are listed too, with a Start button
|
||||
try {
|
||||
const recs = await fetch('/dmx-bridges', { cache: 'no-store' }).then((r) => (r.ok ? r.json() : {}));
|
||||
for (const [id, rec] of Object.entries(recs)) {
|
||||
if (!bridgeAddrs.includes('dmx:' + id)) {
|
||||
data.bridges = (data.bridges || []).concat([{ addr: 'dmx:' + id, kind: 'stopped', name: '', status: { name: rec.name } }]);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// no DMX bridges to add
|
||||
}
|
||||
renderBridges(data);
|
||||
filterBridges();
|
||||
} catch (error) {
|
||||
@@ -445,27 +499,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
if (bridgeRefresh) bridgeRefresh.addEventListener('click', loadBridgeSettings);
|
||||
|
||||
// Add: the address in the box at the top goes straight onto the list (Edit changes it later)
|
||||
function addBridgeFromBox() {
|
||||
const addr = bridgeAddInput.value.trim();
|
||||
if (!addr) return;
|
||||
if (bridgeAddrs.includes(addr)) {
|
||||
showSettingsMessage('That bridge is already in the list', 'error');
|
||||
return;
|
||||
}
|
||||
bridgeAddInput.value = '';
|
||||
putBridges([...bridgeAddrs, addr], 'Bridge added.');
|
||||
}
|
||||
if (bridgeAddBtn) bridgeAddBtn.addEventListener('click', addBridgeFromBox);
|
||||
if (bridgeAddInput) {
|
||||
bridgeAddInput.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
addBridgeFromBox();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (bridgeAddBtn) bridgeAddBtn.addEventListener('click', () => openBridgeEditor(null));
|
||||
|
||||
const bridgeSearch = document.getElementById('bridge-search');
|
||||
function filterBridges() {
|
||||
@@ -476,12 +510,30 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
if (bridgeSearch) bridgeSearch.addEventListener('input', filterBridges);
|
||||
|
||||
// The bridge editor: add a bridge, or change one's address and radio channel
|
||||
// The bridge dialog, for every kind of bridge: a type picker (USB board, network board, DMX) shows the fields of
|
||||
// that type. Adding starts with the type; an existing bridge keeps its type.
|
||||
const bridgeEditModal = document.getElementById('edit-bridge-modal');
|
||||
const bridgeEditForm = document.getElementById('edit-bridge-form');
|
||||
const bridgeTypeSel = document.getElementById('edit-bridge-type');
|
||||
let bridgeEditing = null; // the bridge being edited, or null when adding
|
||||
let dmxLoaded = false; // the DMX section holds the bridge being edited (or a new one)
|
||||
|
||||
const isBoardAddr = (addr) => /^(serial:)?\/dev\//.test(addr) || addr.startsWith("usb:");
|
||||
const isBoardAddr = (addr) => /^(serial:)?\/dev\//.test(addr) || addr.startsWith('usb:');
|
||||
|
||||
const TYPE_HELP = {
|
||||
usb: 'A bridge board on USB: its serial port (/dev/ttyACM1). Once it answers it is known by its MAC, on whichever port it is plugged into.',
|
||||
network: 'A bridge board or led-simulator on the network: host:port (UDP, default port 8766).',
|
||||
dmx: 'Universes sent to Art-Net, sACN, USB-DMX or the rig simulator 40 times a second. Each fixture is a led-driver of its own.',
|
||||
browser: 'The rig page of this controller. It has nothing to set and cannot be removed.',
|
||||
};
|
||||
|
||||
function bridgeType(b) {
|
||||
if (!b) return 'usb';
|
||||
if (b.kind === 'dmx' || b.kind === 'stopped') return 'dmx';
|
||||
if (b.kind === 'browser') return 'browser';
|
||||
if (b.kind === 'serial' || isBoardAddr(b.addr)) return 'usb';
|
||||
return 'network';
|
||||
}
|
||||
|
||||
function bridgeEditError(text) {
|
||||
const el = document.getElementById('edit-bridge-error');
|
||||
@@ -489,58 +541,101 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
el.hidden = !text;
|
||||
}
|
||||
|
||||
function syncBridgeEditor() {
|
||||
const addr = document.getElementById('edit-bridge-addr').value.trim();
|
||||
const browser = bridgeEditing && bridgeEditing.kind === 'browser';
|
||||
const usb = !!bridgeEditing && bridgeEditing.addr.startsWith('usb:');
|
||||
document.getElementById('edit-bridge-channel-field').hidden = browser || !(usb || isBoardAddr(addr));
|
||||
async function syncBridgeEditor() {
|
||||
const type = bridgeTypeSel.value;
|
||||
const usbKnown = !!bridgeEditing && bridgeEditing.addr.startsWith('usb:');
|
||||
document.getElementById('edit-bridge-type-help').textContent = TYPE_HELP[type] || '';
|
||||
document.getElementById('edit-bridge-addr-field').hidden = type === 'dmx' || type === 'browser';
|
||||
document.getElementById('edit-bridge-channel-field').hidden = type !== 'usb';
|
||||
document.getElementById('edit-bridge-dmx-field').hidden = type !== 'dmx';
|
||||
document.getElementById('edit-bridge-name').maxLength = type === 'dmx' ? 63 : 40;
|
||||
document.getElementById('edit-bridge-name').placeholder = type === 'dmx' ? 'e.g. Stage' : 'e.g. Stage left';
|
||||
const addr = document.getElementById('edit-bridge-addr');
|
||||
addr.placeholder = type === 'network' ? '192.168.1.50:8766' : '/dev/ttyACM1';
|
||||
addr.disabled = type === 'browser' || usbKnown; // a USB board is found by its MAC wherever it is plugged in
|
||||
bridgeEditModal.querySelector('.modal-content').classList.toggle('bridge-modal-wide', type === 'dmx');
|
||||
if (type === 'dmx' && !dmxLoaded && window.DmxBridges) {
|
||||
dmxLoaded = true;
|
||||
try {
|
||||
const name = await window.DmxBridges.load(bridgeEditing ? bridgeEditing.addr.slice(4) : null);
|
||||
if (bridgeEditing) document.getElementById('edit-bridge-name').value = name;
|
||||
} catch (error) {
|
||||
dmxLoaded = false;
|
||||
bridgeEditError(`Could not load the DMX bridge: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openBridgeEditor(b) {
|
||||
bridgeEditing = b || null;
|
||||
const browser = !!b && b.kind === 'browser';
|
||||
dmxLoaded = false;
|
||||
const type = bridgeType(b);
|
||||
const browser = type === 'browser';
|
||||
const usbKnown = !!b && b.addr.startsWith('usb:');
|
||||
document.getElementById('edit-bridge-title').textContent = b ? 'Edit bridge' : 'Add bridge';
|
||||
document.getElementById('edit-bridge-name').value = b && b.name ? b.name : '';
|
||||
document.getElementById('edit-bridge-name').disabled = false;
|
||||
const addr = document.getElementById('edit-bridge-addr');
|
||||
addr.value = b ? (bridgeMac(b) || b.addr) : '';
|
||||
const usb = !!b && b.addr.startsWith('usb:');
|
||||
addr.disabled = browser || usb; // a USB board is found by its MAC wherever it is plugged in
|
||||
bridgeTypeSel.value = type;
|
||||
bridgeTypeSel.disabled = !!b; // a bridge keeps its type; delete it and add another to change it
|
||||
bridgeTypeSel.querySelector('option[value="browser"]').hidden = !browser;
|
||||
document.getElementById('edit-bridge-name').value = b ? (type === 'dmx' ? (b.status && b.status.name) || '' : b.name || '') : '';
|
||||
document.getElementById('edit-bridge-addr').value = b && type !== 'dmx' ? (bridgeMac(b) || b.addr) : '';
|
||||
const ch = document.getElementById('edit-bridge-channel');
|
||||
ch.value = b && b.status && b.status.channel ? String(b.status.channel) : '';
|
||||
document.getElementById('edit-bridge-status').textContent = b
|
||||
? (usb ? 'A USB board, found by its MAC wherever it is plugged in' + (b.status && b.status.port ? ' (now on ' + b.status.port + ')' : '') + '. ' : '') + (browser ? 'The rig page of this controller. It has nothing to set and cannot be removed. ' : '') + describeBridge(b)
|
||||
? (usbKnown && b.status && b.status.port ? 'Now on ' + b.status.port + '. ' : '') + describeBridge(b)
|
||||
: '';
|
||||
document.getElementById('edit-bridge-save-btn').hidden = browser;
|
||||
bridgeEditError('');
|
||||
document.getElementById('edit-bridge-dmx-universes').textContent = '';
|
||||
bridgeEditError('');
|
||||
syncBridgeEditor();
|
||||
bridgeEditModal.classList.add('active');
|
||||
}
|
||||
|
||||
// Save a USB or network board: its place in the list, its name and its radio channel
|
||||
async function saveBoard() {
|
||||
const usbKnown = !!bridgeEditing && bridgeEditing.addr.startsWith('usb:');
|
||||
const addr = usbKnown ? bridgeEditing.addr : document.getElementById('edit-bridge-addr').value.trim();
|
||||
const type = bridgeTypeSel.value;
|
||||
if (!addr) return type === 'network' ? 'Enter the board\'s host:port' : 'Enter the board\'s port (/dev/...)';
|
||||
if (type === 'network' && (isBoardAddr(addr) || !/^[^\s:]+:\d+$/.test(addr))) return 'A network bridge is host:port, e.g. 192.168.1.50:8766';
|
||||
if (type === 'usb' && !isBoardAddr(addr)) return 'A USB bridge is its port, e.g. /dev/ttyACM1';
|
||||
if (addr !== (bridgeEditing && bridgeEditing.addr) && bridgeAddrs.includes(addr)) return 'That bridge is already in the list';
|
||||
const raw = document.getElementById('edit-bridge-channel').value.trim();
|
||||
const list = bridgeEditing ? bridgeAddrs.map((a) => (a === bridgeEditing.addr ? addr : a)) : [...bridgeAddrs, addr];
|
||||
const channelChanged = type === 'usb' && raw !== '' &&
|
||||
raw !== String(bridgeEditing && bridgeEditing.status && bridgeEditing.status.channel || '');
|
||||
const name = document.getElementById('edit-bridge-name').value.trim();
|
||||
let err = '';
|
||||
if (!bridgeEditing || addr !== bridgeEditing.addr) {
|
||||
err = await putBridges(list, bridgeEditing ? 'Bridge updated.' : 'Bridge added.');
|
||||
}
|
||||
if (!err && name !== ((bridgeEditing && bridgeEditing.name) || '')) err = await setBridgeName(addr, name);
|
||||
if (!err && channelChanged) err = await setBridgeChannel(addr, raw);
|
||||
return err;
|
||||
}
|
||||
|
||||
async function saveDmx() {
|
||||
try {
|
||||
const r = await window.DmxBridges.save(document.getElementById('edit-bridge-name').value);
|
||||
showSettingsMessage(r.created ? 'DMX bridge added.' : 'DMX bridge saved.', 'success');
|
||||
} catch (error) {
|
||||
return error.message;
|
||||
}
|
||||
loadBridgeSettings();
|
||||
setTimeout(loadBridgeSettings, 1500); // the fixtures come up a moment later
|
||||
return '';
|
||||
}
|
||||
|
||||
if (bridgeEditModal && bridgeEditForm) {
|
||||
const close = () => bridgeEditModal.classList.remove('active');
|
||||
document.getElementById('edit-bridge-close-btn').addEventListener('click', close);
|
||||
document.getElementById('edit-bridge-addr').addEventListener('input', syncBridgeEditor);
|
||||
bridgeTypeSel.addEventListener('change', () => {
|
||||
bridgeEditError('');
|
||||
syncBridgeEditor();
|
||||
});
|
||||
bridgeEditForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const usb = !!bridgeEditing && bridgeEditing.addr.startsWith('usb:');
|
||||
const addr = usb ? bridgeEditing.addr : document.getElementById('edit-bridge-addr').value.trim();
|
||||
const raw = document.getElementById('edit-bridge-channel').value.trim();
|
||||
if (!addr) return;
|
||||
if (addr !== (bridgeEditing && bridgeEditing.addr) && bridgeAddrs.includes(addr)) {
|
||||
bridgeEditError('That bridge is already in the list');
|
||||
return;
|
||||
}
|
||||
const list = bridgeEditing ? bridgeAddrs.map((a) => (a === bridgeEditing.addr ? addr : a)) : [...bridgeAddrs, addr];
|
||||
const channelChanged = isBoardAddr(addr) && raw !== '' &&
|
||||
raw !== String(bridgeEditing && bridgeEditing.status && bridgeEditing.status.channel || '');
|
||||
const name = document.getElementById('edit-bridge-name').value.trim();
|
||||
let err = '';
|
||||
if (!bridgeEditing || addr !== bridgeEditing.addr) {
|
||||
err = await putBridges(list, bridgeEditing ? 'Bridge updated.' : 'Bridge added.');
|
||||
}
|
||||
if (!err && name !== ((bridgeEditing && bridgeEditing.name) || '')) err = await setBridgeName(addr, name);
|
||||
if (!err && channelChanged) err = await setBridgeChannel(addr, raw);
|
||||
bridgeEditError('');
|
||||
const err = bridgeTypeSel.value === 'dmx' ? await saveDmx() : await saveBoard();
|
||||
if (err) bridgeEditError(err);
|
||||
else close();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user