20180223FINAL

Dependencies:   BLE_API X_NUCLEO_IDB0XA1 X_NUCLEO_IHM02A1 mbed

Fork of Motor_Ble_v10223 by NEHSROBOT

Revision:
12:407779f755d0
Parent:
11:6deabd374c96
--- a/main.cpp	Fri Feb 23 08:12:54 2018 +0000
+++ b/main.cpp	Fri Feb 23 08:52:13 2018 +0000
@@ -116,7 +116,7 @@
 
 
 /* Motor Control Expansion Board. */
-XNucleoIHM02A1* x_nucleo_ihm02a1 = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, D10, &dev_spi);
+XNucleoIHM02A1* x_nucleo_ihm02a1 = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, A2, &dev_spi);
 
 DigitalOut actuatedLED(LED2);
 const static char     DEVICE_NAME[] = "mydevice";    //   CHANGE NAME
@@ -146,40 +146,27 @@
         }
         else if (*(params->data)== 0x42)  
         { 
-            actuatedLED=0      ;
-            //SOFTSTOP();
+            actuatedLED=1      ;
+            BWD();
 
         }
         else if (*(params->data)== 0x43)  
         { 
             actuatedLED=1      ;
-            //FWD();
-
+            RIGHT();
 
         }
         else if (*(params->data)== 0x44)  
         { 
-            actuatedLED=0      ;
-            wait(0.1)          ;
-            BWD();
-        }
-        else if (*(params->data)== 0x01)  
-        { 
-            actuatedLED=1      ;
-            FWD();
-        }
-        else if (*(params->data)== 0x02)  {
-            actuatedLED=1      ;
-            BWD();
-        }
-        else if (*(params->data)== 0x03)  {
-            actuatedLED=1      ;
-            RIGHT();
-        }
-        else if (*(params->data)== 0x04)  {
             actuatedLED=1      ;
             LEFT();
         }
+        else if (*(params->data)== 0x45)  
+        { 
+            actuatedLED=0      ;
+            SOFTSTOP();
+        }
+
            
    
     }
@@ -274,9 +261,9 @@
     /* Getting the current position. */
 //  int position = motors[0]->get_position();
 
-        /* Preparing each motor to perform a run at a specified speed. */
+    /* Preparing each motor to perform a run at a specified speed. */
     for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
-        motors[m]->prepare_move(StepperMotor::BWD, 25600);
+        motors[m]->prepare_run(StepperMotor::BWD, 400);
     }
 
     /* Performing the action on each motor at the same time. */
@@ -297,8 +284,8 @@
  // int position = motors[0]->get_position();
 
         /* Preparing each motor to perform a run at a specified speed. */
-    motors[0]->prepare_move(StepperMotor::FWD, 25600);
-    motors[1]->prepare_move(StepperMotor::BWD, 25600);
+    motors[0]->prepare_run(StepperMotor::FWD, 400);
+    motors[1]->prepare_run(StepperMotor::BWD, 400);
 
     /* Performing the action on each motor at the same time. */
     x_nucleo_ihm02a1->perform_prepared_actions();
@@ -318,8 +305,8 @@
 //  int position = motors[0]->get_position();
 
         /* Preparing each motor to perform a run at a specified speed. */
-    motors[1]->prepare_move(StepperMotor::FWD, 25600);
-    motors[0]->prepare_move(StepperMotor::BWD, 25600);
+    motors[0]->prepare_run(StepperMotor::BWD, 400);
+    motors[1]->prepare_run(StepperMotor::FWD, 400);
 
     /* Performing the action on each motor at the same time. */
     x_nucleo_ihm02a1->perform_prepared_actions();