Keypads as channels and bindings, the PDMs' way (lib/maptool/keypad.rb): can.json's keypads (a Blink Marine PKP by its protocol, or any signals as inputs) give channels pad.K1, pad.E3, pad.E3 press; the drive profile's bindings give each a screen action, a knob action (zoom, pan, rows), another in an open menu and its LED colour, sent back to the PKP. Outputs (lib/maptool/outputs.rb): relay modules (simulated, no current measured), a binding's output with toggle/on/off/hold/pulse, hold off when the keypad goes silent, the state re-sent every 100 ms; /sim.html switches them by hand. CANopen TIME from maptool while no other node sends it (lib/maptool/can_time.rb), shown in /can.html
This commit is contained in:
1 parent
bf90f4cf23
commit
38fb06853e
14 files changed
+785
-24
No files matched your search
+1
-1
@@ -154,7 +154,7 @@
|
||||
const silent = Object.keys(last.nodes).filter((id) => last.nodes[id].silent);
|
||||
const shown = notice && notice.until > Date.now() ? notice : null;
|
||||
status.className = silent.length || shown?.bad ? "bad" : "";
|
||||
status.textContent = (shown ? `${shown.text} · ` : "") + (silent.length ? `⚠ node ${silent.join(", ")} silent · ` : "") + `updated ${new Date().toLocaleTimeString()}`;
|
||||
status.textContent = (shown ? `${shown.text} · ` : "") + (silent.length ? `⚠ node ${silent.join(", ")} silent · ` : "") + (last.time ? `TIME: ${last.time.sending ? "maptool sends it" : "another node sends it"} · ` : "") + `updated ${new Date().toLocaleTimeString()}`;
|
||||
} catch (e) {
|
||||
status.textContent = `can't reach the server: ${e.message}`;
|
||||
} finally {
|
||||
|
||||
+21
-1
@@ -54,6 +54,11 @@
|
||||
<h2>Trip</h2>
|
||||
<dl id="trip"></dl>
|
||||
</section>
|
||||
<section id="outputs" hidden>
|
||||
<h2>Relays</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>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@@ -107,8 +112,23 @@
|
||||
$("state").innerHTML = `<span class="bad">${e.message}</span>${/401/.test(e.message) ? ' — <a href="/login">log in</a>' : ""}`;
|
||||
}
|
||||
}
|
||||
// The relay modules (GET /api/outputs): a button per channel, lit when on.
|
||||
async function relays() {
|
||||
const data = await json("/api/outputs").catch(() => null);
|
||||
$("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(", ");
|
||||
$("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("");
|
||||
}
|
||||
$("relays").addEventListener("click", (e) => {
|
||||
const b = e.target.closest("button[data-output]");
|
||||
if (b) json(`/api/outputs/${b.dataset.output}`, { method: "POST" }).catch((err) => alert(err.message)).then(relays);
|
||||
});
|
||||
refresh();
|
||||
setInterval(refresh, 1000);
|
||||
relays();
|
||||
setInterval(() => { refresh(); relays(); }, 1000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user