feat: browser simulator served by the controller, desktop build, browser bridge

- led-simulator: the rig runs the C++ led-driver as WebAssembly (sim-driver/),
  one single-threaded worker per bar, no cross-origin isolation needed. Rooms
  (one JSON per room) with an on-page editor, and a pattern gallery. The
  Python server, Pyodide boot and ring buffer are removed.
- sim-controller sim_rig.c: serves /sim/ from an embedded pack, the page's
  WebSocket and the rooms/flash API. The desktop build embeds it too.
- bridge.c: a "browser" bridge kind that carries ESP-NOW frames to the page;
  devices announced through it are marked sim.
- UI: Simulator in the Menu, split view with resize and pop-out, swipe
  between controller and rig on phones; SIM/REAL badges in Devices.
- Fades: preset pushes and Wi-Fi driver bodies always carry fade and
  beat_time, so "off" no longer inherits an earlier fade.
- Also the sequences-v2 work in progress: desktop port, bridge firmware,
  serial bridge, Wi-Fi drivers, sequence timeline, audio and API changes.
- led-driver: ESP-NOW link, beat sync, control messages, sim hooks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-16 19:32:46 +13:00
1 parent 698c1463c0
commit 581b751904
506 files changed
+42336 -3599

No files matched your search

+18 -7
View File
@@ -220,7 +220,7 @@ async function runEspnowPing({ btn, dot, statusEl } = {}) {
function applyEspnowPingToDeviceRows(responses, phase) {
const container = document.getElementById('devices-list-modal');
if (!container) return;
container.querySelectorAll('.profiles-row[data-device-transport="espnow"]').forEach((row) => {
container.querySelectorAll('.profiles-row[data-device-transport="espnow"], .profiles-row[data-device-transport="wifi"]').forEach((row) => {
const dot = row.querySelector('.device-status-dot');
if (!dot) return;
if (phase === 'pinging') {
@@ -427,14 +427,15 @@ async function createDeviceFromModal() {
if (statusEl) statusEl.textContent = 'Name is required';
return;
}
if (mac.length !== 12) {
if (transport === 'wifi') {
if (!address) {
if (statusEl) statusEl.textContent = 'Address is required for Wi-Fi devices (the driver hostname, e.g. led20)';
return;
}
} else if (mac.length !== 12) {
if (statusEl) statusEl.textContent = 'MAC must be 12 hex characters';
return;
}
if (transport === 'wifi' && !address) {
if (statusEl) statusEl.textContent = 'Address is required for Wi-Fi devices';
return;
}
if (btn) {
btn.disabled = true;
@@ -446,7 +447,7 @@ async function createDeviceFromModal() {
name,
transport,
type: 'led',
mac,
mac: transport === 'wifi' ? undefined : mac,
address: transport === 'wifi' ? address : mac,
};
const res = await fetch('/devices', {
@@ -549,6 +550,15 @@ function renderDevicesList(devices) {
label.style.flex = '1';
label.style.minWidth = '100px';
// Simulated (a driver of the rig page at /sim/, heard on the browser bridge) or a real board
const isSim = !!(dev && dev.sim);
const kind = document.createElement('span');
kind.className = `device-kind-badge device-kind-badge--${isSim ? 'sim' : 'real'}`;
kind.textContent = isSim ? 'sim' : 'real';
kind.title = isSim
? 'Simulated: a driver on the rig page (/sim/), reached over the browser bridge'
: 'A real board';
const editBtn = document.createElement('button');
editBtn.className = 'btn btn-secondary btn-small';
editBtn.textContent = 'Edit';
@@ -576,6 +586,7 @@ function renderDevicesList(devices) {
row.appendChild(dot);
row.appendChild(label);
row.appendChild(kind);
row.appendChild(editBtn);
row.appendChild(identifyBtn);
row.appendChild(deleteBtn);
+154 -2
View File
@@ -147,7 +147,7 @@ document.addEventListener('DOMContentLoaded', () => {
const apPw = document.getElementById('ap-password-input');
if (apPw) apPw.value = data.ap_password || '';
const bridge = document.getElementById('bridge-input');
if (bridge) bridge.value = data.bridge || '';
if (bridge) bridge.value = Array.isArray(data.bridges) ? data.bridges.join(', ') : (data.bridge || '');
staticIpsList.innerHTML = '';
(Array.isArray(data.static_ips) ? data.static_ips : []).forEach(addStaticIpRow);
}
@@ -260,6 +260,7 @@ document.addEventListener('DOMContentLoaded', () => {
settingsModal.classList.add('active');
switchSettingsTab('controller');
loadDeviceSettings();
loadBridgeSettings();
});
}
@@ -311,6 +312,157 @@ document.addEventListener('DOMContentLoaded', () => {
}
});
}
// Bridges: USB boards and network boards (GET/PUT /settings/bridge)
const bridgeSection = document.getElementById('bridge-section');
const bridgeList = document.getElementById('bridge-list');
const bridgeAddInput = document.getElementById('bridge-add-input');
const bridgeAddForm = document.getElementById('bridge-add-form');
const bridgePorts = document.getElementById('bridge-ports');
const bridgeRefresh = document.getElementById('bridge-refresh-btn');
let bridgeAddrs = [];
function describeBridge(b) {
const st = b.status || {};
if (b.kind !== 'serial') return 'Network bridge · sent ' + (st.tx || 0) + ' · received ' + (st.rx || 0);
if (!st.linked) return 'Not connected (waiting for the board on ' + st.port + ')';
return ['Connected', 'MAC ' + st.mac, 'channel ' + st.channel, 'microphone ' + (st.mic ? 'yes' : 'no'),
'sent ' + st.sent, 'received ' + st.rx].join(' · ');
}
function syncBridgeInput() {
const simInput = document.getElementById('bridge-input');
if (simInput) simInput.value = bridgeAddrs.join(', ');
}
function renderBridges(data) {
bridgeList.textContent = '';
for (const b of data.bridges || []) {
const row = document.createElement('div');
row.className = 'bridge-row';
const head = document.createElement('div');
const name = document.createElement('strong');
name.textContent = b.addr;
head.append(name);
const status = document.createElement('small');
status.className = 'muted-text';
status.textContent = ' ' + describeBridge(b);
head.append(status);
row.append(head);
const actions = document.createElement('div');
actions.className = 'btn-group';
if (b.kind === 'serial') {
const ch = document.createElement('input');
ch.type = 'number';
ch.min = '1';
ch.max = '13';
ch.placeholder = 'channel';
ch.value = b.status && b.status.channel ? String(b.status.channel) : '';
ch.setAttribute('aria-label', 'Radio channel for ' + b.addr);
const setCh = document.createElement('button');
setCh.type = 'button';
setCh.className = 'btn btn-secondary';
setCh.textContent = 'Set channel';
setCh.addEventListener('click', () => setBridgeChannel(b.addr, ch.value));
actions.append(ch, setCh);
}
const remove = document.createElement('button');
remove.type = 'button';
remove.className = 'btn btn-secondary';
remove.textContent = 'Remove';
remove.addEventListener('click', () => putBridges(bridgeAddrs.filter((a) => a !== b.addr), 'Bridge removed.'));
actions.append(remove);
row.append(actions);
bridgeList.append(row);
}
if (!(data.bridges || []).length) {
const none = document.createElement('small');
none.className = 'muted-text';
none.textContent = 'No bridges: the controller uses the radio.';
bridgeList.append(none);
}
bridgePorts.textContent = '';
for (const port of data.ports || []) {
if (bridgeAddrs.includes(port)) continue;
const opt = document.createElement('option');
opt.value = port;
bridgePorts.append(opt);
}
}
async function loadBridgeSettings() {
if (!bridgeSection) return;
try {
const data = await fetch('/settings/bridge', { cache: 'no-store' }).then((r) => r.json());
bridgeSection.hidden = !data.supported;
if (!data.supported) return;
bridgeAddrs = (data.bridges || []).map((b) => b.addr);
renderBridges(data);
syncBridgeInput();
} catch (error) {
bridgeList.textContent = 'Could not read the bridges.';
}
}
async function putBridges(addrs, okText) {
try {
const response = await fetch('/settings/bridge', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ bridges: addrs }),
});
const result = await response.json();
if (response.ok) {
showSettingsMessage(okText, 'success');
} else {
showSettingsMessage(`Error: ${result.error || 'Failed to update the bridges'}`, 'error');
}
} catch (error) {
showSettingsMessage(`Error: ${error.message}`, 'error');
}
loadBridgeSettings();
setTimeout(loadBridgeSettings, 1500); // a board answers its link a moment later
}
async function setBridgeChannel(addr, raw) {
const channel = parseInt(raw, 10);
if (Number.isNaN(channel) || channel < 1 || channel > 13) {
showSettingsMessage('Radio channel must be between 1 and 13', 'error');
return;
}
try {
const response = await fetch('/settings/bridge', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ addr, channel }),
});
const result = await response.json();
if (response.ok) {
showSettingsMessage('Channel set on the board.', 'success');
} else {
showSettingsMessage(`Error: ${result.error || 'Failed to set the channel'}`, 'error');
}
} catch (error) {
showSettingsMessage(`Error: ${error.message}`, 'error');
}
loadBridgeSettings();
}
if (bridgeRefresh) bridgeRefresh.addEventListener('click', loadBridgeSettings);
if (bridgeAddForm) {
bridgeAddForm.addEventListener('submit', (e) => {
e.preventDefault();
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.');
});
}
const networkForm = document.getElementById('network-form');
if (networkForm) {
networkForm.addEventListener('submit', async (e) => {
@@ -340,7 +492,7 @@ document.addEventListener('DOMContentLoaded', () => {
hostname,
static_ips: staticIps,
ap_password: apPassword,
bridge: (document.getElementById('bridge-input') || { value: '' }).value.trim(),
bridges: (document.getElementById('bridge-input') || { value: '' }).value.split(',').map((v) => v.trim()).filter(Boolean),
ap_enabled: !apToggle || apToggle.getAttribute('aria-pressed') === 'true',
}),
});
+15 -3
View File
@@ -283,7 +283,6 @@ document.addEventListener('DOMContentLoaded', () => {
const presetBrightnessInput = document.getElementById('preset-brightness-input');
const presetDelayInput = document.getElementById('preset-delay-input');
const presetFadeInput = document.getElementById('preset-fade-input');
const presetBeatTimeInput = document.getElementById('preset-beat-time-input');
const presetDelayField = presetDelayInput ? presetDelayInput.closest('.preset-editor-field') : null;
const presetBackgroundInput = document.getElementById('preset-background-input');
const presetBackgroundButton = document.getElementById('preset-background-btn');
@@ -750,7 +749,6 @@ document.addEventListener('DOMContentLoaded', () => {
presetBrightnessInput.value = preset.brightness || 0;
presetDelayInput.value = preset.delay || 0;
if (presetFadeInput) presetFadeInput.value = preset.fade || preset.f || 0;
if (presetBeatTimeInput) presetBeatTimeInput.checked = !!(preset.beat_time || preset.tb);
if (presetBackgroundInput) {
const rawBgRef = preset.background_palette_ref ?? preset.backgroundPaletteRef;
let bgRef = null;
@@ -988,7 +986,6 @@ document.addEventListener('DOMContentLoaded', () => {
brightness: presetBrightnessInput ? parseInt(presetBrightnessInput.value, 10) || 0 : 0,
delay: presetDelayInput ? parseInt(presetDelayInput.value, 10) || 0 : 0,
fade: presetFadeInput ? Math.max(0, Math.min(10000, parseInt(presetFadeInput.value, 10) || 0)) : 0,
beat_time: !!(presetBeatTimeInput && presetBeatTimeInput.checked),
background: presetBackgroundInput ? presetBackgroundInput.value : '#000000',
background_palette_ref: currentBackgroundPaletteRef != null ? currentBackgroundPaletteRef : null,
auto: presetManualModeInput ? !presetManualModeInput.checked : true,
@@ -2008,6 +2005,9 @@ const sendPresetViaEspNow = async (
n5: coercePresetInt(preset.n5),
n6: presetWireN6(preset),
manual_beat_n: coerceManualBeatN(preset),
// Always sent: a driver applies a preset over the one it runs, so a missing fade would carry over
fade: Math.max(0, Math.min(10000, Number(preset.fade ?? preset.f) || 0)),
beat_time: preset.beat_time === true || preset.tb === true || preset.tb === 1,
},
},
};
@@ -2142,6 +2142,18 @@ async function sendZonePresetSelection(zoneId, tabData, presetId, preset, allPre
? await zm.resolveDeviceNamesForZonePreset(tabData, pid)
: [];
const groupIds = zoneGroupIdsFromTabData(tabData);
// Tell the controller first: a looping preset takes over the zone from a looping sequence, and a
// one-shot sequence goes back to this preset when it ends. The drivers get it from the push below.
try {
await fetch(`/zones/${encodeURIComponent(String(zoneId))}/play`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({ preset_id: pid, drivers: false }),
});
} catch (e) {
console.warn('zone play:', e);
}
document.querySelectorAll('#presets-list-zone .sequence-tile-main.active').forEach((b) => b.classList.remove('active'));
await sendPresetViaEspNow(pid, body, names, false, false, '2', {
select: true,
groupIds,
File diff suppressed because it is too large. Load diff
+69 -1017
View File
File diff suppressed because it is too large. Load diff
+360
View File
@@ -0,0 +1,360 @@
// Simulator in the Menu (host builds only, which serve the simulated rig at /sim/).
//
// Wide screens: the rig opens beside the UI, the controller on the left and the rig on the right, with a divider to
// resize them. Narrow screens (phones): the controller and the rig are two full-width pages; swipe left and right,
// or tap the pager at the bottom, to switch. Both stay loaded either way, so the rig's bars keep running. Pop out
// moves the rig to its own window. Whether it is open, its width and the page shown are remembered in this browser.
(function () {
'use strict';
const KEY = 'ledController.simSplit';
const MIN_W = 320;
const NARROW = 900; // below this: two pages to swipe between, not side by side
const LOCK_PX = 10; // movement before a touch counts as a swipe or a scroll
const DRAG_CLASS = 'sim-swipe-dragging';
let pane = null;
let pager = null;
let width = 0;
let page = 0; // swipe mode: 0 the controller, 1 the rig
function load() {
try {
return JSON.parse(localStorage.getItem(KEY)) || {};
} catch (_e) {
return {};
}
}
function save(state) {
try {
localStorage.setItem(KEY, JSON.stringify(Object.assign(load(), state)));
} catch (_e) {
// storage unavailable: the split lasts for this page only
}
}
function isOpen() {
return pane !== null;
}
function swipeMode() {
return window.innerWidth < NARROW;
}
function clampWidth(w) {
const max = Math.max(MIN_W, window.innerWidth - MIN_W);
return Math.round(Math.min(max, Math.max(MIN_W, w)));
}
function applyWidth(w) {
width = clampWidth(w);
document.documentElement.style.setProperty('--sim-pane-w', `${width}px`);
}
function setDrag(px) {
document.documentElement.style.setProperty('--sim-drag', `${Math.round(px)}px`);
}
function setPage(p) {
page = p ? 1 : 0;
document.documentElement.style.setProperty('--sim-page', String(page));
setDrag(0);
if (pager) {
pager.querySelectorAll('button').forEach((b, i) => b.setAttribute('aria-pressed', String(i === page)));
}
if (pane) {
// The page that is off screen is out of the tab order and hidden from screen readers
pane.inert = swipeMode() && page === 0;
const app = document.querySelector('.app-container');
if (app) {
app.inert = swipeMode() && page === 1;
}
}
save({ page });
}
// Side by side or two pages, from the window's width (a phone turned sideways can switch)
function layout() {
if (!pane) {
return;
}
const swipe = swipeMode();
document.body.classList.toggle('sim-split', !swipe);
document.body.classList.toggle('sim-swipe', swipe);
if (!swipe) {
applyWidth(width || load().width || window.innerWidth * 0.45);
}
setPage(page);
}
function popOut() {
const win = window.open('/sim/', 'led-simulator', 'popup,width=1200,height=800');
if (!win) {
// Pop-ups blocked: keep the simulator here
alert('The browser blocked the simulator window. Allow pop-ups for this site, or open /sim/ in a new tab.');
return;
}
// Only one page runs the rig: the new window takes it over, so the pane closes
close();
}
/* ---- swiping between the two pages ---- */
// Touches that belong to something else: sliders and fields, sideways scrollers, open dialogs, and the rig's
// canvas while its room is being edited (a drag there moves a bar)
function ownsTouch(target, doc) {
const el = target && target.nodeType === 1 ? target : target && target.parentElement;
if (!el) {
return false;
}
if (el.closest('input, textarea, select, [contenteditable="true"], [data-no-swipe], .sim-pane-divider')) {
return true;
}
if (doc.querySelector('.modal.active, dialog[open]')) {
return true;
}
if (doc.body.classList.contains('editing') && el.closest('canvas')) {
return true;
}
const win = doc.defaultView;
for (let n = el; n && n !== doc.body; n = n.parentElement) {
const ox = win.getComputedStyle(n).overflowX;
if ((ox === 'auto' || ox === 'scroll') && n.scrollWidth > n.clientWidth + 2) {
return true;
}
}
return false;
}
function attachSwipe(doc) {
let start = null;
doc.addEventListener('touchstart', (ev) => {
start = null;
if (!document.body.classList.contains('sim-swipe') || ev.touches.length !== 1) {
return;
}
if (ownsTouch(ev.target, doc)) {
return;
}
const t = ev.touches[0];
start = { x: t.clientX, y: t.clientY, at: performance.now(), lock: null, dx: 0 };
}, { passive: true });
doc.addEventListener('touchmove', (ev) => {
if (!start || ev.touches.length !== 1) {
return;
}
const t = ev.touches[0];
const dx = t.clientX - start.x;
const dy = t.clientY - start.y;
if (!start.lock) {
if (Math.abs(dx) < LOCK_PX && Math.abs(dy) < LOCK_PX) {
return;
}
start.lock = Math.abs(dx) > Math.abs(dy) * 1.5 ? 'x' : 'y';
if (start.lock === 'x') {
document.body.classList.add(DRAG_CLASS);
}
}
if (start.lock !== 'x') {
return; // a scroll: leave it to the page
}
ev.preventDefault();
// The pages follow the finger; past the first or last page they resist
const past = (page === 0 && dx > 0) || (page === 1 && dx < 0);
start.dx = dx;
setDrag(past ? dx / 4 : dx);
}, { passive: false });
const end = () => {
if (!start) {
return;
}
const s = start;
start = null;
if (s.lock !== 'x') {
return;
}
document.body.classList.remove(DRAG_CLASS);
const fast = Math.abs(s.dx) / Math.max(1, performance.now() - s.at) > 0.5; // px per ms: a flick
const far = Math.abs(s.dx) > window.innerWidth * 0.25;
if ((far || fast) && s.dx < 0 && page === 0) {
setPage(1);
} else if ((far || fast) && s.dx > 0 && page === 1) {
setPage(0);
} else {
setPage(page); // not far enough: back where it was
}
};
doc.addEventListener('touchend', end);
doc.addEventListener('touchcancel', end);
}
/* ---- the pane ---- */
function build() {
pane = document.createElement('div');
pane.id = 'sim-pane';
pane.className = 'sim-pane';
pane.innerHTML =
'<div class="sim-pane-divider" role="separator" aria-orientation="vertical" ' +
'aria-label="Resize the simulator" title="Drag to resize"></div>' +
'<div class="sim-pane-body">' +
'<div class="sim-pane-bar">' +
'<span class="sim-pane-title">Simulator</span>' +
'<button type="button" class="btn btn-secondary btn-small" data-sim="popout" ' +
'title="Open the simulator in its own window">Pop out ↗</button>' +
'<button type="button" class="btn btn-secondary btn-small" data-sim="close" ' +
'title="Close the simulator (its bars power off)" aria-label="Close the simulator">×</button>' +
'</div>' +
'<iframe class="sim-pane-frame" src="/sim/" title="Simulated rig"></iframe>' +
'</div>';
pane.querySelector('[data-sim="popout"]').addEventListener('click', popOut);
pane.querySelector('[data-sim="close"]').addEventListener('click', close);
// Swipes that start in the rig (same origin, so its document can be listened to)
const frame = pane.querySelector('iframe');
frame.addEventListener('load', () => {
try {
attachSwipe(frame.contentDocument);
} catch (_e) {
// not reachable: swipe from the pane's bar or the pager instead
}
});
const divider = pane.querySelector('.sim-pane-divider');
divider.addEventListener('pointerdown', (ev) => {
ev.preventDefault();
divider.setPointerCapture(ev.pointerId);
document.body.classList.add('sim-split-dragging'); // the iframe would swallow the pointer
const move = (e) => applyWidth(window.innerWidth - e.clientX);
const up = () => {
divider.removeEventListener('pointermove', move);
divider.removeEventListener('pointerup', up);
divider.removeEventListener('pointercancel', up);
document.body.classList.remove('sim-split-dragging');
save({ width });
};
divider.addEventListener('pointermove', move);
divider.addEventListener('pointerup', up);
divider.addEventListener('pointercancel', up);
});
divider.addEventListener('keydown', (ev) => {
const step = ev.shiftKey ? 80 : 20;
if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
ev.preventDefault();
applyWidth(width + (ev.key === 'ArrowLeft' ? step : -step));
save({ width });
}
});
divider.tabIndex = 0;
document.body.appendChild(pane);
pager = document.createElement('div');
pager.className = 'sim-pager';
pager.setAttribute('role', 'group');
pager.setAttribute('aria-label', 'Show the controller or the simulator (or swipe)');
pager.innerHTML =
'<button type="button" aria-pressed="true">Controller</button>' +
'<button type="button" aria-pressed="false">Simulator</button>';
pager.querySelectorAll('button').forEach((b, i) => b.addEventListener('click', () => setPage(i)));
document.body.appendChild(pager);
}
function open() {
if (!pane) {
build();
width = load().width || 0;
page = swipeMode() ? 1 : 0; // on a phone, opening it shows it
}
save({ open: true });
layout();
window.dispatchEvent(new Event('resize')); // the UI lays out for its new width
}
function close() {
if (pane) {
pane.remove(); // the iframe goes with it: its bars power off
pane = null;
}
if (pager) {
pager.remove();
pager = null;
}
const app = document.querySelector('.app-container');
if (app) {
app.inert = false;
}
document.body.classList.remove('sim-split', 'sim-swipe', DRAG_CLASS);
document.documentElement.style.setProperty('--sim-page', '0');
setDrag(0);
save({ open: false });
window.dispatchEvent(new Event('resize'));
}
// The Menu item: open it; once open, side by side it closes it, on a phone it shows its page
function toggle() {
if (!isOpen()) {
open();
} else if (swipeMode()) {
setPage(page === 1 ? 0 : 1);
} else {
close();
}
}
function addMenuEntries() {
// A header button for the Menu item to forward to, as the other entries do (help.js)
const headerActions = document.querySelector('.header-actions');
const settingsBtn = document.getElementById('settings-btn');
const btn = document.createElement('button');
btn.className = 'btn btn-secondary edit-mode-only';
btn.id = 'sim-btn';
btn.textContent = 'Simulator';
btn.addEventListener('click', toggle);
if (headerActions) {
headerActions.insertBefore(btn, settingsBtn && settingsBtn.parentNode === headerActions ? settingsBtn : null);
}
const menu = document.getElementById('main-menu-dropdown');
if (menu) {
const item = document.createElement('button');
item.type = 'button';
item.className = 'edit-mode-only';
item.dataset.target = 'sim-btn';
item.textContent = 'Simulator';
const settingsItem = menu.querySelector('[data-target="settings-btn"]');
menu.insertBefore(item, settingsItem);
}
}
async function init() {
let ok = false;
try {
const r = await fetch('/sim/api/config', { cache: 'no-store' });
ok = r.ok;
} catch (_e) {
ok = false;
}
if (!ok) {
return; // the board: no simulator
}
addMenuEntries();
attachSwipe(document); // swipes that start on the controller's page
const saved = load();
if (saved.open) {
build();
width = saved.width || 0;
page = saved.page ? 1 : 0;
layout();
}
window.addEventListener('resize', layout);
}
window.simSplit = { open, close, popOut, setPage };
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();
+1003 -194
View File
File diff suppressed because it is too large. Load diff
+66 -49
View File
@@ -359,14 +359,13 @@
<div id="sequences-modal" class="modal">
<div class="modal-content">
<div class="modal-head">
<h2>Sequences &amp; animations</h2>
<h2>Sequences</h2>
<div class="modal-top-actions">
<button type="button" class="btn btn-secondary" id="sequences-close-btn">Close</button>
</div>
</div>
<div class="modal-actions">
<button type="button" class="btn btn-primary" id="sequence-add-btn">Add sequence</button>
<button type="button" class="btn btn-primary" id="animation-add-btn">Add animation</button>
<button type="button" class="btn btn-secondary" id="sequences-open-presets-btn">Presets</button>
</div>
<div id="sequences-list" class="profiles-list"></div>
@@ -388,42 +387,48 @@
<label for="sequence-editor-name">Name</label>
<input type="text" id="sequence-editor-name" placeholder="Sequence name" style="width:100%;max-width:24rem;">
</div>
<div class="preset-editor-field">
<label for="sequence-editor-kind">Kind</label>
<select id="sequence-editor-kind" class="zone-device-add-select">
<option value="sequence">Sequence</option>
<option value="animation">Animation (one shot)</option>
</select>
<div id="sequence-editor-kind-hint" class="muted-text"></div>
</div>
<div class="preset-editor-field">
<label for="sequence-editor-mode">Steps last (lanes can override)</label>
<select id="sequence-editor-mode" class="zone-device-add-select">
<option value="beats">Beats</option>
<option value="time">Time (seconds)</option>
</select>
</div>
<div id="sequence-editor-beats-panel" style="margin:0 0 0.75rem 0;">
<label style="display:block;">
<input type="checkbox" id="sequence-editor-loop" checked>
Loop
</label>
</div>
<details class="seq-targets-panel" open>
<summary><strong>Targets</strong> <span class="muted-text">— the drivers this sequence plays to, in order. Lanes, steps and chases pick from them.</span></summary>
<div id="sequence-editor-targets" class="profiles-list"></div>
<div class="modal-actions">
<button type="button" class="btn btn-secondary btn-small" id="sequence-editor-add-target-btn">Add target</button>
<button type="button" class="btn btn-secondary btn-small" id="sequence-editor-per-driver-btn" title="One target for each driver in this zone's groups">One per driver</button>
<!-- Timeline: tracks (targets) down, beats or seconds across, clips dragged in from the browser -->
<div id="seq-tl" class="tl">
<div class="tl-transport">
<div class="tl-tgroup">
<button type="button" class="tl-tbtn" id="tl-play" title="Save, then play it in the current zone">&#9654;</button>
<button type="button" class="tl-tbtn" id="tl-stop" title="Stop the sequence">&#9632;</button>
</div>
<div class="tl-lcd" title="Playhead position and tempo"><span id="tl-pos">1.1</span><span id="tl-bpm">120 BPM</span></div>
<div class="tl-tgroup tl-seg" id="tl-units" title="Clips last beats, or seconds">
<button type="button" data-v="beats">Beats</button>
<button type="button" data-v="time">Seconds</button>
</div>
<!-- What clips are measured in; the Beats/Seconds buttons set it -->
<select id="sequence-editor-mode" hidden>
<option value="beats">Beats</option>
<option value="time">Seconds</option>
</select>
<label class="tl-tfield">Snap <select id="tl-snap"></select></label>
<label class="tl-tfield tl-loop-toggle" title="On: loops, every track restarting at the end of the loop bar. Off: a one-shot that plays once in seconds, then the zone goes back to its last looping preset or sequence."><input type="checkbox" id="sequence-editor-loop" checked> Loop</label>
<div class="tl-tgroup">
<button type="button" class="tl-tbtn" id="tl-zoom-out" title="Zoom out">&minus;</button>
<button type="button" class="tl-tbtn" id="tl-zoom-in" title="Zoom in">+</button>
</div>
</div>
</details>
<div class="modal-actions">
<button type="button" class="btn btn-secondary btn-small" id="sequence-editor-view-btn">Show grid</button>
<div class="tl-notice" id="tl-notice" hidden></div>
<div class="tl-main">
<div class="tl-arrange">
<div class="tl-scroll" id="tl-scroll"><div class="tl-canvas" id="tl-canvas"></div></div>
<div class="tl-addtrack">
<select id="tl-add-track" class="zone-device-add-select"></select>
<button type="button" class="btn btn-secondary btn-small" id="tl-per-driver" title="One track for each driver in this zone's groups">One track per driver</button>
</div>
</div>
<aside class="tl-browser">
<div class="tl-browser-head"><span>Browser</span><button type="button" class="tl-tbtn" id="tl-browser-refresh" title="Reload presets">&#8635;</button></div>
<input type="search" id="tl-browser-search" placeholder="Search presets" autocomplete="off">
<div class="tl-browser-list" id="tl-browser-list"></div>
</aside>
</div>
<div class="tl-inspector" id="tl-inspector"></div>
</div>
<div id="sequence-editor-grid" class="seq-grid" hidden></div>
<div id="sequence-editor-lanes"></div>
<div class="modal-actions preset-editor-modal-actions">
<button type="button" class="btn btn-secondary btn-small" id="sequence-editor-add-lane-btn">Add lane</button>
<button type="button" class="btn btn-danger" id="sequence-editor-delete-btn">Delete</button>
</div>
</div>
@@ -464,11 +469,6 @@
<label for="preset-fade-input">Fade in (ms)</label>
<input type="number" id="preset-fade-input" placeholder="0" min="0" max="10000" step="50" value="0" title="Crossfade from what the strip showed when this preset is selected (needs updated drivers)">
</div>
<div class="preset-editor-field">
<label for="preset-beat-time-input" title="Delay and timing parameters count quarter beats instead of ms, so the preset follows the tempo">
<input type="checkbox" id="preset-beat-time-input"> Times in ¼ beats
</label>
</div>
<div class="preset-editor-field">
<label for="preset-background-input">Background</label>
<div class="profiles-actions" style="gap: 0.4rem;">
@@ -993,12 +993,9 @@
</div>
</div>
<ul>
<li><strong>Sequences</strong> (Edit mode): build multi-step shows with one or more <strong>lanes</strong> (each lane targets a device group).</li>
<li>Add presets as steps per lane; open from the zone editor to attach a sequence to a zone.</li>
<li><strong>Targets</strong>: list the drivers the sequence plays to (groups or single drivers; <em>One per driver</em> fills it from the zone). Each lane picks its targets, and a step can light just some of them.</li>
<li><strong>Lane options</strong>: timing in beats or seconds (beat and time lanes run side by side), <em>Start after</em> to offset a lane, <em>Speed</em> ¼×–4×, and <em>Chase</em> to move each step to the next target (forward, reverse, bounce, random).</li>
<li><strong>Animations</strong>: a one-shot clip. Its zone tile (⚡) plays it once over whatever runs, then the drivers go back; the sequence underneath keeps time. A step can fire an animation too.</li>
<li><strong>Show grid</strong>: all lanes on one time line, with the playing steps lit; click a cell to change it.</li>
<li><strong>Sequences</strong> (Edit mode): open from the zone editor to attach a sequence to a zone.</li>
<li><strong>Timeline</strong>: like music editing software. Each <strong>track</strong> is a group (or some drivers); time runs across in bars and beats (or seconds). Drag presets from the <em>Browser</em> onto a track, drag clips to move them and their edges to resize; scroll over the tracks to zoom. Click a track name to pick its groups (<em>One track per driver</em> fills them from the zone). Old sequences made with lanes, chases or speeds open as one pass of what they played. With <em>Loop</em> on, drag the end of the loop bar to set where every track restarts. ▶ saves and plays it, with a playhead.</li>
<li><strong>One-shots</strong>: a sequence with <em>Loop</em> off. On a zone (⚡) it plays once over whatever runs, then the zone goes back to its last looping preset or sequence; a looping sequence underneath keeps time. A sequence can play a one-shot as a clip too, for as long as the clip is drawn. Zones can mix looping presets, looping sequences and one-shots.</li>
<li><strong>Beat</strong> / <strong>Downbeat</strong> toggle (header): when starting a sequence, wait for beat or downbeat before step 1.</li>
<li>Tap <kbd>S</kbd> or the BPM button during playback to sync step timing to music (with Audio running).</li>
</ul>
@@ -1235,6 +1232,24 @@
<div id="network-status" class="muted-text">Loading…</div>
</div>
<!-- Bridges: USB boards and network boards that carry the radio frames (hidden where not supported) -->
<div class="settings-section" id="bridge-section" hidden>
<h3>Bridges</h3>
<small>Every ESP-NOW frame goes to each bridge, and a frame that several bridges hear arrives once. A USB board is its port (<code>/dev/ttyACM1</code>); a network board is <code>host:port</code> (UDP).</small>
<div id="bridge-list"></div>
<form id="bridge-add-form">
<div class="form-group">
<label for="bridge-add-input">Add a bridge</label>
<input type="text" id="bridge-add-input" list="bridge-ports" placeholder="/dev/ttyACM1 or 192.168.1.50:8766" maxlength="79" autocomplete="off">
<datalist id="bridge-ports"></datalist>
</div>
<div class="btn-group">
<button type="button" class="btn btn-secondary btn-full" id="bridge-refresh-btn">Refresh</button>
<button type="submit" class="btn btn-primary btn-full">Add</button>
</div>
</form>
</div>
<!-- Network -->
<div class="settings-section">
<h3>Network</h3>
@@ -1259,9 +1274,9 @@
<small>8 to 63 characters (WPA2). Leave empty for an open network.</small>
</div>
<div class="form-group">
<label for="bridge-input">Simulator bridge</label>
<input type="text" id="bridge-input" placeholder="off (drivers over the radio)" maxlength="63" autocomplete="off">
<small><code>host:port</code> of led-simulator (UDP, port 8766). While set, the controller talks to the simulated drivers instead of the radio. Leave empty for the real rig.</small>
<label for="bridge-input">Bridges</label>
<input type="text" id="bridge-input" placeholder="off (drivers over the radio)" maxlength="400" autocomplete="off">
<small>Comma-separated: USB boards (<code>/dev/ttyACM1</code>) and <code>host:port</code> (UDP, e.g. led-simulator on port 8766). While any are set, the controller sends its frames to them instead of the radio. Applied on the next restart; the list above applies at once.</small>
</div>
<div class="form-group">
<label>Static IPs</label>
@@ -1384,10 +1399,12 @@
<script src="/static/patterns.js"></script>
<script src="/static/presets.js"></script>
<script src="/static/sequences.js"></script>
<script src="/static/seq_timeline.js"></script>
<script src="/static/devices.js"></script>
<script src="/static/audio.js"></script>
<script src="/static/numpad.js"></script>
<script src="/static/outputs.js"></script>
<script src="/static/list_search.js"></script>
<script src="/static/sim_split.js"></script>
</body>
</html>