Update

Dependencies:   mbed mbed-rtos X_NUCLEO_IHM02A1

Revision:
39:6cc9a40bc8a6
Parent:
37:a74d377d8f74
Child:
40:117b324843ee
--- a/STEPPER.cpp	Mon May 13 10:11:48 2019 +0000
+++ b/STEPPER.cpp	Tue May 14 08:05:58 2019 +0000
@@ -9,22 +9,22 @@
 /* -------------------------- Leerlauf -------------------------------------- */
 void Stepper_1_Leerlauf()
 {
-    motors[0]->hard_hiz(); 
-    motors[0]->wait_while_active(); 
+    motors[0]->hard_hiz();
+    motors[0]->wait_while_active();
 }
 void Stepper_2_Leerlauf()
 {
-    motors[1]->hard_hiz();  
+    motors[1]->hard_hiz();
     motors[1]->wait_while_active();
 }
 void Stepper_3_Leerlauf()
 {
-    motors2[0]->hard_hiz();  
+    motors2[0]->hard_hiz();
     motors2[0]->wait_while_active();
 }
 void Stepper_4_Leerlauf()
 {
-    motors2[1]->hard_hiz();  
+    motors2[1]->hard_hiz();
     motors2[1]->wait_while_active();
 }
 /* ---------------------------- END ----------------------------------------- */
@@ -34,23 +34,23 @@
 /* --------------------------- Stop ----------------------------------------- */
 void Stepper_1_Stop()
 {
-    motors[0]->hard_stop(); 
-    motors[0]->wait_while_active(); 
+    motors[0]->hard_stop();
+    motors[0]->wait_while_active();
 }
 void Stepper_2_Stop()
 {
-    motors[1]->hard_stop(); 
-    motors[1]->wait_while_active(); 
+    motors[1]->hard_stop();
+    motors[1]->wait_while_active();
 }
 void Stepper_3_Stop()
 {
-    motors2[0]->hard_stop(); 
-    motors2[0]->wait_while_active(); 
+    motors2[0]->hard_stop();
+    motors2[0]->wait_while_active();
 }
 void Stepper_4_Stop()
 {
-    motors2[1]->hard_stop(); 
-    motors2[1]->wait_while_active(); 
+    motors2[1]->hard_stop();
+    motors2[1]->wait_while_active();
 }
 /* ---------------------------- END ----------------------------------------- */
 
@@ -228,53 +228,41 @@
 /* --------------------------------- MOVE ----------------------------------- */
 void Stepper_1_Move(char direction, unsigned int steps)
 {
-    if( direction == 'V')
-    {
+    if( direction == 'V') {
         motors[0]->move(StepperMotor::FWD, 128*steps);
         motors[0]->wait_while_active();
-    }
-    else if ( direction == 'R')
-    {
+    } else if ( direction == 'R') {
         motors[0]->move(StepperMotor::BWD, 128*steps);
         motors[0]->wait_while_active();
     }
-    
+
 }
 void Stepper_2_Move(char direction, unsigned int steps)
 {
-    if( direction == 'V')
-    {
+    if( direction == 'V') {
         motors[1]->move(StepperMotor::FWD, 128*steps);
         motors[1]->wait_while_active();
-    }
-    else if ( direction == 'R')
-    {
+    } else if ( direction == 'R') {
         motors[1]->move(StepperMotor::BWD, 128*steps);
         motors[1]->wait_while_active();
     }
 }
 void Stepper_3_Move(char direction, unsigned int steps)
 {
-    if( direction == 'V')
-    {
+    if( direction == 'V') {
         motors2[0]->move(StepperMotor::FWD, 128*steps);
         motors2[0]->wait_while_active();
-    }
-    else if ( direction == 'R')
-    {
+    } else if ( direction == 'R') {
         motors2[0]->move(StepperMotor::BWD, 128*steps);
         motors2[0]->wait_while_active();
     }
 }
 void Stepper_4_Move(char direction, unsigned int steps)
 {
-    if( direction == 'V')
-    {
+    if( direction == 'V') {
         motors2[1]->move(StepperMotor::FWD, 128*steps);
         motors2[1]->wait_while_active();
-    }
-    else if ( direction == 'R')
-    {
+    } else if ( direction == 'R') {
         motors2[1]->move(StepperMotor::BWD, 128*steps);
         motors2[1]->wait_while_active();
     }
@@ -286,55 +274,69 @@
 /* --------------------------------- RUN ------------------------------------ */
 void Stepper_1_Run(char direction, unsigned int speed)
 {
-    if( direction == 'V')
-    {
+    if( direction == 'V') {
         motors[0]->run(StepperMotor::FWD, speed);
         motors[0]->wait_while_active();
-    }
-    else if ( direction == 'R')
-    {
+    } else if ( direction == 'R') {
         motors[0]->run(StepperMotor::BWD, speed);
         motors[0]->wait_while_active();
     }
-    
+
 }
 void Stepper_2_Run(char direction, unsigned int speed)
 {
-    if( direction == 'V')
-    {
+    if( direction == 'V') {
         motors[1]->run(StepperMotor::FWD, speed);
         motors[1]->wait_while_active();
-    }
-    else if ( direction == 'R')
-    {
+    } else if ( direction == 'R') {
         motors[1]->run(StepperMotor::BWD, speed);
         motors[1]->wait_while_active();
     }
 }
 void Stepper_3_Run(char direction, unsigned int speed)
 {
-    if( direction == 'V')
-    {
+    if( direction == 'V') {
         motors2[0]->run(StepperMotor::FWD, speed);
         motors2[0]->wait_while_active();
-    }
-    else if ( direction == 'R')
-    {
+    } else if ( direction == 'R') {
         motors2[0]->run(StepperMotor::BWD, speed);
         motors2[0]->wait_while_active();
     }
 }
 void Stepper_4_Run(char direction, unsigned int speed)
 {
-    if( direction == 'V')
-    {
+    if( direction == 'V') {
         motors2[1]->run(StepperMotor::FWD, speed);
         motors2[1]->wait_while_active();
-    }
-    else if ( direction == 'R')
-    {
+    } else if ( direction == 'R') {
         motors2[1]->run(StepperMotor::BWD, speed);
         motors2[1]->wait_while_active();
     }
 }
+/* ---------------------------- END ----------------------------------------- */
+
+
+
+
+/* ------------------------- SET_SPEED_AC ----------------------------------- */
+void Stepper_1_SetPara(int speed, int acc)
+{
+    motors[0]->set_max_speed(speed);
+    motors[0]->set_acceleration(acc);
+}
+void Stepper_2_SetPara(int speed, int acc)
+{
+    motors[1]->set_max_speed(speed);
+    motors[1]->set_acceleration(acc);
+}
+void Stepper_3_SetPara(int speed, int acc)
+{
+    motors2[0]->set_max_speed(speed);
+    motors2[0]->set_acceleration(acc);
+}
+void Stepper_4_SetPara(int speed, int acc)
+{
+    motors2[1]->set_max_speed(speed);
+    motors2[1]->set_acceleration(acc);
+}
 /* ---------------------------- END ----------------------------------------- */
\ No newline at end of file