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,
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,
Sourcepub 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,
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
.
pub fn servos(&self) -> [ServoIdx; NUM_SERVOS]
Sourcepub fn enabled(&self, servo: ServoIdx) -> bool
pub fn enabled(&self, servo: ServoIdx) -> bool
Return whether or not this ServoCluster
is enabled.
Sourcepub fn set_enabled(&mut self, servo: ServoIdx, enable: bool, load: bool)
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.
Sourcepub fn set_pulse(&mut self, servo: ServoIdx, pulse: f32, load: bool)
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.
Sourcepub fn set_value(&mut self, servo: ServoIdx, value: f32, load: bool)
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.
Sourcepub fn set_phase(&mut self, servo: ServoIdx, phase: f32, load: bool)
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.
Sourcepub fn set_frequency(&mut self, system_clock_hz: HertzU32, frequency: f32)
pub fn set_frequency(&mut self, system_clock_hz: HertzU32, frequency: f32)
Set the pwm frequency being used for this ServoCluster
.
Sourcepub fn to_min(&mut self, servo: ServoIdx, load: bool)
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.
Sourcepub fn to_mid(&mut self, servo: ServoIdx, load: bool)
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.
Sourcepub fn to_max(&mut self, servo: ServoIdx, load: bool)
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.
Sourcepub fn to_percent(&mut self, servo: ServoIdx, percent: f32, load: bool)
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.
Sourcepub fn calibration(&self, servo: ServoIdx) -> &Calibration<Cal>
pub fn calibration(&self, servo: ServoIdx) -> &Calibration<Cal>
Get a shared reference to a particular servo’s calibration.
Sourcepub fn calibration_mut(&mut self, servo: ServoIdx) -> &mut Calibration<Cal>
pub fn calibration_mut(&mut self, servo: ServoIdx) -> &mut Calibration<Cal>
Get a unique reference to a particular servo’s calibration.
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>
impl<const NUM_SERVOS: usize, P, SM, Cal = NoCustom> !UnwindSafe for ServoCluster<NUM_SERVOS, P, SM, Cal>
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