embedded_stepper/driver.rs
1
2//! Low-level **coil driver** trait used by the high-level [Stepper](`crate::stepper::Stepper`).
3//!
4//! Implement this for your motor wiring to describe how each `this_step`
5//! energizes pins. Errors bubble up from the underlying GPIO pins via
6//! the associated `Error` type.
7//!
8//! Equivalent to the Arduino `stepMotor` function.
9
10/// Generic stepper “coil driver” interface (no_std, embedded-hal compatible).
11pub trait StepperMotor {
12 type Error;
13
14 /// Drive to a specific step (implementation decides sequence).
15 ///
16 /// Must take a step number, and use this to determine the coil sequence and energise accordingly
17 ///
18 /// Equivalent to the Arduino `stepMotor` function.
19 fn step(&mut self, this_step: u32) -> Result<(), Self::Error>;
20
21 /// De-energize all coils.
22 ///
23 /// Implementors should set all coil pins to `low`.
24 ///
25 /// Arduino stepper does not have this function, but it may be useful for drivers with no enable-disable
26 fn clear(&mut self) -> Result<(), Self::Error>;
27}