Set the movers' zeros and pan directions, swap M1/M2's patch, and model tilt in the simulator.

The front right mover is on DMX 1 and the front left on 45, so M1 and M2
swap addresses in the stage map and test.qxw. Measured on the rig, pan 0
faces forward on the front pair and into the middle on the back pair, back
at 85. M1 and M4 turn anticlockwise, so movers get a pan_reverse flag.

Tilt 127 now points straight down: the simulator draws a spot under the
head, and past 127 the beam flips behind the pan heading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-10-22 22:54:14 +13:00
1 parent 2b0f9e2f9b
commit fc8abf9c99
9 files changed
+124 -26

No files matched your search

+1 -1
View File
@@ -83,7 +83,7 @@ def _demo_frame(fixtures: list[Fixture], elapsed: float) -> bytearray:
for index, fixture in enumerate(movers):
pan = int(32768 + math.sin(elapsed * 0.6 + index * math.pi) * 9000)
pan = max(0, min(65535, pan))
tilt = 42000
tilt = 20000
_put(frame, fixture, "Pan", (pan >> 8) & 0xFF)
_put(frame, fixture, "Pan Fine", pan & 0xFF)
_put(frame, fixture, "Tilt", (tilt >> 8) & 0xFF)
+12 -2
View File
@@ -6,6 +6,7 @@ such as Dimmer, Red, Pan, and Zoom select the slots.
from __future__ import annotations
import math
import re
from simulator.stage import Fixture, Stage
@@ -13,6 +14,10 @@ from simulator.stage import Fixture, Stage
_PIXEL = re.compile(r"^(red|green|blue|white) (\d+)$", re.IGNORECASE)
PAN_DEGREES = 540.0
# Tilt 127 is straight down. 0 leans along the pan heading, 255 away from it.
TILT_DEGREES = 270.0
# Plan reach of a beam at or above horizontal.
BEAM_MAX_M = 4.7
ZOOM_MIN = 5.0
ZOOM_MAX = 45.0
@@ -378,8 +383,10 @@ def _decode_mover_named(channels: list[int], names: list[str]) -> dict:
pan_speed = _value(channels, names, "Pan/Tilt Speed")
pan_deg = (pan - 32768) / 65536.0 * PAN_DEGREES
zoom_deg = ZOOM_MIN + (zoom / 255.0) * (ZOOM_MAX - ZOOM_MIN)
# Long enough to read on the plan at tilt zero. Tilt stretches the throw.
beam_m = 2.2 + (tilt / 65535.0) * 2.5
tilt_deg = (tilt - 32768) / 65536.0 * TILT_DEGREES
# Reach along the pan heading on the plan. Negative points behind it.
lean = max(-90.0, min(90.0, -tilt_deg))
beam_m = BEAM_MAX_M * math.sin(math.radians(lean))
return {
"r": red,
"g": green,
@@ -393,6 +400,7 @@ def _decode_mover_named(channels: list[int], names: list[str]) -> dict:
"speed_hz": speed,
"dynamic": dynamic_name,
"pan_deg": round(pan_deg, 2),
"tilt_deg": round(tilt_deg, 2),
"zoom_deg": round(zoom_deg, 2),
"beam_m": round(beam_m, 3),
"pixels": tinted,
@@ -422,6 +430,8 @@ def view_fixture(fixture: Fixture, universes: dict[int, bytes]) -> dict:
viewed = decode_mover(channels)
else:
viewed = decode_can(channels)
if fixture.pan_reverse and "pan_deg" in viewed:
viewed["pan_deg"] = -viewed["pan_deg"]
viewed["patched"] = True
return viewed
+3
View File
@@ -36,6 +36,7 @@ class Fixture:
channel_names: list[str] = field(default_factory=list)
direction: float = 0.0 # cans: beam heading, degrees clockwise from +Y
zero: float = 0.0 # movers: heading at pan centre, same degrees
pan_reverse: bool = False # movers: rising pan turns the head anticlockwise
@property
def dmx(self) -> int | None:
@@ -61,6 +62,7 @@ class Fixture:
"channel_names": self.channel_names,
"direction": self.direction,
"zero": self.zero,
"pan_reverse": self.pan_reverse,
}
@@ -144,6 +146,7 @@ def load_stage(path: Path) -> Stage:
channel_names=channel_names,
direction=float(raw.get("direction") or 0),
zero=float(raw.get("zero") or 0),
pan_reverse=bool(raw.get("pan_reverse", False)),
)
)
return Stage(
+32 -3
View File
@@ -293,17 +293,24 @@ function drawGlow(sx, sy, fixture, color) {
function drawBeam(sx, sy, fixture, live, color, fixed) {
const level = (color.r + color.g + color.b) / 255;
const length = fixed ? fixed.beam : Math.max(live.beam_m || 0, fixture.kind === "mover" ? 2.2 : 0);
if (live.patched === false || level <= 0.02 || !length) return;
if (live.patched === false || level <= 0.02) return;
const aim = fixed || aimed(fixture.id, live, fixture.zero);
// Mover reach is signed: below zero the head has tilted past straight down.
const reach = fixed ? fixed.beam : fixture.kind === "mover" ? aim.beam : live.beam_m || 0;
// DMX focus 0 is a wide wash. Focus 255 holds the zoom angle.
// Fixed beams pass spread directly, 0 tight and 1 wide.
const spread = fixed ? fixed.focus : 1 - (live.focus || 0);
const zoom = fixed ? fixed.zoom : live.zoom_deg || 8;
const tight = zoom / 2;
const wide = Math.max(tight, 40);
const rad = aim.pan * Math.PI / 180;
const half = (tight + (wide - tight) * spread) * Math.PI / 180;
if (fixture.kind === "mover" && Math.abs(reach) < SPOT_M) {
drawSpot(sx, sy, fixture, aim.pan, reach, half, color, spread);
return;
}
const length = Math.abs(reach);
if (!length) return;
const rad = (aim.pan + (reach < 0 ? 180 : 0)) * Math.PI / 180;
const tip = [fixture.x + Math.sin(rad) * length, fixture.y + Math.cos(rad) * length];
const left = [fixture.x + Math.sin(rad - half) * length, fixture.y + Math.cos(rad - half) * length];
const right = [fixture.x + Math.sin(rad + half) * length, fixture.y + Math.cos(rad + half) * length];
@@ -320,6 +327,27 @@ function drawBeam(sx, sy, fixture, live, color, fixed) {
ctx.fill();
}
// Below this plan reach a mover is pointing near straight down.
const SPOT_M = 0.5;
// Throw to the floor for the spot under a mover.
const DROP_M = 2.5;
function drawSpot(sx, sy, fixture, pan, reach, half, color, spread) {
const rad = pan * Math.PI / 180;
const cx = sx(fixture.x + Math.sin(rad) * reach);
const cy = sy(fixture.y + Math.cos(rad) * reach);
const radius = Math.max(4, Math.abs(sx(DROP_M * Math.tan(half)) - sx(0)));
const gradient = ctx.createRadialGradient(cx, cy, 0, cx, cy, radius);
const alpha = 0.85 * (1 - spread * 0.35);
gradient.addColorStop(0, `rgba(${color.r},${color.g},${color.b},${alpha})`);
gradient.addColorStop(0.7, `rgba(${color.r},${color.g},${color.b},${alpha * 0.6})`);
gradient.addColorStop(1, `rgba(${color.r},${color.g},${color.b},0)`);
ctx.fillStyle = gradient;
ctx.beginPath();
ctx.arc(cx, cy, radius, 0, Math.PI * 2);
ctx.fill();
}
function lensRotation(live) {
if (live.spin_dps) return ((performance.now() / 1000) * live.spin_dps * Math.PI) / 180;
return ((live.lens_deg || 0) * Math.PI) / 180;
@@ -443,6 +471,7 @@ function updateDetail() {
if (live.reset) bits.push("reset");
if (fixture.kind === "mover" && live.pan_deg != null) {
bits.push(`pan ${live.pan_deg.toFixed(0)}°`);
if (live.tilt_deg != null) bits.push(`tilt ${live.tilt_deg.toFixed(0)}°`);
bits.push(`zoom ${(live.zoom_deg || 0).toFixed(0)}°`);
if (live.spin_dps) bits.push(`lens ${live.spin_dps > 0 ? "CW" : "CCW"}`);
else if (live.lens_deg) bits.push(`lens ${live.lens_deg.toFixed(0)}°`);