Skip to content

Commit

Permalink
Replace DirOnlyDriver with StepperDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Aug 7, 2023
1 parent 176a3e4 commit 16935a5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/ContinuousStepper/OutputPin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ContinuousStepper/StepperInterfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 1 addition & 15 deletions src/ContinuousStepperWithOscillator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 16935a5

Please sign in to comment.