stepper_motion/lib.rs
1//! # stepper-motion
2//!
3//! Configuration-driven stepper motor motion control with embedded-hal 1.0 support.
4//!
5//! ## Features
6//!
7//! - **Configuration-driven**: Define motors and trajectories in TOML files
8//! - **embedded-hal 1.0**: Uses `OutputPin` for STEP/DIR, `DelayNs` for timing
9//! - **no_std compatible**: Core library works without standard library
10//! - **Asymmetric profiles**: Independent acceleration and deceleration rates
11//! - **Position tracking**: Absolute position tracked at all times
12//! - **Type-state safety**: Compile-time motor state verification
13//!
14//! ## Quick Start
15//!
16//! ```rust,ignore
17//! use stepper_motion::{StepperMotor, SystemConfig};
18//!
19//! // Load configuration from TOML
20//! let config: SystemConfig = stepper_motion::load_config("motion.toml")?;
21//!
22//! // Create motor with embedded-hal pins
23//! let mut motor = StepperMotor::builder()
24//! .from_config(&config, "x_axis")?
25//! .step_pin(step_pin)
26//! .dir_pin(dir_pin)
27//! .delay(delay)
28//! .build()?;
29//!
30//! // Execute named trajectory
31//! motor.execute("home")?;
32//! ```
33//!
34//! ## Feature Flags
35//!
36//! - `std` (default): Enables file I/O and TOML parsing
37//! - `alloc`: Enables heap allocation for no_std with allocator
38//! - `defmt`: Enables defmt logging for embedded targets
39
40#![cfg_attr(not(feature = "std"), no_std)]
41#![warn(missing_docs)]
42#![warn(clippy::all)]
43#![deny(unsafe_code)]
44// Allow large error types - necessary for no_std with heapless strings
45#![allow(clippy::result_large_err)]
46
47#[cfg(feature = "alloc")]
48extern crate alloc;
49
50// Core modules
51pub mod config;
52pub mod error;
53pub mod motion;
54pub mod motor;
55pub mod trajectory;
56
57// Re-exports for ergonomic API
58pub use config::{MotorConfig, SystemConfig, TrajectoryConfig, validate_config};
59pub use error::{Error, Result};
60pub use motion::{Direction, MotionPhase, MotionProfile};
61pub use motor::{state, MotorSystem, StepperMotor};
62pub use trajectory::TrajectoryRegistry;
63
64// Configuration loading (std only)
65#[cfg(feature = "std")]
66pub use config::load_config;
67
68// Unit types
69pub use config::units::{Degrees, DegreesPerSec, DegreesPerSecSquared, Microsteps, Steps};