eLab Team / Mbed 2 deprecated LaLaBox

Dependencies:   mbed CREALIB

Revision:
4:d452a7e3461a
Parent:
3:50e030d90648
Child:
5:f62e799558c3
diff -r 50e030d90648 -r d452a7e3461a main.cpp
--- a/main.cpp	Fri Jun 17 11:45:23 2016 +0000
+++ b/main.cpp	Fri Jun 17 14:58:17 2016 +0000
@@ -13,7 +13,7 @@
 DigitalOut myled(LED1);     // Blinking LED
 
 // --- Define the Foor PINs used for Motor drive -----
-Motor motorBox(PA_9, PC_7, PB_6, PA_7)
+Motor motorBox(PA_9, PC_7, PB_6, PA_7);
 // Motor motorDancer(PA_9, PC_7, PB_6, PA_7)
 
 // --- Define PC_8 as the output of PWM use for Tones -----
@@ -47,7 +47,7 @@
     myled = 1;      // To see something is alive
     DEBUG("\n\n\r");
     DEBUG("------------------------------------------\n\r"); 
-    DEBUG("----- Wire WINDER (fbd38) version 1.0 ----\n\r");
+    DEBUG("----- LaLaBox (fbd38)     version 1.0 ----\n\r");
     DEBUG("------------------------------------------\n\r"); 
     help();
     DEBUG("------------------------------------------\n\r"); 
@@ -56,32 +56,29 @@
      //
     while(1) {
         char command;   // Command to execute
-        uint32_t TimeToRunSec, TimeToRunMin;
-        DEBUG(">> ");
+         DEBUG(">> ");
         command = pc_uart.getc();
         DEBUG("%c", command);
         switch (command) {
         case 'h': help(); break;
-        case 'z': MotorCommand = k_zero; break;
-        case 'k': TestMotor(); break;
+        case 'z': motorBox.SetCommand(MOTOR_zero); break;
+        case 'k': motorBox.TestMotor(); break;
         case 'n':
             pc_uart.scanf("%d", &NumberOfTurns);
-            MotorBox->TurnMotor(NumberOfTurns);
+            motorBox.TurnMotor(NumberOfTurns);
            break;
-        case 'c': MotorDir = d_clock; break;
-        case 'a': MotorDir = d_anti;  break;
-        case 'm': DEBUG(" [ not ready yet ]\n\r"); break;
-        case 'l': DEBUG(" [ not ready yet ]\n\r"); break;
-        case 'w': DEBUG(" -- Starting --\n\r"); MotorCommand = k_wire;    break;
-        case 'p': DEBUG(" -- Pause    --\n\r"); MotorCommand = k_pause;   break;
-        case 'r': DEBUG(" -- Re-Start --\n\r"); MotorCommand = k_restart; break;
-        case 's': DEBUG(" -- Stop     --\n\r"); MotorCommand = k_stop;    break;
-        case ' ': 
-            TimeToRunSec = (NumSteps * (MotorStepTime / 1000))/1000;
-            TimeToRunMin = TimeToRunSec / 60;
-            TimeToRunSec %= 60;
-            DEBUG(" Step to run: %d; Time %d,%2d (min, sec)\n\r", NumSteps, TimeToRunMin, TimeToRunSec); 
+        case 'c': 
+            DEBUG(" -- Direction CLOCKWISE --\n\r");
+            motorBox.SetDirection(DIRECTION_CLOCKWISE); 
             break;
+        case 'a': 
+            DEBUG(" -- Direction COUNTER CLOCKWISE --\n\r");
+            motorBox.SetDirection(DIRECTION_COUNTERCLOCKWISE);  
+            break;
+        case 'w': DEBUG(" -- Starting --\n\r"); motorBox.SetCommand(MOTOR_start);    break;
+        case 'p': DEBUG(" -- Pause    --\n\r"); motorBox.SetCommand(MOTOR_pause);   break;
+        case 'r': DEBUG(" -- Re-Start --\n\r"); motorBox.SetCommand(MOTOR_restart); break;
+        case 's': DEBUG(" -- Stop     --\n\r"); motorBox.SetCommand(MOTOR_stop);    break;
         default : DEBUG("invalid command; use: 'h' for help()");
         }
     }