diff --git a/src/ContinuousStepper/OutputPin.hpp b/src/ContinuousStepper/OutputPin.hpp index ac33cf7..ef5ecc4 100644 --- a/src/ContinuousStepper/OutputPin.hpp +++ b/src/ContinuousStepper/OutputPin.hpp @@ -17,6 +17,10 @@ class OutputPin { pinMode(pin, OUTPUT); } + operator pin_t() const { + return _pin; + } + void set(bool level) { if (_level == uint8_t(level) || _pin == NULL_PIN) return; diff --git a/src/ContinuousStepper/StepperInterfaces.hpp b/src/ContinuousStepper/StepperInterfaces.hpp index b37d3c7..a8e7f50 100644 --- a/src/ContinuousStepper/StepperInterfaces.hpp +++ b/src/ContinuousStepper/StepperInterfaces.hpp @@ -39,7 +39,7 @@ class StepperDriver : public StepperInterface { // step() must be called twice per cycle: // - once to set the step pin high // - once to set it low - return true; + return _stepPin != NULL_PIN; } private: diff --git a/src/ContinuousStepperWithOscillator.hpp b/src/ContinuousStepperWithOscillator.hpp index 9ca16d8..c26790d 100644 --- a/src/ContinuousStepperWithOscillator.hpp +++ b/src/ContinuousStepperWithOscillator.hpp @@ -4,23 +4,9 @@ namespace ArduinoContinuousStepper { class ContinuousStepperWithOscillator : public ContinuousStepperBase { - class DirOnlyDriver : public StepperInterface { - public: - DirOnlyDriver(pin_t dirPin) : _dirPin(dirPin) {} - - void step() override {} - - void setDirection(bool reversed) { - _dirPin.set(reversed ? LOW : HIGH); - } - - private: - OutputPin _dirPin; - }; - public: void begin(pin_t stepPin, pin_t dirPin) { - ContinuousStepperBase::begin(new DirOnlyDriver(dirPin)); + ContinuousStepperBase::begin(new StepperDriver(NULL_PIN, dirPin)); _stepPin = stepPin; pinMode(stepPin, OUTPUT); }