Accel Stepper and Servo at Same Time

this code is based on the “overshoot” example… it simply ramps the motor one way, stops and ramps the opposite way.

I would also like to have use of a servo via potentiometer at the same time the motor is stepping ( it is for a camera rig with servo for focusing).

what I get is a complete movement to the new position, then a servo move, then a motor move, rather than both at the same time.

what am I doing wrong?

thanks!

dp

#include <VarSpeedServo.h>
#include <AccelStepper.h>

AccelStepper stepper(1,12,13);
VarSpeedServo fServo;
int goPos=5000;
#define APOT A2

void setup()
{
fServo.attach(10);

}
int prevRead;
void loop()
{

int potRead = map(analogRead(APOT),0,1023,0,180);
stepper.setMaxSpeed(3000);
stepper.setAcceleration(200);
stepper.runToNewPosition(0);
stepper.move(goPos);

while (stepper.currentPosition() !=goPos){
stepper.run();
fServo.slowmove(potRead,40);
}

// cause an overshoot as we whiz past 300
stepper.setCurrentPosition(0);
goPos=goPos*-1;
}

perhaps this should be under coding issues, but if clarification is needed: I am running the sparkfun easy stepper on pins 12 and 13. I thought the Accel stepper library was non-blocking, how can I maintain the accelerations and decelerations while focusing at the same time-- with the AF stepper library it was as simple as something like this in the main loop:

servo.slowmove(45,10);
stepper.step(1,FORWARD,INTERLEAVE);

however, if I am not mistaken, accelstepper library will not implement accelerations without the run() or other such statements..(e.g. runSpeedToPosition())--

some are blocking most are not--- however, run() sure seems to block my loop... no doubt it is how I am implementing but I have tried to break it up into smaller chunks with no luck... looking for some ideas based on experience that I lack. Thanks in advance.