Testing 1 blue pill

Dependencies:   mbed mbed-rtos TextLCD

Revision:
29:f3b1387c81f1
Parent:
28:3193157ebb0c
Child:
30:a35f0ab97a65
--- a/Stepper_Motor/STEPPER_MOTOR.cpp	Mon Mar 11 14:19:26 2019 +0000
+++ b/Stepper_Motor/STEPPER_MOTOR.cpp	Wed Mar 13 11:34:39 2019 +0000
@@ -22,7 +22,7 @@
 {
     return (_Steps_Done /50);
 }
-void STEPPER_MOTOR::Rotate_Steps(int Steps,int Function)
+void STEPPER_MOTOR::Rotate_Steps(int Steps,int Function,bool Direction)
 {   
     if(Function == 2)//Coiling
     {
@@ -32,35 +32,58 @@
     {
         loop_wait_time = 2;//Twisting
     } 
-    Steps = Steps*50;
-    //int correctionfactor;
-    //int timeofturn=correctinfactor*speed;
+    Steps = Steps*50;//int correctionfactor;//int timeofturn=correctinfactor*speed;
     _Steps_Done = 0;
-    //int mystep=0;
-    //printf("START!!! step value is=%d\n\r",mystep);
+
     for(int x =0 ; x <= Steps; x++)
     {
         if(_Pause_Code == 0)
         {
-            this->pin1 = 0;
-            this->pin2 = 1;
-            this->pin3 = 0;
-            this->pin4 = 1;
-            Thread::wait(loop_wait_time);
-            this->pin1 = 0;
-            this->pin2 = 1;
-            this->pin3 = 1;
-            this->pin4 = 0; 
-            Thread::wait(loop_wait_time);
-            this->pin1 = 1;
-            this->pin2 = 0;
-            this->pin3 = 1;
-            this->pin4 = 0;
-            Thread::wait(loop_wait_time);
-            this->pin1 = 1;
-            this->pin2 = 0;
-            this->pin3 = 0;
-            this->pin4 = 1;     
+            if(Direction == 0)
+            {
+                this->pin1 = 0;
+                this->pin2 = 1;
+                this->pin3 = 0;
+                this->pin4 = 1;
+                Thread::wait(loop_wait_time);
+                this->pin1 = 0;
+                this->pin2 = 1;
+                this->pin3 = 1;
+                this->pin4 = 0; 
+                Thread::wait(loop_wait_time);
+                this->pin1 = 1;
+                this->pin2 = 0;
+                this->pin3 = 1;
+                this->pin4 = 0;
+                Thread::wait(loop_wait_time);
+                this->pin1 = 1;
+                this->pin2 = 0;
+                this->pin3 = 0;
+                this->pin4 = 1;
+            }
+            else if (Direction == 1)   
+            {   
+                this->pin1 = 1;
+                this->pin2 = 0;
+                this->pin3 = 0;
+                this->pin4 = 1;
+                Thread::wait(loop_wait_time);
+                this->pin1 = 1;
+                this->pin2 = 0;
+                this->pin3 = 1;
+                this->pin4 = 0;
+                Thread::wait(loop_wait_time);
+                this->pin1 = 0;
+                this->pin2 = 1;
+                this->pin3 = 1;
+                this->pin4 = 0;
+                Thread::wait(loop_wait_time); 
+                this->pin1 = 0;
+                this->pin2 = 1;
+                this->pin3 = 0;
+                this->pin4 = 1;
+                Thread::wait(loop_wait_time);             
+            }  
             Thread::wait(loop_wait_time);  
             _Steps_Done = _Steps_Done +1;
         }