Accelstepper, joystick and avoiding setCurrentPosition()

I originally posted to
https://groups.google.com/forum/#!topic/accelstepper/T_USR692pM0
and was helped out by
https://groups.google.com/forum/#!searchin/accelstepper/360/accelstepper/2xpCtmseXZA/Y_b4RqOdjL8J
and
http://forum.arduino.cc/index.php?topic=246421.0
so I'm on the final stretch.

the code

if(UD1 < pointy1-10 || UD1 > pointy1+10 || LR1 < pointx1-10 || LR1 > pointx1+10){
      deltay1 = UD1-pointy1;
      deltax1 = LR1-pointx1;
      angleindegrees1 = ((atan2(deltay1, deltax1)) *180 / 3.1415926535 +180);
      stepperstep1 = map(angleindegrees1, 0, 360, 47, 0);
      laststep1 = stepperstep1;
  }else{
    stepperstep1 = laststep1;
  }
if(laststep1 == 47){
    stepper1.setCurrentPosition(47);
    stepper1.moveTo(stepperstep1);
  }
  else if(laststep1 == 0){
    stepper1.setCurrentPosition(0);
    stepper1.moveTo(stepperstep1);
  }else{
    stepper1.moveTo(stepperstep1);
  }
    stepper1.run();

works, but whenever I crossover from the first to the last step and vice versa, the speed drops to zero and sometimes it stutters and misses a few steps due to the setCurrentPosition() calls.

If anyone has any polishing, tips or code improvements I'm all ears, thanks!

My guess is that you are interfering with the natural working of the library. Your variable may have the value 47 before the accelStepper library gets to that position.

I think there is an AccelStepper function to get the actual position.

...R

Self bump/reply

I think there is an AccelStepper function to get the actual position.

Yes it's stepper1.currentPosition() for use in my example.

My guess is that you are interfering with the natural working of the library. Your variable may have the value 47 before the accelStepper library gets to that position.

The variables stepperstep1 and laststep1 are where the joystick is, the point is for the motor position to follow it.

This is going to take a AccelStepper ringer I know, there's not many options left for me.

The code in your Original Post does not include stepper1.currentPosition() so I see no reason to vary from my earlier comment.

Post your complete program.

And if you respond more quickly I might still remember what I have in my mind now.

...R