Struct ServoState

Source
pub struct ServoState<C> { /* private fields */ }
Expand description

Type to manage state for a single servo.

Implementations§

Source§

impl<C> ServoState<C>

Source

pub fn new() -> Option<Self>

Constructs a new ServoState if the calibration type has 2 or more calibration points.

Source§

impl<C> ServoState<C>
where C: CalibrationData, for<'a> <C as CalibrationData>::Iterator<'a>: Iterator<Item = (Point, Point)>,

Source

pub fn with_calibration(calibration: Calibration<C>) -> Self

Construct a ServoState based on some Calibration.

Source

pub fn enable_with_return(&mut self) -> f32

Enable the servo and return its pulse.

Source

pub fn set_value_with_return(&mut self, value: f32) -> f32

Set the value and return the pulse.

Source

pub fn disable(&mut self)

Disable the servo.

Source

pub fn enabled(&self) -> bool

Return whether the servo is enabled.

Source

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.

Source

pub fn pulse(&self) -> Option<f32>

Get the pulse if available.

Source

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.

Source

pub fn value(&self) -> f32

Get the current value of the servo.

Source

pub fn to_min_with_return(&mut self) -> f32

Move the servo to the minimum value and return the pulse.

Source

pub fn to_mid_with_return(&mut self) -> f32

Move the servo to the mid-point value and return the pulse.

Source

pub fn to_max_with_return(&mut self) -> f32

Move the servo to the maximum value and return the pulse.

Source

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.

Source

pub fn calibration(&self) -> &Calibration<C>

Get a shared reference of the servo’s calibration.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

Source§

type Remainder = Choices

Source§

fn subset( self, ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<Source> Sculptor<HNil, HNil> for Source

Source§

type Remainder = Source

Source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.