Browse Source

fixed "step on limit" bug

prevent motor from stepping one step on limit
eLandon 4 years ago
parent
commit
69edc1bd20
1 changed files with 3 additions and 1 deletions
  1. 3 1
      Atm_AccelStepper.cpp

+ 3 - 1
Atm_AccelStepper.cpp

@@ -151,7 +151,7 @@ void Atm_AccelStepper::action( int id ) {
 
     case ENT_ENABLED:
       // _isHoming = 0 ;
-      // stepper_update();
+      stepper_update();
       if(last_trigger == EVT_ON_TARGET){push( connectors, ON_ONTARGET, 0, _currentStep, 0 );};
       push(connectors, ON_CHANGESTATE, 0,  state(), 0);
       push(connectors, ON_CHANGEPOSITION, 0,  stepper->currentPosition(), _currentSpeed);
@@ -167,6 +167,7 @@ void Atm_AccelStepper::action( int id ) {
       push(connectors, ON_CHANGESTATE, 0,  state(), 0);
       
       if (last_trigger!=EVT_ON_LIMIT_LOW && last_trigger!=EVT_ON_LIMIT_HIGH){compensatePlay(_currentSpeed);break;}
+
       if (runMode){stepper->setSpeed( _currentSpeed);}
       else{stepper->moveTo(_targetStep);}
       position_timer.setFromNow(this, POSITION_SEND_TIMER);
@@ -511,6 +512,7 @@ Atm_AccelStepper& Atm_AccelStepper::rotate( long  int speed) {
   runMode = 1;
   stepper->setSpeed( speed);
   _currentSpeed = stepper->speed();
+  stepper_update();
   enable();
   trigger( EVT_MOVE );
   return *this;