When reading the Accelstepper.h following lines appear (from 476 to 489):
long currentPosition();
/// Resets the current position of the motor, so that wherever the motor
/// happens to be right now is considered to be the new 0 position. Useful
/// for setting a zero position on a stepper after an initial hardware
/// positioning move.
/// Has the side effect of setting the current motor speed to 0.
/// \param[in] position The position in steps of wherever the motor
/// happens to be right now.
void setCurrentPosition(long position);
/// Moves the motor (with acceleration/deceleration)
/// to the target position and blocks until it is at
/// position. Dont use this in event loops, since it blocks.
However, in Accelstepper.cpp following shows (lines 82 to 95:
long AccelStepper::currentPosition()
{
return _currentPos;
}
// Useful during initialisations or after initial positioning
// Sets speed to 0
void AccelStepper::setCurrentPosition(long position)
{
_targetPos = _currentPos = position;
_n = 0;
_stepInterval = 0;
_speed = 0.0;
}
-
Rather than resetting the current position to the new 0 position, does currentPosition not return the actually stored current position?
-
setCurrentPosition: can this not also be used to store a new value in setCurrentPosition? For example to assign a new value to currentPosition (without moving the stepper)
-
If the latter is not true, how can (with this library) a new value be assigned the currentPosition? For example, on startup or reset of the program) to assign a value to the current position of the stepper. Such as if, before reset, a specific current stepper position needs to be restored after reset.