|
@@ -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);
|
|
@@ -166,7 +166,7 @@ void Atm_AccelStepper::action( int id ) {
|
|
|
case ENT_RUNNING:
|
|
|
push(connectors, ON_CHANGESTATE, 0, state(), 0);
|
|
|
|
|
|
- if (last_trigger!=EVT_ON_LIMIT_LOW && last_trigger!=EVT_ON_LIMIT_HIGH){compensatePlay(_currentSpeed);}
|
|
|
+ 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);
|
|
@@ -177,23 +177,24 @@ void Atm_AccelStepper::action( int id ) {
|
|
|
// if on limits and limits are hard, stop moving in one direction
|
|
|
if(limitLow_State && _limitLow_Hard && (_currentSpeed<0.)) {
|
|
|
trigger(EVT_EMERGENCY_STOP);
|
|
|
-
|
|
|
+ break;
|
|
|
}
|
|
|
if( limitHigh_State && _limitHigh_Hard && (_currentSpeed>0.)) {
|
|
|
trigger(EVT_EMERGENCY_STOP);
|
|
|
+ break;
|
|
|
}
|
|
|
// if hard limits and homing is done, check current position is within limits
|
|
|
if (_limitLow_Hard && homingLow_done) {
|
|
|
- if( (_currentStep<0) && (_currentSpeed<0.)) {trigger(EVT_EMERGENCY_STOP);}
|
|
|
+ if( (_currentStep<0) && (_currentSpeed<0.)) {trigger(EVT_EMERGENCY_STOP);break;}
|
|
|
}
|
|
|
if (_limitHigh_Hard && _maxStep) { //maxstep is 0 if not defined
|
|
|
- if( (_currentStep>_maxStep) && (_currentSpeed>0.)) {trigger(EVT_EMERGENCY_STOP);}
|
|
|
+ if( (_currentStep>_maxStep) && (_currentSpeed>0.)) {trigger(EVT_EMERGENCY_STOP);break;}
|
|
|
}
|
|
|
|
|
|
stepper_update();
|
|
|
|
|
|
- if(runMode && _currentSpeed == 0.) {trigger(EVT_EMERGENCY_STOP);}//trigger(EVT_ON_TARGET);
|
|
|
- if(!runMode && (_currentStep==_targetStep)){push( connectors, ON_ONTARGET, 0, _currentStep, 0 );trigger(EVT_EMERGENCY_STOP);}
|
|
|
+ if(runMode && _currentSpeed == 0.) {trigger(EVT_EMERGENCY_STOP);break;}//trigger(EVT_ON_TARGET);
|
|
|
+ if(!runMode && (_currentStep==_targetStep)){push( connectors, ON_ONTARGET, 0, _currentStep, 0 );trigger(EVT_EMERGENCY_STOP);break;}
|
|
|
return;
|
|
|
|
|
|
case ENT_STOP:
|
|
@@ -204,6 +205,7 @@ void Atm_AccelStepper::action( int id ) {
|
|
|
// stepper_update();
|
|
|
stepper->stop();
|
|
|
_targetStep = stepper->targetPosition();
|
|
|
+ break;
|
|
|
// push( connectors, ON_STOP, 0, 0, 0 );
|
|
|
}
|
|
|
if (last_trigger == EVT_EMERGENCY_STOP) {
|
|
@@ -212,17 +214,19 @@ void Atm_AccelStepper::action( int id ) {
|
|
|
_currentStep = stepper->currentPosition();
|
|
|
_targetStep = _currentStep ;
|
|
|
stepper->setCurrentPosition(_currentStep);
|
|
|
+ break;
|
|
|
// stepper->moveTo(_targetStep);
|
|
|
// push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
|
|
|
// push( connectors, ON_STOP, 0, 1, 0 );
|
|
|
}
|
|
|
- stepper_update();
|
|
|
+ // stepper_update();
|
|
|
// push(connectors, ON_CHANGEPOSITION, 0, _currentStep, stepper->speed());
|
|
|
return;
|
|
|
|
|
|
case LP_STOP:
|
|
|
+
|
|
|
+ if(_currentSpeed == 0.) {trigger(EVT_ENABLE);break;}
|
|
|
stepper_update();
|
|
|
- if(_currentSpeed == 0.) {trigger(EVT_ENABLE);}
|
|
|
return;
|
|
|
|
|
|
case ENT_HOMING_LOW:
|
|
@@ -466,6 +470,7 @@ Atm_AccelStepper& Atm_AccelStepper::move( long int stepRel) {
|
|
|
_targetStep = _currentStep + stepRel;
|
|
|
runMode = 0;
|
|
|
stepper->moveTo(_targetStep);
|
|
|
+ _currentSpeed = stepper->speed();
|
|
|
enable();
|
|
|
trigger( EVT_MOVE );
|
|
|
return *this;
|
|
@@ -475,6 +480,7 @@ Atm_AccelStepper& Atm_AccelStepper::moveTo( long int stepAbs) {
|
|
|
_targetStep = stepAbs;
|
|
|
runMode = 0;
|
|
|
stepper->moveTo(_targetStep);
|
|
|
+ _currentSpeed = stepper->speed();
|
|
|
enable();
|
|
|
trigger( EVT_MOVE );
|
|
|
return *this;
|
|
@@ -485,6 +491,7 @@ Atm_AccelStepper& Atm_AccelStepper::movePercent( float percent) {
|
|
|
runMode = 0;
|
|
|
// Serial.println(_targetStep);
|
|
|
stepper->moveTo(_targetStep);
|
|
|
+ _currentSpeed = stepper->speed();
|
|
|
enable();
|
|
|
trigger( EVT_MOVE );
|
|
|
return *this;
|
|
@@ -494,6 +501,7 @@ Atm_AccelStepper& Atm_AccelStepper::moveToPercent( float percent) {
|
|
|
_targetStep = (float) percent/100*float(_maxStep) ;
|
|
|
runMode = 0;
|
|
|
stepper->moveTo(_targetStep);
|
|
|
+ _currentSpeed = stepper->speed();
|
|
|
enable();
|
|
|
trigger( EVT_MOVE );
|
|
|
return *this;
|