Struct Stepper

Source
pub struct Stepper<M: StepperMotor, D: DelayNs> { /* private fields */ }
Expand description

High-level stepper controller parameterized by a motor coil driver M and a delay D.

Implementations§

Source§

impl<M: StepperMotor, D: DelayNs> Stepper<M, D>

Source

pub fn new(number_of_steps: u32, motor: M, delay: D) -> Self

Create a new controller.

  • number_of_steps: steps per mechanical revolution (as in Arduino stepper constructor)
  • motor: coil driver implementing StepperMotor
  • delay: timing provider implementing DelayNs
Source

pub fn set_speed(&mut self, speed: u32)

Set speed in RPM.

Equivalent to the Arduino stepper function with the same name except the division by 0 check.

If speed or number_of_steps are 0, the speed is set to 0

Source

pub fn deenergise(&mut self) -> Result<(), M::Error>

De-energize all coils by delegating to clear.

Source

pub fn step(&mut self, steps_to_move: i32) -> Result<(), M::Error>

Perform a blocking move of steps_to_move steps.

Positive values step forward; negative values step backward.

Ported from Arduino stepper step function

Auto Trait Implementations§

§

impl<M, D> Freeze for Stepper<M, D>
where M: Freeze, D: Freeze,

§

impl<M, D> RefUnwindSafe for Stepper<M, D>

§

impl<M, D> Send for Stepper<M, D>
where M: Send, D: Send,

§

impl<M, D> Sync for Stepper<M, D>
where M: Sync, D: Sync,

§

impl<M, D> Unpin for Stepper<M, D>
where M: Unpin, D: Unpin,

§

impl<M, D> UnwindSafe for Stepper<M, D>
where M: UnwindSafe, D: 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<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, 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.