Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions CheapStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ void CheapStepper::run(){

if (micros() - lastStepTime >= delay) { // if time for step
if (stepsLeft > 0) { // clockwise
stepCW();
stepCW(false);
stepsLeft--;
} else if (stepsLeft < 0){ // counter-clockwise
stepCCW();
stepCCW(false);
stepsLeft++;
}

Expand All @@ -153,10 +153,13 @@ void CheapStepper::stop(){
}


void CheapStepper::step(bool clockwise){
void CheapStepper::step(bool clockwise, bool block){

if (clockwise) seqCW();
else seqCCW();
if(block) {
delayMicroseconds(delay);
}
}

void CheapStepper::off() {
Expand Down Expand Up @@ -293,7 +296,6 @@ void CheapStepper::seq (int seqNum){
for (int p=0; p<4; p++){
digitalWrite(pins[p], pattern[p]);
}
delayMicroseconds(delay);
}


6 changes: 3 additions & 3 deletions CheapStepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ class CheapStepper



void step (bool clockwise);
void step (bool clockwise, bool block = true);
// move 1 step clockwise or counter-clockwise

void stepCW () { step (true); } // move 1 step clockwise
void stepCCW () { step (false); } // move 1 step counter-clockwise
void stepCW (bool block = true) { step (true, block); } // move 1 step clockwise
void stepCCW (bool block = true) { step (false, block); } // move 1 step counter-clockwise

int getStep() { return stepN; } // returns current miniStep position
int getDelay() { return delay; } // returns current delay (microseconds)
Expand Down