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.
Dependencies: mbed-dsp
Fork of mbed-os-example-blinky by
main.cpp
- Committer:
- deeza
- Date:
- 2017-04-05
- Revision:
- 52:d5c59769e1de
- Parent:
- 51:837137ab83ed
- Child:
- 53:3187ccbe0cca
File content as of revision 52:d5c59769e1de:
#include "mbed.h" #include "complex.h" #include "fft.h" Serial pc(USBTX, USBRX); DigitalOut led1(LED1); // State machine int STATE; //const int NONE = -1; const int IDLE = 0; const int LISTEN = 1; const int CALC = 2; const int SEND = 3; const int CALC_ERROR = 4; //const int WAIT = 9; // main() runs in its own thread in the OS int main() { /* STATE = IDLE; while (true) { switch (STATE) { case IDLE: //code here STATE = LISTEN; //next state break; case LISTEN: //code here break; case CALC: //code here break; case CALC_ERROR: //code here break; case SEND: // code here break; } }*/ //testar complexa tal addering, verkar funka. complex c1 = complex(1,2); complex c2 = complex(2,3); complex c3 = c1 + c2; pc.printf("hello \n"); //...Inside your signal processing function // Allocate memory for signal data complex *pSignal_1 = new complex[1024]; complex *pSignal_2 = new complex[1024]; //...Fill signal array with data // Apply FFT CFFT::Forward(pSignal_1, 1024); CFFT::Forward(pSignal_2, 1024); //...Utilize transform result complex *corrSignal = new complex[1024]; startCorr = corrSignal; for( i=0; i<1024; i++){ *corrSignal = (*pSignal_1) * (*pSignal_2); corrSignal++; pSignal_1++; pSignal_2++; } int counter = 0; int maxPos = 0; //delay i form av antal sample complex maxValue = (0,0); for(i=0; i<1024; i++){ if (*corrSignal > abs(maxValue) ){ maxValue = *corrSignal; maxPos = counter; } counter++; corrSignal++; } // Free memory delete[] pSignal; } //Calculating distanse between sound and camera double calcDis(double t, double v){ double s = t*v; return s; } //Calculating angle in radians, D distanse between mic1 and mic2 double calcAng(double s, double D){ double ang = asin(s/D); return ang; } //Presuming the input value is temp as a nuber and humidity as procent double speedofsound(double temp, double hum){ //Calculations done in Matlab double speed = 331.1190 + 0.6016*temp + 0.0126*hum; return speed; }