void MiniStepper::step(long steps) { long absSteps = abs(steps); byte stepDirection = (steps<0 ? -1 : 1); for (long i=0; i<absSteps; i+=stepDirection) { incrementStep(stepDirection); executeStep(); } }
bool StepperMotor::moveOneStepForward() { if (!interrupt) { stepIdx = incrementStep(stepIdx); moveOneStep(stepIdx); } return interrupt; }
bool StepperMotor::moveOneStepBackward() { if (!interrupt) { stepIdx = incrementStep(stepIdx); moveOneStep(NUMBER_OF_STEPS - stepIdx - 1); } return interrupt; }
void MiniStepper::step(long steps) { startIdleHold(); // engage all pins at this stage, so we can do incremental updates long absSteps = abs(steps); int stepDirection = (steps<0 ? -1 : 1); unsigned long startTime; unsigned long sleepTime; for (long i=0; i<absSteps; i++) { startTime = micros(); incrementStep(stepDirection); if (stepDirection > 0) { executePositiveStep(); } else { executeNegativeStep(); } delayMicroseconds(stepMicros - (startTime - micros())); // Always doing subtraction calculations to make sure we don't have weird rollover incidents. } }