pub struct ServoState<C> { /* private fields */ }
Expand description
Type to manage state for a single servo.
Implementations§
Source§impl<C> ServoState<C>
impl<C> ServoState<C>
Source§impl<C> ServoState<C>where
C: CalibrationData,
for<'a> <C as CalibrationData>::Iterator<'a>: Iterator<Item = (Point, Point)>,
impl<C> ServoState<C>where
C: CalibrationData,
for<'a> <C as CalibrationData>::Iterator<'a>: Iterator<Item = (Point, Point)>,
Sourcepub fn with_calibration(calibration: Calibration<C>) -> Self
pub fn with_calibration(calibration: Calibration<C>) -> Self
Construct a ServoState
based on some Calibration.
Sourcepub fn enable_with_return(&mut self) -> f32
pub fn enable_with_return(&mut self) -> f32
Enable the servo and return its pulse.
Sourcepub fn set_value_with_return(&mut self, value: f32) -> f32
pub fn set_value_with_return(&mut self, value: f32) -> f32
Set the value and return the pulse.
Sourcepub fn pulse_to_level(pulse: f32, resolution: u32, frequency: f32) -> u32
pub fn pulse_to_level(pulse: f32, resolution: u32, frequency: f32) -> u32
Convert the pulse, given a resolution and frequency, into a level for use by pwm signals.
Sourcepub fn set_pulse_with_return(&mut self, pulse: f32) -> Option<f32>
pub fn set_pulse_with_return(&mut self, pulse: f32) -> Option<f32>
Set the pulse and return the new pulse value. Can return None
when pulse is not larger
than the minimum valid pulse.
Sourcepub fn to_min_with_return(&mut self) -> f32
pub fn to_min_with_return(&mut self) -> f32
Move the servo to the minimum value and return the pulse.
Sourcepub fn to_mid_with_return(&mut self) -> f32
pub fn to_mid_with_return(&mut self) -> f32
Move the servo to the mid-point value and return the pulse.
Sourcepub fn to_max_with_return(&mut self) -> f32
pub fn to_max_with_return(&mut self) -> f32
Move the servo to the maximum value and return the pulse.
Sourcepub fn to_percent_with_return(&mut self, percent: f32) -> f32
pub fn to_percent_with_return(&mut self, percent: f32) -> f32
Move the servo to a percentage of its movement range.
0% corresponds to the servo’s minimum value, and 100% corresponds to the servo’s maximum value.
Sourcepub fn calibration(&self) -> &Calibration<C>
pub fn calibration(&self) -> &Calibration<C>
Get a shared reference of the servo’s calibration.
Sourcepub fn calibration_mut(&mut self) -> &mut Calibration<C>
pub fn calibration_mut(&mut self) -> &mut Calibration<C>
Get a unique reference to the servos’ calibration.
Auto Trait Implementations§
impl<C> Freeze for ServoState<C>where
C: Freeze,
impl<C> RefUnwindSafe for ServoState<C>where
C: RefUnwindSafe,
impl<C> Send for ServoState<C>where
C: Send,
impl<C> Sync for ServoState<C>where
C: Sync,
impl<C> Unpin for ServoState<C>where
C: Unpin,
impl<C> UnwindSafe for ServoState<C>where
C: UnwindSafe,
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
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more