Tummas Tomasson / Mbed 2 deprecated PingDetector_mbedadc

Dependencies:   mbed

PingDetect/FFT.h

Committer:
tummastt
Date:
2012-07-30
Revision:
0:efb27fbc92c0
Child:
1:227db871d328

File content as of revision 0:efb27fbc92c0:

/*  

    
 */
 
#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