From 23e24cab5d03af1cbff4f07f6390413bd9888a8e Mon Sep 17 00:00:00 2001 From: bleack Date: Sat, 21 Nov 2026 11:14:56 +0100 Subject: [PATCH] fix(controller): handle asymmetric CRSF lower/upper span in steering_to_crsf --- src/controller.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controller.rs b/src/controller.rs index 4b526d6..ba26d48 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -297,7 +297,11 @@ pub fn steering_to_crsf(raw_norm: f32, deadzone: f32, expo: f32, invert: bool) - let curved = scaled * (1.0 - e + e * (scaled * scaled)); let directed = if invert { -curved } else { curved }; - let crsf = CRSF_CHANNEL_MID as f32 - directed * (CRSF_CHANNEL_MAX - CRSF_CHANNEL_MID) as f32; + let crsf = if directed >= 0.0 { + CRSF_CHANNEL_MID as f32 - directed * (CRSF_CHANNEL_MID - CRSF_CHANNEL_MIN) as f32 + } else { + CRSF_CHANNEL_MID as f32 - directed * (CRSF_CHANNEL_MAX - CRSF_CHANNEL_MID) as f32 + }; (crsf.round() as u16).clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX) }