Struct ServoCluster

Source
pub struct ServoCluster<const NUM_SERVOS: usize, P, SM, Cal = NoCustom>
where P: PIOExt, SM: StateMachineIndex,
{ /* private fields */ }
Expand description

A type to manage a cluster of servos all run from the same PIO state machine.

Implementations§

Source§

impl<'a, const NUM_SERVOS: usize, P, SM, Cal, F> ServoCluster<NUM_SERVOS, P, SM, Cal>
where Cal: Default + CalibrationData + Clone, for<'i> <Cal as CalibrationData>::Iterator<'i>: Iterator<Item = (Point, Point)>, P: PIOExt<PinFunction = F>, F: Function, SM: StateMachineIndex,

Source

pub fn builder<C1, C2, const NUM_CHANNELS: usize>( pio: &'a mut PIO<P>, sm: UninitStateMachine<(P, SM)>, dma_channels: (Channel<C1>, Channel<C2>), global_states: &'static mut GlobalStates<NUM_CHANNELS>, ) -> ServoClusterBuilder<'a, Cal, C1, C2, P, SM, F, NUM_SERVOS, NUM_CHANNELS>
where C1: ChannelIndex + 'static, C2: ChannelIndex + 'static,

Get a builder to help construct a ServoCluster.

Source

pub fn servos(&self) -> [ServoIdx; NUM_SERVOS]

Source

pub fn enabled(&self, servo: ServoIdx) -> bool

Return whether or not this ServoCluster is enabled.

Source

pub fn set_enabled(&mut self, servo: ServoIdx, enable: bool, load: bool)

Control whether the ServoCluster is enabled or not. If load is true, immeditely update the servo pwm signal.

Source

pub fn pulse(&self, servo: ServoIdx) -> Option<f32>

Get the pulse for a particular servo.

Source

pub fn set_pulse(&mut self, servo: ServoIdx, pulse: f32, load: bool)

Set the pulse for a particular servo. If load is true, immeditely update the servo pwm signal.

Source

pub fn value(&self, servo: ServoIdx) -> f32

Get the value for a particular servo.

Source

pub fn set_value(&mut self, servo: ServoIdx, value: f32, load: bool)

Set the value for a particular servo. If load is true, immeditely update the servo pwm signal.

Source

pub fn phase(&self, servo: ServoIdx) -> f32

Get the phase for a particular servo.

Source

pub fn set_phase(&mut self, servo: ServoIdx, phase: f32, load: bool)

Set the phase for a particular servo. If load is true, immeditely update the servo pwm signal.

Source

pub fn frequency(&self) -> f32

Get the pwm frequency being used for this ServoCluster.

Source

pub fn set_frequency(&mut self, system_clock_hz: HertzU32, frequency: f32)

Set the pwm frequency being used for this ServoCluster.

Source

pub fn min_value(&self, servo: ServoIdx) -> f32

Get the min value for a particular servo.

Source

pub fn mid_value(&self, servo: ServoIdx) -> f32

Get the mid value for a particular servo.

Source

pub fn max_value(&self, servo: ServoIdx) -> f32

Get the max value for a particular servo.

Source

pub fn to_min(&mut self, servo: ServoIdx, load: bool)

Set the min value for a particular servo. If load is true, immediately update the servo pwm signal.

Source

pub fn to_mid(&mut self, servo: ServoIdx, load: bool)

Set the mid value for a particular servo. If load is true, immediately update the servo pwm signal.

Source

pub fn to_max(&mut self, servo: ServoIdx, load: bool)

Set the max value for a particular servo. If load is true, immediately update the servo pwm signal.

Source

pub fn to_percent(&mut self, servo: ServoIdx, percent: f32, load: bool)

Set a particular servo to a percentage of its range. 0% maps to the servo’s minimum value, 100% maps to the servo’s maximum value.

Source

pub fn calibration(&self, servo: ServoIdx) -> &Calibration<Cal>

Get a shared reference to a particular servo’s calibration.

Source

pub fn calibration_mut(&mut self, servo: ServoIdx) -> &mut Calibration<Cal>

Get a unique reference to a particular servo’s calibration.

Source

pub fn load(&mut self)

Immediately update the pwm state for all servos.

Auto Trait Implementations§

§

impl<const NUM_SERVOS: usize, P, SM, Cal> Freeze for ServoCluster<NUM_SERVOS, P, SM, Cal>
where Cal: Freeze,

§

impl<const NUM_SERVOS: usize, P, SM, Cal = NoCustom> !RefUnwindSafe for ServoCluster<NUM_SERVOS, P, SM, Cal>

§

impl<const NUM_SERVOS: usize, P, SM, Cal = NoCustom> !Send for ServoCluster<NUM_SERVOS, P, SM, Cal>

§

impl<const NUM_SERVOS: usize, P, SM, Cal = NoCustom> !Sync for ServoCluster<NUM_SERVOS, P, SM, Cal>

§

impl<const NUM_SERVOS: usize, P, SM, Cal> Unpin for ServoCluster<NUM_SERVOS, P, SM, Cal>
where Cal: Unpin, P: Unpin, SM: Unpin,

§

impl<const NUM_SERVOS: usize, P, SM, Cal = NoCustom> !UnwindSafe for ServoCluster<NUM_SERVOS, P, SM, Cal>

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.