#ifndef STEPPER_DRIVER_H #define STEPPER_DRIVER_H #include #include "esp_err.h" /** * @brief Abstract base class for stepper motor driver chips. * * This interface abstracts the low-level control of the stepper motor driver, * such as enabling/disabling, setting direction, sleep mode, and microstepping configuration. * It does NOT handle step generation (that is handled by the StepperMotor class using GPTimer). */ class StepperDriver { public: virtual ~StepperDriver() = default; /** * @brief Initialize the driver hardware (GPIOs, IO Expander, etc.) * @return ESP_OK on success */ virtual esp_err_t Init() = 0; /** * @brief Enable or disable the motor driver output. * @param enable true to enable, false to disable * @return ESP_OK on success */ virtual esp_err_t Enable(bool enable) = 0; /** * @brief Set the motor direction. * @param dir true for one direction (e.g. UP/CW), false for the other (e.g. DOWN/CCW) * @return ESP_OK on success */ virtual esp_err_t SetDirection(bool dir) = 0; /** * @brief Set the motor driver to sleep mode to save power. * @param sleep true to sleep, false to wake up * @return ESP_OK on success */ virtual esp_err_t Sleep(bool sleep) = 0; /** * @brief Set microstepping mode. * @param microsteps Microstepping value (e.g., 1, 2, 4, 8, 16, 32, etc.) * @return ESP_OK on success */ virtual esp_err_t SetMicrosteps(int microsteps) = 0; }; #endif // STEPPER_DRIVER_H