From b0aac111a2a581c2d06fabc70ec7c6812031b844 Mon Sep 17 00:00:00 2001 From: torque Date: Sat, 6 Jul 2024 13:04:55 -0700 Subject: [PATCH] controller: implement elevation mask There's not really any analogous concept for azimuth. This is for a specific piece of hardware, so there's no real point in making it more generic. This is respected at the 180 degree point as well, for software that can handle flipped rotation configurations. This doesn't currently play well with the elevation offset setting, which should be applied after this clamping operation. Either this needs to be moved to the API layer or (more appropriately) the input range validation needs to move in the controller. --- src/Config.zig | 4 ++++ src/LabjackYaesu.zig | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Config.zig b/src/Config.zig index 64867a6..47e9dde 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -65,6 +65,9 @@ controller: ControllerConfig = .{ .parking_posture = .{ .azimuth = 180, .elevation = 90 }, .angle_tolerance = .{ .azimuth = 1, .elevation = 1 }, .angle_offset = .{ .azimuth = 0, .elevation = 0 }, + // this is a symmetric mask, so the minimum usable elevation is elevation_mask deg + // and the maximum usable elevation is 180 - elevation_mask deg + .elevation_mask = 0.0, }, pub const VoltAngle = struct { voltage: f64, angle: f64 }; @@ -115,6 +118,7 @@ const ControllerConfig = struct { parking_posture: AzEl, angle_tolerance: AzEl, angle_offset: AzEl, + elevation_mask: f64, const OutPair = struct { increase: lj.DigitalOutputChannel, diff --git a/src/LabjackYaesu.zig b/src/LabjackYaesu.zig index 34f5ab7..b46dab3 100644 --- a/src/LabjackYaesu.zig +++ b/src/LabjackYaesu.zig @@ -40,7 +40,13 @@ pub fn setTarget(self: LabjackYaesu, target: AzEl) void { defer self.lock.unlock(); const controller = @constCast(self.controller); - controller.target = target; + controller.target = .{ + .azimuth = target.azimuth, + .elevation = @min( + @max(target.elevation, config.controller.elevation_mask), + 180.0 - config.controller.elevation_mask, + ), + }; controller.requested_state = .running; }