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.cpp
- Revision:
- 0:efb27fbc92c0
- Child:
- 1:227db871d328
diff -r 000000000000 -r efb27fbc92c0 PingDetect/FFT.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PingDetect/FFT.cpp Mon Jul 30 09:57:42 2012 +0000
@@ -0,0 +1,39 @@
+#include "FFT.h"
+
+// Using the Mellen FFT
+extern "C" void fftR4(short *y, short *x, int N);
+
+int FFT::DetectSignal(short data[]) {
+
+ CalculateFFT(data);
+
+ // adding the center frequencies with the 4 closesed frequencies
+// amp = my[centerFreq-2]+my[centerFreq]+my[centerFreq+2];
+ amp = my[centerFreq-2]+my[centerFreq]+my[centerFreq+2];
+// return amp;
+ if (amp >= AMPLITUDE_LIMIT)
+ return found; // indicating pinger signal found
+
+ else
+ return notFound; // indicating no pinger signal found
+
+}
+
+void FFT::CalculateFFT(short data[]) {
+
+ // Clearing array
+ for (i=0; i<SAMPLES*2; i++)
+ mx[i]=0;
+
+ // Add data to array
+ for (i=0; i<SAMPLES; i=i+1)
+ mx[i*2]=data[i]-DCOFFSET;
+
+ // calculate fft
+ fftR4(my, mx, SAMPLES);
+
+ // make all values positive
+ for (i=0; i<SAMPLES; i=i+2) {
+ my[i] = abs(my[i]);
+ }
+}
\ No newline at end of file