mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
fix(review): apply critical code-review optimizations for locks, memory, and responsiveness
This commit is contained in:
1 parent
2d9be15713
commit
a55ca0a25d
4 files changed
+156
-70
No files matched your search
+4
-1
@@ -171,7 +171,7 @@ impl NomadHeadTracker {
|
||||
|
||||
#[inline]
|
||||
pub fn deg_to_crsf(angle_deg: f32, max_deg: f32) -> u16 {
|
||||
if angle_deg.is_nan() || max_deg <= 0.0 {
|
||||
if angle_deg.is_nan() || !(max_deg > 0.0) {
|
||||
return CRSF_CHANNEL_MID;
|
||||
}
|
||||
let norm = (angle_deg / max_deg).clamp(-1.0, 1.0);
|
||||
@@ -254,6 +254,9 @@ mod tests {
|
||||
assert_eq!(NomadHeadTracker::deg_to_crsf(90.0, 90.0), CRSF_CHANNEL_MAX);
|
||||
assert_eq!(NomadHeadTracker::deg_to_crsf(-90.0, 90.0), CRSF_CHANNEL_MIN);
|
||||
assert_eq!(NomadHeadTracker::deg_to_crsf(f32::NAN, 90.0), CRSF_CHANNEL_MID);
|
||||
assert_eq!(NomadHeadTracker::deg_to_crsf(45.0, f32::NAN), CRSF_CHANNEL_MID);
|
||||
assert_eq!(NomadHeadTracker::deg_to_crsf(45.0, 0.0), CRSF_CHANNEL_MID);
|
||||
assert_eq!(NomadHeadTracker::deg_to_crsf(45.0, -10.0), CRSF_CHANNEL_MID);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user