SoftwareMotionControl

Struct SoftwareMotionControl 

Source
pub struct SoftwareMotionControl<Driver, Timer, Profile: MotionProfile, Convert, const TIMER_HZ: u32> { /* private fields */ }
Expand description

Software implementation of motion control capability

Some driver natively support motion control capability. This is a software implementation of the MotionControl trait for those drivers that don’t. It wraps a driver that implements SetDirection and Step, and in turn acts like a driver itself, adding to the wrapped driver’s capabilities.

You can use SoftwareMotionControl directly, but like a driver, it is designed to be used through the Stepper API.

Implementations§

Source§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Profile: MotionProfile,

Source

pub fn new( driver: Driver, timer: Timer, profile: Profile, convert: Convert, ) -> Self

Construct a new instance of SoftwareMotionControl

Instead of using this constructor directly, you can instead use Stepper::enable_motion_control with any driver that implements SetDirection and Step, providing timer and a motion profile. This module provides a blanket implementation of EnableMotionControl to make this work.

Source

pub fn driver(&self) -> Option<&Driver>

Access a reference to the wrapped driver

This is only possible if there is no ongoing movement.

Source

pub fn driver_mut(&mut self) -> Option<&mut Driver>

Access a mutable reference to the wrapped driver

This is only possible if there is no ongoing movement.

Source

pub fn timer(&self) -> Option<&Timer>

Access a reference to the wrapped timer

This is only possible if there is no ongoing movement.

Source

pub fn timer_mut(&mut self) -> Option<&mut Timer>

Access a mutable reference to the wrapped timer

This is only possible if there is no ongoing movement.

Source

pub fn profile(&self) -> &Profile

Access a reference to the wrapped motion profile

Source

pub fn profile_mut(&mut self) -> &mut Profile

Access a mutable reference to the wrapped motion profile

Source

pub fn current_step(&self) -> i32

Access the current step

Source

pub fn current_direction(&self) -> Direction

Access the current direction

Source

pub fn set_step_mode( &mut self, step_mode: Driver::StepMode, ) -> Result<SetStepModeFuture<RefMut<'_, Driver>, RefMut<'_, Timer>, TIMER_HZ>, BusyError<Infallible>>
where Driver: SetStepMode, Timer: TimerTrait<TIMER_HZ>,

Set step mode of the wrapped driver

This method is a more convenient alternative to Stepper::set_step_mode, which requires a timer, while this methods reuses the timer that SoftwareMotionControl already owns.

However, while Stepper::set_step_mode is part of the generic API, this method is only available, if you statically know that you’re working with a driver wrapped by SoftwareMotionControl.

§Errors

Returns BusyError::Busy, if a motion is ongoing.

Source

pub fn set_direction( &mut self, direction: Direction, ) -> Result<SetDirectionFuture<RefMut<'_, Driver>, RefMut<'_, Timer>, TIMER_HZ>, BusyError<Infallible>>
where Driver: SetDirection, Timer: TimerTrait<TIMER_HZ>,

Set direction of the wrapped driver

This method is a more convenient alternative to Stepper::set_direction, which requires a timer, while this methods reuses the timer that SoftwareMotionControl already owns.

However, while Stepper::set_direction is part of the generic API, this method is only available, if you statically know that you’re working with a driver wrapped by SoftwareMotionControl.

§Errors

Returns BusyError::Busy, if a motion is ongoing.

Source

pub fn step( &mut self, ) -> Result<StepFuture<RefMut<'_, Driver>, RefMut<'_, Timer>, TIMER_HZ>, BusyError<Infallible>>
where Driver: Step, Timer: TimerTrait<TIMER_HZ>,

Tell the wrapped driver to move the motor one step

This method is a more convenient alternative to Stepper::step, which requires a timer, while this methods reuses the timer that SoftwareMotionControl already owns.

However, while Stepper::step is part of the generic API, this method is only available, if you statically know that you’re working with a driver wrapped by SoftwareMotionControl.

§Errors

Returns BusyError::Busy, if a motion is ongoing.

Trait Implementations§

Source§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> MotionControl for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Driver: SetDirection + Step, Profile: MotionProfile, Timer: TimerTrait<TIMER_HZ>, Profile::Velocity: Copy, Convert: DelayToTicks<Profile::Delay, TIMER_HZ>,

Source§

type Velocity = <Profile as MotionProfile>::Velocity

The type used by the driver to represent velocity
Source§

type Error = Error<<Driver as SetDirection>::Error, <<Driver as SetDirection>::Dir as ErrorType>::Error, <Driver as Step>::Error, <<Driver as Step>::Step as ErrorType>::Error, <Timer as Timer<TIMER_HZ>>::Error, <Convert as DelayToTicks<<Profile as MotionProfile>::Delay, TIMER_HZ>>::Error>

The type error that can happen when using this trait
Source§

fn move_to_position( &mut self, max_velocity: Self::Velocity, target_step: i32, ) -> Result<(), Self::Error>

Move to the given position Read more
Source§

fn reset_position(&mut self, step: i32) -> Result<(), Self::Error>

Reset internal position to the given value Read more
Source§

fn update(&mut self) -> Result<bool, Self::Error>

Update an ongoing motion Read more
Source§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> SetDirection for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Driver: SetDirection, Profile: MotionProfile,

Source§

const SETUP_TIME: Nanoseconds = Driver::SETUP_TIME

The time that the DIR signal must be held for a change to apply
Source§

type Dir = <Driver as SetDirection>::Dir

The type of the DIR pin
Source§

type Error = BusyError<<Driver as SetDirection>::Error>

The error that can occur while accessing the DIR pin
Source§

fn dir(&mut self) -> Result<&mut Self::Dir, Self::Error>

Provides access to the DIR pin
Source§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> SetStepMode for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Driver: SetStepMode, Profile: MotionProfile,

Source§

const SETUP_TIME: Nanoseconds = Driver::SETUP_TIME

The time the mode signals need to be held before re-enabling the driver
Source§

const HOLD_TIME: Nanoseconds = Driver::HOLD_TIME

The time the mode signals need to be held after re-enabling the driver
Source§

type Error = BusyError<<Driver as SetStepMode>::Error>

The error that can occur while using this trait
Source§

type StepMode = <Driver as SetStepMode>::StepMode

The type that defines the microstepping mode Read more
Source§

fn apply_mode_config( &mut self, step_mode: Self::StepMode, ) -> Result<(), Self::Error>

Apply the new step mode configuration Read more
Source§

fn enable_driver(&mut self) -> Result<(), Self::Error>

Re-enable the driver after the mode has been set
Source§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> Step for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Driver: Step, Profile: MotionProfile,

Source§

const PULSE_LENGTH: Nanoseconds = Driver::PULSE_LENGTH

The minimum length of a STEP pulse
Source§

type Step = <Driver as Step>::Step

The type of the STEP pin
Source§

type Error = BusyError<<Driver as Step>::Error>

The error that can occur while accessing the STEP pin
Source§

fn step(&mut self) -> Result<&mut Self::Step, Self::Error>

Provides access to the STEP pin

Auto Trait Implementations§

§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> Freeze for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Profile: Freeze, Convert: Freeze, Driver: Freeze, Timer: Freeze, <Profile as MotionProfile>::Delay: Freeze,

§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> RefUnwindSafe for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Profile: RefUnwindSafe, Convert: RefUnwindSafe, Driver: RefUnwindSafe, Timer: RefUnwindSafe, <Profile as MotionProfile>::Delay: RefUnwindSafe,

§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> Send for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Profile: Send, Convert: Send, Driver: Send, Timer: Send, <Profile as MotionProfile>::Delay: Send,

§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> Sync for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Profile: Sync, Convert: Sync, Driver: Sync, Timer: Sync, <Profile as MotionProfile>::Delay: Sync,

§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> Unpin for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Profile: Unpin, Convert: Unpin, Driver: Unpin, Timer: Unpin, <Profile as MotionProfile>::Delay: Unpin,

§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> UnwindSafe for SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>
where Profile: UnwindSafe, Convert: UnwindSafe, Driver: UnwindSafe, Timer: UnwindSafe, <Profile as MotionProfile>::Delay: 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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<Driver, Timer, Profile, Convert, const TIMER_HZ: u32> EnableMotionControl<(Timer, Profile, Convert), TIMER_HZ> for Driver
where Driver: SetDirection + Step, Profile: MotionProfile, Timer: Timer<TIMER_HZ>, <Profile as MotionProfile>::Velocity: Copy, Convert: DelayToTicks<<Profile as MotionProfile>::Delay, TIMER_HZ>,

Source§

type WithMotionControl = SoftwareMotionControl<Driver, Timer, Profile, Convert, TIMER_HZ>

The type of the driver after motion control has been enabled
Source§

fn enable_motion_control( self, _: (Timer, Profile, Convert), ) -> <Driver as EnableMotionControl<(Timer, Profile, Convert), TIMER_HZ>>::WithMotionControl

Enable step control
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.