pub struct ServoMap { /* private fields */ }Expand description
Maps a servo angle to its RC pulse width in microseconds, and back.
A hobby servo is positioned by the width of a pulse repeated about every 20 ms: the standard
range is 1000 to 2000 microseconds spanning the full travel, with 1500 at centre.
ServoMap::standard uses those defaults over 180 degrees; ServoMap::new covers servos
with a different range or travel.
§Examples
use pamoja_kit::ServoMap;
let servo = ServoMap::standard();
assert_eq!(servo.pulse(0.0), 1000);
assert_eq!(servo.pulse(90.0), 1500); // centre
assert_eq!(servo.pulse(180.0), 2000);
assert!((servo.angle(1500) - 90.0).abs() < 1e-3);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ServoMap
impl RefUnwindSafe for ServoMap
impl Send for ServoMap
impl Sync for ServoMap
impl Unpin for ServoMap
impl UnsafeUnpin for ServoMap
impl UnwindSafe for ServoMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more