-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Description
isRunning() returns false only if speed is not zero and distanceToGo is not 0, but when using runSpeedToPosition(), the speed is not set to zero even when the target position is reached. This means that when using runSpeedToPosition(), isRunning() always return true even when the move is completed. The following change should fix this...
boolean AccelStepper::runSpeedToPosition()
{
if (_targetPos == _currentPos)
{
_speed = 0.0;
return false;
}
if (_targetPos >_currentPos)
_direction = DIRECTION_CW;
else
_direction = DIRECTION_CCW;
return runSpeed();
}
Also, when using runSpeed(), the target position is not set, so isRunning() may return true even if the speed is set to zero. Changing isRunning() to use || instead of && should fix this (...as well as the previous problem), but I haven't looked into the code enough to determine if it'll cause other issues.
bool AccelStepper::isRunning()
{
return !(_speed == 0.0 || _targetPos == _currentPos);
}
Metadata
Metadata
Assignees
Labels
No labels