Tummas Tomasson / Mbed 2 deprecated PingDetector_mbedadc

Dependencies:   mbed

Revision:
1:227db871d328
Parent:
0:efb27fbc92c0
--- a/main.cpp	Mon Jul 30 09:57:42 2012 +0000
+++ b/main.cpp	Tue Aug 21 14:23:03 2012 +0000
@@ -1,9 +1,6 @@
 /*
-    D- (Orange) is pin5 on AUX
-    D+ (Yellow) is pin8 on AUX
-    GND is pin 1 on AUX
-    +12V is pin 3 on AUX
-
+    Program to detect a pinger signal and send
+    it back to the PC for processing
  */
 
 #include "mbed.h"
@@ -38,7 +35,6 @@
 
     while (1) {
 
-//        PD.SendSerial(Command);
         //
         switch (Command) {
             case start:
@@ -63,6 +59,7 @@
     }
 }
 
+// Stops all functions.
 void Stop() {
     t.detach();
     l2=0;
@@ -71,32 +68,38 @@
     Command = doNothing;
 }
 
+// sets the find function to run every 5ms
 void Start() {
     l2=1;
     t.detach();
-//    t.attach_us(&Find,10000);
     t.attach_us(&Find,5000);
     Command = doNothing;
 }
 
+// Calculates the FFT and sends to the PC 100 times
 void CalculateFFT() {
     t.detach();
     PD.CalculateFFT();    
     Command = doNothing;
 }
 
+// The run function samples the data from the filters
+// and sends to it to the PC
 void Run () {
+    l4=0;
     l3=!l3;
     PD.Run();
 }
 
+// Run the find function, if the signal is is found,
+// it sets the run function to run every second and 
+// ensures the detected signal is in the centre of
+// the sampling window
 void Find() {
-    l4=!l4;
+    l4=1;
     Found = PD.Search();
     if(Found == found){
-        l2=0;
         t.detach();
-//        wait_ms(1000-TIME_OFFSET);
         wait_ms(1000-TIME_OFFSET);
         t.attach(&Run,1);
         Run();