[][src]Struct step_dir::Driver

pub struct Driver<T> { /* fields omitted */ }

Abstract interface to stepper motor drivers

Wraps a concrete driver and uses the traits that the concrete driver implements to provide an abstract API. You can construct an instance of this type using Driver::from_inner.

Notes on timer use

Some of this struct's methods take a timer argument. This is expected to be an implementation of embedded_hal::timer::CountDown, with the additional requirement that CountDown::Time has a TryFrom<Nanoseconds> implementation, where Nanoseconds refers to embedded_time::duration::Nanoseconds.

Not every CountDown implementation provides this for its Time type, so it might be necessary that the user either adds this embedded_time integration to the HAL library they are using, or provides a wrapper around the CountDown implementation in their own code, adding the conversion there.

Every method that takes a timer argument internally performs the conversion from Nanoseconds to the timers Time type. Since the nanosecond values are constant and the CountDown implementation is known statically, the compiler should have enough information to perform this conversion at compile-time.

Unfortunately there is currently no way to make sure that this optimization actually happens. Additions like RFC 2632, RFC 2920, and possibly others along those lines, could help with this in the future. For now, users must manually inspect the generated code and tweak optimization settings (and possibly the HAL-specific conversion code), if this level of performance is required.

Implementations

impl<T> Driver<T>[src]

pub fn from_inner(inner: T) -> Self[src]

Create a new Driver instance from a concrete driver

pub fn inner(&self) -> &T[src]

Access a reference to the wrapped driver

Can be used to access driver-specific functionality that can't be provided by Driver's abstract interface.

pub fn inner_mut(&mut self) -> &mut T[src]

Access a mutable reference to the wrapped driver

Can be used to access driver-specific functionality that can't be provided by Driver's abstract interface.

pub fn release(self) -> T[src]

Release the wrapped driver

Drops this instance of Driver and returns the wrapped driver.

pub fn enable_step_mode_control<Resources, Timer>(
    self,
    res: Resources,
    initial: <T::WithStepModeControl as SetStepMode>::StepMode,
    timer: &mut Timer
) -> Result<Driver<T::WithStepModeControl>, Error<<T::WithStepModeControl as SetStepMode>::Error, <Timer::Time as TryFrom<Nanoseconds>>::Error, Timer::Error>> where
    T: EnableStepModeControl<Resources>,
    Timer: CountDown,
    Timer::Time: TryFrom<Nanoseconds>, 
[src]

Enable microstepping mode control

Consumes this instance of Driver and returns a new instance that provides control over the microstepping mode. Once this method has been called, the Driver::set_step_mode method becomes available.

Takes the hardware resources that are required for controlling the microstepping mode as an argument. What exactly those are depends on the specific driver. Typically they are the output pins that are connected to the mode pins of the driver.

This method is only available, if the driver supports enabling step mode control. It might no longer be available, once step mode control has been enabled.

pub fn set_step_mode<'r, Timer>(
    &'r mut self,
    step_mode: T::StepMode,
    timer: &'r mut Timer
) -> SetStepModeFuture<'r, T, Timer> where
    T: SetStepMode,
    Timer: CountDown,
    Timer::Time: TryFrom<Nanoseconds>, 
[src]

Sets the microstepping mode

This method is only available, if the wrapped driver supports microstepping, and supports setting the step mode through software. Some drivers might not support microstepping at all, or only allow setting the step mode by changing physical switches.

You might need to call Driver::enable_step_mode_control to make this method available.

pub fn enable_direction_control<Resources, Timer>(
    self,
    res: Resources,
    initial: Direction,
    timer: &mut Timer
) -> Result<Driver<T::WithDirectionControl>, Error<<T::WithDirectionControl as SetDirection>::Error, <Timer::Time as TryFrom<Nanoseconds>>::Error, Timer::Error>> where
    T: EnableDirectionControl<Resources>,
    Timer: CountDown,
    Timer::Time: TryFrom<Nanoseconds>, 
[src]

Enable direction control

Consumes this instance of Driver and returns a new instance that provides control over the motor direction. Once this method has been called, the Driver::set_direction method becomes available.

Takes the hardware resources that are required for controlling the direction as an argument. What exactly those are depends on the specific driver. Typically it's going to be the output pin that is connected to the driver's DIR pin.

This method is only available, if the driver supports enabling direction control. It might no longer be available, once direction control has been enabled.

pub fn set_direction<'r, Timer>(
    &'r mut self,
    direction: Direction,
    timer: &'r mut Timer
) -> SetDirectionFuture<'r, T, Timer> where
    T: SetDirection,
    Timer: CountDown,
    Timer::Time: TryFrom<Nanoseconds>, 
[src]

Set direction for future movements

You might need to call Driver::enable_direction_control to make this method available.

pub fn enable_step_control<Resources>(
    self,
    res: Resources
) -> Driver<T::WithStepControl> where
    T: EnableStepControl<Resources>, 
[src]

Enable step control

Consumes this instance of Driver and returns a new instance that provides control over stepping the motor. Once this method has been called, the Driver::step method becomes available.

Takes the hardware resources that are required for controlling the direction as an argument. What exactly those are depends on the specific driver. Typically it's going to be the output pin that is connected to the driver's STEP pin.

This method is only available, if the driver supports enabling step control. It might no longer be available, once step control has been enabled.

pub fn step<'r, Timer>(
    &'r mut self,
    timer: &'r mut Timer
) -> StepFuture<'r, T, Timer> where
    T: Step,
    Timer: CountDown,
    Timer::Time: TryFrom<Nanoseconds>, 
[src]

Rotates the motor one (micro-)step in the given direction

Steps the motor one step in the direction that was previously set, according to current microstepping configuration. To achieve a specific speed, the user must call this method at an appropriate frequency.

You might need to call Driver::enable_step_control to make this method available.

pub fn pulse_length(&self) -> Nanoseconds where
    T: Step
[src]

Returns the step pulse length of the wrapped driver

The pulse length is also available through the Step trait. This method provides a more convenient way to access it.

Auto Trait Implementations

impl<T> Send for Driver<T> where
    T: Send
[src]

impl<T> Sync for Driver<T> where
    T: Sync
[src]

impl<T> Unpin for Driver<T> where
    T: Unpin
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.