Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: PingDetect/FFT.h
- Revision:
- 0:efb27fbc92c0
- Child:
- 1:227db871d328
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PingDetect/FFT.h	Mon Jul 30 09:57:42 2012 +0000
@@ -0,0 +1,45 @@
+/*  
+
+    
+ */
+ 
+#ifndef FFT_H
+#define FFT_H
+
+#include "mbed.h"
+#include "../Parameters.h"
+
+class FFT {
+public:
+    FFT () {
+        float temp = float(FREQ)*SAMPLES/SAMPLE_RATE;
+        if (fmod(temp,1)<0.5)
+            centerFreq = 2+floor(temp)*2; 
+        else
+            centerFreq = 2+ceil(temp)*2;
+    }
+    
+    int DetectSignal(short data[]);
+    /*  Used to detect if the pinger signal is present
+            returns found if signal is detected
+            retruns notFound if no signal is detected
+        Parameters defined in Parameters.h
+            FREQ is the frequency in kHz of the pinger signal
+            AMPLITUDE_LIMIT is what the signal amplitude has to be 
+            to be considered found. It used the amplitude sum of
+            +-0.3kHz. E.g. if FREQ 10k AMP = AMP_9.7k+AMP_10k+AMP_10.3k
+    */
+
+    void CalculateFFT(short data[]);
+    
+    
+    short my[SAMPLES*2]; // output data 16 bit,4 byte aligned  y0r,y0i,y1r,y1i,....
+    
+private:
+    short mx[SAMPLES*2]; // input data 16 bit, 4 byte aligned  x0r,x0i,x1r,x1i,....
+    int amp;
+    int centerFreq;
+    int i;
+};
+
+#endif
\ No newline at end of file