fix(controller): handle asymmetric CRSF lower/upper span in steering_to_crsf

This commit is contained in:
bleack committed 2026-11-21 11:14:56 +01:00
1 parent 95ad271232
commit 23e24cab5d
1 file changed
+5 -1
+5 -1
View File
@@ -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 curved = scaled * (1.0 - e + e * (scaled * scaled));
let directed = if invert { -curved } else { curved }; 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) (crsf.round() as u16).clamp(CRSF_CHANNEL_MIN, CRSF_CHANNEL_MAX)
} }