Outputs: positions (a key steps off → a → b → off, a knob up and down, the last off before the next on), strobe (a period) and dimmer (a knob's level by a step; a dimmable module gets a byte per channel, a relay just switches); in /keypad.html and /sim.html, a key's LED on while a position is chosen or a strobe runs
This commit is contained in:
1 parent
e82b2236b5
commit
82a728e024
7 files changed
+239
-55
No files matched your search
+4
-4
@@ -55,9 +55,9 @@
|
||||
<dl id="trip"></dl>
|
||||
</section>
|
||||
<section id="outputs" hidden>
|
||||
<h2>Relays</h2>
|
||||
<h2>Outputs</h2>
|
||||
<div id="relays"></div>
|
||||
<p style="color: GrayText; font-size: 0.85rem">can.json's "outputs" (simulated: no frames sent). A click switches one; the keypad's bindings with an "output" do too.</p>
|
||||
<p style="color: GrayText; font-size: 0.85rem">can.json's "outputs" (simulated: no frames sent). A click switches one (and stops its strobe); the keypad's bindings with an output do too.</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -118,9 +118,9 @@
|
||||
$("outputs").hidden = !data;
|
||||
if (!data) return;
|
||||
const esc = (s) => String(s).replace(/[&<>"]/g, (ch) => `&#${ch.charCodeAt(0)};`);
|
||||
const by = (o) => data.bindings.filter((b) => b.output === o).map((b) => `${b.input} (${b.mode || "toggle"})`).join(", ");
|
||||
const by = (o) => data.bindings.filter((b) => (b.outputs || [b.output]).includes(o)).map((b) => `${b.input} (${b.mode || "toggle"})`).join(", ");
|
||||
$("relays").innerHTML = data.modules.map((m) => `<p>${esc(m.name)} · node ${m.node}${m.simulated ? " · simulated" : ""}</p><div class="actions">` +
|
||||
m.channels.map((c) => `<button type="button" data-output="${esc(m.name)}/${c.n}" class="${c.on ? "on" : ""}" title="${esc(by(`${m.name}.${c.n}`))}">${c.on ? "●" : "○"} ${c.n}${c.label ? ` ${esc(c.label)}` : ""}</button>`).join("") + "</div>").join("");
|
||||
m.channels.map((c) => `<button type="button" data-output="${esc(m.name)}/${c.n}" class="${c.on ? "on" : ""}" title="${esc(by(`${m.name}.${c.n}`))}">${c.on ? "●" : "○"} ${c.n}${c.label ? ` ${esc(c.label)}` : ""}${c.level != null ? ` ${Math.round(c.level)} %` : ""}${c.strobe ? " · strobe" : ""}</button>`).join("") + "</div>").join("");
|
||||
}
|
||||
$("relays").addEventListener("click", (e) => {
|
||||
const b = e.target.closest("button[data-output]");
|
||||
|
||||
Reference in new issue
Block a user