main: respect the elevation mask after applying offsets

This prevents offsets from being able to point below the elevation
mask. The way this is done should probably be reworked, but this whole
thing is such a messy hack anyway that, like, whatever, man.
This commit is contained in:
torque 2024-08-22 13:56:37 -07:00
parent db55a5081d
commit ddbfb9746d
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk

View File

@ -185,9 +185,21 @@ pub const RotInt = struct {
.el = self.requested_posture.el,
};
mangled.el = if (mangled.el > 90)
@min(mangled.el, 180 - self.conf.elevation_mask) - self.offsets.el
@max(
@min(
@min(mangled.el, 180 - self.conf.elevation_mask) - self.offsets.el,
180 - self.conf.elevation_mask,
),
90,
)
else
@max(mangled.el, self.conf.elevation_mask) + self.offsets.el;
@min(
@max(
@max(mangled.el, self.conf.elevation_mask) + self.offsets.el,
self.conf.elevation_mask,
),
90,
);
self.sendRotatorCommand(.{ .set_position = mangled });
} else {