Viewer TUI
Interactive terminal grid of channel levels for one universe.
Source:
examples/viewer-tui.ts
Interactive terminal UI that redraws a 32×16 grid of channel levels for one universe. Requires a TTY.
npx tsx examples/viewer-tui.ts 1Environment: SACN_UNIVERSE, SACN_INTERFACE.
| Keys | Action |
|---|---|
← / → or h / l | Universe ±1 |
[ / ] | Universe ±10 |
q | Quit |
Core pieces: a ViewerService over NodeSacnReceiver, a subscribe listener
that stores the latest packet per universe, and a redraw loop. Full source is
in the core repo (terminal escape handling is lengthy and not repeated here).
import { ViewerService } from "@helioslx/core";
import { NodeSacnReceiver } from "@helioslx/core/node";
const iface = process.env.SACN_INTERFACE;
const viewer = new ViewerService({
receiver: new NodeSacnReceiver({
...(iface === undefined ? {} : { iface }),
}),
ownsReceiver: true,
});
await viewer.start();
await viewer.setSelectedUniverses([1]);
const unsubscribe = viewer.subscribe((packet) => {
// Update UI from packet.values (512 slots, 0-based index).
console.info(packet.universe, packet.values[0]);
});
// …redraw loop and key handling in the full example…Related: Viewing packets.