-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
If toStep is less than stepN the move to is incorrect. This also affects newMoveToDegree.
My solution:
void CheapStepper::newMoveTo (bool clockwise, int toStep){
// keep toStep in 0-(totalSteps-1) range
if (toStep >= totalSteps) toStep %= totalSteps;
else if (toStep < 0) {
toStep %= totalSteps; // returns negative if toStep not multiple of totalSteps
if (toStep < 0) toStep += totalSteps; // shift into 0-(totalSteps-1) range
lastStepTime = micros();
}
if (clockwise) { // drp correction for moveto < current position
if (toStep < stepN) toStep = toStep + totalSteps;
stepsLeft = toStep - stepN;
//stepsLeft = abs(toStep - stepN);
}
else {
if (toStep < stepN) { // drp correction for moveto < current position
stepsLeft= toStep - stepN;
}else{
//stepsLeft = -1*(totalSteps - abs(toStep - stepN));
stepsLeft = -1*(totalSteps - (toStep - stepN));
}
}
lastStepTime = micros();
}
As a bonus, abs no longer needed
David
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels