mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
fix(controller): handle asymmetric CRSF lower/upper span in steering_to_crsf
This commit is contained in:
1 parent
95ad271232
commit
23e24cab5d
1 file changed
+5
-1
+5
-1
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user