Quellcode durchsuchen

stepper settings functions

setmaxspeed, homing speed and acceleration
position refresh rate
titi vor 5 Jahren
Ursprung
Commit
0794287c49
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. 5 1
      Atm_AccelStepper.cpp

+ 5 - 1
Atm_AccelStepper.cpp

@@ -112,6 +112,8 @@ void Atm_AccelStepper::action( int id ) {
       push(connectors, ON_CHANGESTATE, 0,  state(), 0);
       enabled = _enableReversed ? LOW : HIGH ;
       digitalWrite(_enablePin, enabled);
+      if(last_trigger == EVT_ON_TARGET){push( connectors, ON_ONTARGET, 0, stepper->currentPosition(), 0 );};
+
       return;
     case ENT_RUNNING:
       push(connectors, ON_CHANGESTATE, 0,  state(), 0);
@@ -224,12 +226,13 @@ void Atm_AccelStepper::stepper_update(void) {
     if (position_timer.expired(this)){
       push(connectors, ON_CHANGEPOSITION, 0,  _currentStep, stepper->speed());
       position_timer.setFromNow(this, POSITION_SEND_TIMER);
-    };
+    }
   }
 }
 
 Atm_AccelStepper& Atm_AccelStepper::setMaxSpeed( long int maxSpeed){
   max_speed = maxSpeed ;
+  stepper->setMaxSpeed(max_speed);
   return *this ;
 }
 
@@ -240,6 +243,7 @@ Atm_AccelStepper& Atm_AccelStepper::setHomingSpeed(long int homingSpeed){
 
 Atm_AccelStepper& Atm_AccelStepper::setAcceleration(long int acc){
   acceleration = acc ;
+  stepper->setAcceleration(max_speed);
   return *this ;
 }