use cranpose_services::{MotionRate, MotionReference};
const ARBITRARY_HEADING: i32 = 0;
const MAGNETIC_NORTH: i32 = 1;
pub(crate) fn reference_code(reference: MotionReference) -> i32 {
match reference {
MotionReference::ArbitraryHeading => ARBITRARY_HEADING,
MotionReference::MagneticNorth => MAGNETIC_NORTH,
}
}
pub(crate) fn reference_of(code: i32) -> MotionReference {
match code {
MAGNETIC_NORTH => MotionReference::MagneticNorth,
_ => MotionReference::ArbitraryHeading,
}
}
pub(crate) fn period_micros(rate: MotionRate) -> i32 {
match rate {
MotionRate::Fastest => 0,
MotionRate::Period(period) => i32::try_from(period.as_micros()).unwrap_or(i32::MAX).max(1),
}
}
#[cfg(test)]
#[path = "tests/device_motion_wire_tests.rs"]
mod tests;