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
+210
-19
@@ -32,6 +32,8 @@ const seqTl = {
|
||||
raf: 0,
|
||||
drag: null,
|
||||
hoverX: null, // the pointer's last x over the timeline: where the zoom buttons zoom around
|
||||
clipboard: null, // a copied or cut clip {play, len, timed, bpm}: kept while the page is open, for any sequence
|
||||
cursor: null, // {uid, at}: the last empty spot clicked on a track, where Paste puts a clip
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------ basics */
|
||||
@@ -381,10 +383,17 @@ function seqTlOnOpen(doc) {
|
||||
function tlNotice(text) {
|
||||
const n = tlEl('tl-notice');
|
||||
if (!n) return;
|
||||
clearTimeout(tlFlash.timer);
|
||||
n.textContent = text;
|
||||
n.hidden = !text;
|
||||
}
|
||||
|
||||
/** A notice that goes away by itself after a few seconds */
|
||||
function tlFlash(text) {
|
||||
tlNotice(text);
|
||||
tlFlash.timer = setTimeout(() => tlNotice(''), 3500);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ render */
|
||||
|
||||
function tlHeadWidth() {
|
||||
@@ -420,6 +429,19 @@ function tlSelect(sel) {
|
||||
document.querySelectorAll('#tl-canvas .tl-clip').forEach((el) => el.classList.toggle('sel', !!sel && sel.clip === parseInt(el.dataset.id, 10)));
|
||||
document.querySelectorAll('#tl-canvas .tl-track .tl-head').forEach((el) => el.classList.toggle('sel', !!sel && sel.track === parseInt(el.dataset.uid, 10)));
|
||||
tlRenderInspector();
|
||||
requestAnimationFrame(tlRevealSelection); // after the inspector has taken its height
|
||||
}
|
||||
|
||||
/** The inspector takes height under the tracks, so a clip or track picked near the bottom can end up below the
|
||||
* tracks' scroll area: scroll that area (only it, and only up or down) just enough to show it again. */
|
||||
function tlRevealSelection() {
|
||||
const el = document.querySelector('#tl-canvas .tl-clip.sel, #tl-canvas .tl-track .tl-head.sel');
|
||||
const scroller = el && el.closest('.tl-scroll');
|
||||
if (!scroller) return;
|
||||
const view = scroller.getBoundingClientRect();
|
||||
const box = el.getBoundingClientRect();
|
||||
const bottom = view.top + scroller.clientHeight; // above a horizontal scrollbar
|
||||
if (box.bottom > bottom) scroller.scrollTop += box.bottom - bottom + 4;
|
||||
}
|
||||
|
||||
function tlRender() {
|
||||
@@ -527,14 +549,19 @@ function tlRender() {
|
||||
head.appendChild(id);
|
||||
}
|
||||
head.dataset.uid = String(t.uid);
|
||||
head.addEventListener('click', () => tlSelect({ track: t.uid }));
|
||||
head.addEventListener('click', () => {
|
||||
seqTl.cursor = null; // Paste then goes to this track's first free place
|
||||
tlSelect({ track: t.uid });
|
||||
});
|
||||
|
||||
const lane = document.createElement('div');
|
||||
lane.className = 'tl-lane';
|
||||
lane.dataset.uid = String(t.uid);
|
||||
lane.style.width = `${W}px`;
|
||||
lane.addEventListener('pointerdown', (e) => {
|
||||
if (e.target === lane && seqTl.sel) tlSelect(null);
|
||||
if (e.target !== lane) return;
|
||||
seqTl.cursor = { uid: t.uid, at: tlQ(tlLaneX(lane, e.clientX) / seqTl.ppb, true) }; // where Paste goes
|
||||
if (seqTl.sel) tlSelect(null);
|
||||
});
|
||||
lane.addEventListener('dblclick', (e) => {
|
||||
if (e.target !== lane) return;
|
||||
@@ -793,6 +820,9 @@ function tlInspectClip(host, c) {
|
||||
const btns = document.createElement('div');
|
||||
btns.className = 'tl-insp-btns';
|
||||
btns.appendChild(tlBtn('Edit', 'Edit the preset or sequence', () => tlEditPlay(c.play)));
|
||||
btns.appendChild(tlBtn('Copy', 'Copy the clip (Ctrl+C)', () => tlCopy(c, false)));
|
||||
btns.appendChild(tlBtn('Cut', 'Cut the clip (Ctrl+X)', () => tlCopy(c, true)));
|
||||
if (seqTl.clipboard) btns.appendChild(tlBtn('Paste', 'Paste the copied clip after this one (Ctrl+V)', tlPaste));
|
||||
btns.appendChild(tlBtn('Delete', 'Remove the clip (Delete)', () => tlDelete(c), 'btn btn-danger btn-small'));
|
||||
host.appendChild(btns);
|
||||
}
|
||||
@@ -861,6 +891,9 @@ function tlInspectTrack(host, t) {
|
||||
down.disabled = i >= seqEd.targets.length - 1;
|
||||
btns.appendChild(up);
|
||||
btns.appendChild(down);
|
||||
if (seqTl.clipboard) {
|
||||
btns.appendChild(tlBtn('Paste', 'Paste the copied clip at the first free place on this track (Ctrl+V)', tlPaste));
|
||||
}
|
||||
btns.appendChild(
|
||||
tlBtn(
|
||||
'Remove track',
|
||||
@@ -968,11 +1001,23 @@ function tlDelete(c) {
|
||||
tlRender();
|
||||
}
|
||||
|
||||
/** The first start at or after `from` where a clip of length len fits on the track; null when none does before the end. */
|
||||
function tlFreeFrom(uid, from, len) {
|
||||
let start = tlR(Math.max(0, from));
|
||||
for (let guard = 0; guard < 256; guard++) {
|
||||
if (start + len > tlLoopLen() + TL_EPS) return null;
|
||||
if (tlFits(uid, start, len)) return start;
|
||||
const blocker = tlClipsOn(uid).find((x) => x.start + x.len > start + TL_EPS && x.start < start + len - TL_EPS);
|
||||
start = tlR(blocker ? blocker.start + blocker.len : start + len);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function tlDuplicate(c) {
|
||||
let start = tlR(c.start + c.len);
|
||||
for (let guard = 0; guard < 256 && !tlFits(c.uid, start, c.len); guard++) {
|
||||
const blocker = tlClipsOn(c.uid).find((x) => x.start + x.len > start + TL_EPS && x.start < start + c.len - TL_EPS);
|
||||
start = tlR(blocker ? blocker.start + blocker.len : start + c.len);
|
||||
const start = tlFreeFrom(c.uid, c.start + c.len, c.len);
|
||||
if (start === null) {
|
||||
tlFlash('No room after this clip before the end of the sequence.');
|
||||
return;
|
||||
}
|
||||
const d = { ...c, id: seqTl.nextId++, start };
|
||||
seqTl.clips.push(d);
|
||||
@@ -980,6 +1025,50 @@ function tlDuplicate(c) {
|
||||
tlRender();
|
||||
}
|
||||
|
||||
/** Copy the clip (what it plays and its length); cut also removes it. */
|
||||
function tlCopy(c, cut) {
|
||||
seqTl.clipboard = { play: c.play, len: c.len, timed: tlTimed(), bpm: tlBpm() };
|
||||
if (cut) tlDelete(c);
|
||||
else tlRenderInspector(); // shows Paste
|
||||
}
|
||||
|
||||
/** Paste the copied clip: after the selected clip on its track, else at the spot last clicked on a track, else at
|
||||
* the first free place on the selected track. The pasted clip is selected, so pasting again lines copies up. */
|
||||
function tlPaste() {
|
||||
const cb = seqTl.clipboard;
|
||||
if (!cb) return;
|
||||
let len = cb.len;
|
||||
if (cb.timed !== tlTimed()) len = cb.timed ? (len * tlBpm()) / 60 : (len * 60) / cb.bpm; // seconds <-> beats
|
||||
len = tlR(Math.max(tlMin(), len));
|
||||
const sel = seqTl.sel;
|
||||
const after = sel && sel.clip ? tlClip(sel.clip) : null;
|
||||
let uid;
|
||||
let from;
|
||||
if (after) {
|
||||
uid = after.uid;
|
||||
from = after.start + after.len;
|
||||
} else if (seqTl.cursor && tlTrack(seqTl.cursor.uid)) {
|
||||
uid = seqTl.cursor.uid;
|
||||
from = seqTl.cursor.at;
|
||||
} else if (sel && sel.track && tlTrack(sel.track)) {
|
||||
uid = sel.track;
|
||||
from = 0;
|
||||
} else {
|
||||
tlFlash('Click a track (or a clip) to paste on, then paste again.');
|
||||
return;
|
||||
}
|
||||
const start = tlFreeFrom(uid, from, len);
|
||||
if (start === null) {
|
||||
tlFlash('No room for the clip there before the end of the sequence.');
|
||||
return;
|
||||
}
|
||||
const c = { id: seqTl.nextId++, uid, start, len, play: cb.play };
|
||||
seqTl.clips.push(c);
|
||||
seqTl.sel = { clip: c.id };
|
||||
seqTl.cursor = null;
|
||||
tlRender();
|
||||
}
|
||||
|
||||
async function tlEditPlay(play) {
|
||||
const id = String(play || '').slice(2);
|
||||
if (!id) return;
|
||||
@@ -1283,6 +1372,93 @@ function tlDragEnd(e, cancelled) {
|
||||
tlRender();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- where Play plays it */
|
||||
|
||||
// "sim": the simulated bars only (/sequences/<id>/preview), the real fixtures keep their show. "both": the
|
||||
// zone's normal playback. The switch shows on host builds with the simulator; elsewhere Play is "both".
|
||||
const TL_TARGET_KEY = 'seqTlTarget';
|
||||
seqTl.target = 'both';
|
||||
seqTl.simAvail = false;
|
||||
|
||||
function tlSimOnly() {
|
||||
return seqTl.simAvail && seqTl.target === 'sim';
|
||||
}
|
||||
|
||||
function tlSetTarget(t) {
|
||||
seqTl.target = t === 'both' ? 'both' : 'sim';
|
||||
const box = tlEl('tl-target');
|
||||
if (box) {
|
||||
box.querySelectorAll('button[data-target]').forEach((b) => {
|
||||
const on = b.dataset.target === seqTl.target;
|
||||
b.classList.toggle('on', on);
|
||||
b.setAttribute('aria-pressed', String(on));
|
||||
});
|
||||
}
|
||||
const play = tlEl('tl-play');
|
||||
if (play) {
|
||||
play.title = tlSimOnly()
|
||||
? 'Save, then play it on the simulator only'
|
||||
: 'Save, then play it in the current zone';
|
||||
}
|
||||
const stop = tlEl('tl-stop');
|
||||
if (stop) stop.title = tlSimOnly() ? 'Stop the preview on the simulator' : 'Stop the sequence';
|
||||
}
|
||||
|
||||
async function tlInitTarget() {
|
||||
const box = tlEl('tl-target');
|
||||
if (!box) return;
|
||||
box.querySelectorAll('button[data-target]').forEach((b) =>
|
||||
b.addEventListener('click', () => {
|
||||
tlSetTarget(b.dataset.target);
|
||||
try {
|
||||
localStorage.setItem(TL_TARGET_KEY, seqTl.target);
|
||||
} catch (_) {
|
||||
/* private mode */
|
||||
}
|
||||
}));
|
||||
let saved = null;
|
||||
try {
|
||||
saved = localStorage.getItem(TL_TARGET_KEY);
|
||||
} catch (_) {
|
||||
/* private mode */
|
||||
}
|
||||
try {
|
||||
const r = await fetch('/sim/api/config', { cache: 'no-store' });
|
||||
seqTl.simAvail = r.ok; // the board: no simulator
|
||||
} catch (_) {
|
||||
seqTl.simAvail = false;
|
||||
}
|
||||
box.hidden = !seqTl.simAvail;
|
||||
tlSetTarget(saved === 'both' ? 'both' : 'sim');
|
||||
}
|
||||
|
||||
/** Save the edited sequence, then play it: on the simulator only, or in the current zone. */
|
||||
async function tlPlay() {
|
||||
const ok = await saveSequenceEditor();
|
||||
if (ok === false || !sequenceEditorId) return;
|
||||
const zid = resolveZoneIdForPresetStripRefresh();
|
||||
try {
|
||||
if (tlSimOnly()) {
|
||||
// The rig shows it: open the simulator beside the editor if it is closed
|
||||
if (!document.getElementById('sim-pane') && window.simSplit) window.simSplit.open('rig');
|
||||
const res = await fetch(`/sequences/${encodeURIComponent(sequenceEditorId)}/preview`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({ zone_id: zid ? String(zid) : '' }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const j = await res.json().catch(() => ({}));
|
||||
throw new Error(j.error || `Preview failed (${res.status})`);
|
||||
}
|
||||
} else if (!tlLoop()) await fireOneShot(sequenceEditorId, zid);
|
||||
else await requestBackendSequencePlay(sequenceEditorId, zid, null);
|
||||
} catch (err) {
|
||||
alert(err.message || 'Could not play it.');
|
||||
}
|
||||
}
|
||||
|
||||
window.seqTlPlay = tlPlay;
|
||||
|
||||
/* --------------------------------------------------------------- playhead */
|
||||
|
||||
function tlStartPoll() {
|
||||
@@ -1302,7 +1478,11 @@ async function tlPoll() {
|
||||
const r = await fetch('/sequences/status', { cache: 'no-store', headers: { Accept: 'application/json' } });
|
||||
const st = r.ok ? await r.json() : null;
|
||||
let lanes = null;
|
||||
if (st && st.overlay && st.overlay.active && String(st.overlay.sequence_id) === sequenceEditorId) lanes = st.overlay.lanes;
|
||||
let looping = !!(st && st.active && String(st.sequence_id) === sequenceEditorId);
|
||||
if (st && st.preview && st.preview.active && String(st.preview.sequence_id) === sequenceEditorId) {
|
||||
lanes = st.preview.lanes; // the simulator's preview of this sequence
|
||||
looping = !!st.preview.loop;
|
||||
} else if (st && st.overlay && st.overlay.active && String(st.overlay.sequence_id) === sequenceEditorId) lanes = st.overlay.lanes;
|
||||
else if (st && st.active && String(st.sequence_id) === sequenceEditorId) lanes = st.lanes;
|
||||
if (Array.isArray(lanes)) {
|
||||
const { map } = tlToLanes();
|
||||
@@ -1313,7 +1493,6 @@ async function tlPoll() {
|
||||
const timed = l.mode === 'time';
|
||||
const s = m.starts[l.step] != null ? m.starts[l.step] : 0;
|
||||
const into = timed ? (l.elapsed_ms || 0) / 1000 : l.beat_in_step || 0;
|
||||
const looping = !!(st && st.active && String(st.sequence_id) === sequenceEditorId);
|
||||
const now = performance.now();
|
||||
const next = {
|
||||
pos: s + into,
|
||||
@@ -1456,18 +1635,18 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
e.target.value = timed ? 'beats' : 'time';
|
||||
tlSetUnits(timed);
|
||||
});
|
||||
on('tl-play', 'click', async () => {
|
||||
const ok = await saveSequenceEditor();
|
||||
if (ok === false || !sequenceEditorId) return;
|
||||
const zid = resolveZoneIdForPresetStripRefresh();
|
||||
try {
|
||||
if (!tlLoop()) await fireOneShot(sequenceEditorId, zid);
|
||||
else await requestBackendSequencePlay(sequenceEditorId, zid, null);
|
||||
} catch (err) {
|
||||
alert(err.message || 'Could not play it.');
|
||||
}
|
||||
});
|
||||
on('tl-play', 'click', tlPlay);
|
||||
tlInitTarget();
|
||||
on('tl-stop', 'click', async () => {
|
||||
if (tlSimOnly()) {
|
||||
// Only the preview stops: the real fixtures keep their show
|
||||
try {
|
||||
await fetch('/sequences/preview/stop', { method: 'POST', headers: { Accept: 'application/json' } });
|
||||
} catch (_) {
|
||||
/* nothing to stop */
|
||||
}
|
||||
return;
|
||||
}
|
||||
// A one-shot plays over the zone: end it as well as the looping sequence
|
||||
try {
|
||||
await fetch('/sequences/overlay/stop', { method: 'POST', headers: { Accept: 'application/json' } });
|
||||
@@ -1493,8 +1672,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
else tlUndo();
|
||||
return;
|
||||
}
|
||||
if ((e.ctrlKey || e.metaKey) && k === 'v') {
|
||||
if (!seqTl.clipboard) return;
|
||||
e.preventDefault();
|
||||
tlPaste();
|
||||
return;
|
||||
}
|
||||
const c = seqTl.sel && seqTl.sel.clip ? tlClip(seqTl.sel.clip) : null;
|
||||
if (!c) return;
|
||||
if ((e.ctrlKey || e.metaKey) && (k === 'c' || k === 'x')) {
|
||||
if (k === 'c' && String(window.getSelection ? window.getSelection() : '')) return; // copying page text
|
||||
e.preventDefault();
|
||||
tlCopy(c, k === 'x');
|
||||
return;
|
||||
}
|
||||
if (e.key === 'Delete' || e.key === 'Backspace') {
|
||||
e.preventDefault();
|
||||
tlDelete(c);
|
||||
|
||||
Reference in new issue
Block a user