Vanmorgen aan gewerkt

Dependencies:   FastPWM HIDScope MODSERIAL QEI biquadFilter mbed

Fork of Project_BioRobotics by Jordi Luong

Revision:
1:1221419474b3
Parent:
0:80ac024b84cb
Child:
2:d3687b2c4e37
--- a/main.cpp	Mon Sep 25 10:12:20 2017 +0000
+++ b/main.cpp	Mon Sep 25 14:29:28 2017 +0000
@@ -1,3 +1,4 @@
+// TEST VERSION
 #include "BiQuad.h"
 #include "FastPWM.h"
 #include "HIDScope.h"
@@ -15,44 +16,48 @@
 bool stateChanged = true;                                                       // Make sure the initialization of first state is executed
 
 // DEFINITIONS
+InterruptIn homeButton(SW2);                                                    // Button to go to home state
+InterruptIn hitButton(SW3);                                                     // Button to go to hit state
 
+float voltage;
 
 // FUNCTIONS
 // Turn motors off
 void TurnMotorsOff()
 {
-    // Turn motors off
+    pc.printf("Turning motors off \r\n");                                       // Turn motors off
 }
 
 // Move to home
 void MoveToHome()
 {
-    // Move to home
+    pc.printf("Moving to home \r\n");                                           // Move to home
 }
 
 // Filter signals
-float FilterSignal(// Signal)
+float FilterSignal(float signal)
 {
-    // Filter signal
-    return // Voltage
+    pc.printf("Filtering signal \r\n");                                         // Filter signal
+    voltage = signal;
+    return voltage;
 }
 
 // Motor 1
-void RotateMotor1(// Voltage)
+void RotateMotor1(float voltage)
 {
-    // Rotate motor 1
+    pc.printf("Rotating motor 1 \r\n");                                         // Rotate motor 1
 }
 
 // Motor 2
-void RotateMotor2(// Voltage)
+void RotateMotor2(float voltage)
 {
-    // Rotate motor 2
+    pc.printf("Rotating motor 2 \r\n");                                         // Rotate motor 2
 }
 
 // Hit the ball
 void HitBall()
 {
-    // Rotate motor 3
+    pc.printf("Hitting the ball \r\n");                                         // Rotate motor 3
 }
 
 // States function
@@ -71,7 +76,7 @@
             }
             
             // Home command
-            if(//HOME COMMAND)
+            if(!homeButton)
             {
                 currentState = HOMING;
                 stateChanged = true;
@@ -103,21 +108,23 @@
             }
             
             // EMG signals to rotate motor 1
-            if(// EMG signal)
+            if(false)
             {
-                FilterSignal(// Signal);                                        // Filter the signal
-                RotateMotor1(// Voltage);                                       // Rotate motor 1
+                FilterSignal(1);                                                // Filter the signal
+                RotateMotor1(voltage);                                          // Rotate motor 1
+                pc.printf("%f \r\n", voltage);
             }
             
             // EMG signals to rotate motor 2
-            if(// EMG signal)
+            if(false)
             {
-                FilterSignal(// Signal);                                        // Filter the signal
-                RotateMotor2(// Voltage);                                       // Rotate motor 2
+                FilterSignal(2);                                                // Filter the signal
+                RotateMotor2(voltage);                                          // Rotate motor 2
+                pc.printf("%f \r\n", voltage);
             }
             
             // Hit command    
-            if(// HIT COMMAND)
+            if(!hitButton)
             {
                 currentState = HITTING;
                 stateChanged = true;