chalala
Dependencies: FastAnalogIn NVIC_set_all_priorities mbed-dsp mbed
Fork of ProyFinal by
Diff: main.cpp
- Revision:
- 1:7655383ca5fd
- Parent:
- 0:2ccf3099b859
- Child:
- 2:6f99f6b825b8
diff -r 2ccf3099b859 -r 7655383ca5fd main.cpp --- a/main.cpp Tue Dec 01 01:08:58 2015 +0000 +++ b/main.cpp Wed Dec 02 20:14:40 2015 +0000 @@ -6,6 +6,12 @@ #include "FastAnalogIn.h" #include <string> +//Enrique García Sandoval A01224184 +//Emmanuel Gonzalez Palacios A01228185 + +// Basado en el código de Frank Vannieuwkerke en KL25Z_FFT_Demo +// https://developer.mbed.org/users/frankvnk/code/KL25Z_FFT_Demo/ + PwmOut myled(LED_GREEN); Serial pc(USBTX, USBRX); FastAnalogIn Audio(PTC0); @@ -14,7 +20,7 @@ int SAMPLE_RATE_HZ = 4000; const int FFT_SIZE = 256; -////Otras Variables//// +////Otras Variables para sampling y FFT//// const static arm_cfft_instance_f32 *S; Ticker samplingTimer; float samples[FFT_SIZE*2]; @@ -23,7 +29,7 @@ //*********// ////Utilidades//// -void printArr(int bigsize, float arr[]){ +void printArr(int bigsize, float arr[]){ //Imprime un arreglo de valores int size = (bigsize/sizeof(arr[0])); pc.printf("\r\n ["); int limit = size - 1; @@ -70,7 +76,7 @@ //**********// -//Funciones para DTMF// +//Funciones para detección de DTMF// int col1 = frequencyToBin(1209); int col2 = frequencyToBin(1336); int col3 = frequencyToBin(1477); @@ -83,7 +89,7 @@ string valC3[] = {"3", "6", "9", "#"}; -int maxCol(){ +int maxCol(){ //Magnitud máxima en una columna int col = 0; float max = 0.0; if (magnitudes[col1] > max){ @@ -100,7 +106,7 @@ return col; } -int maxRow(){ +int maxRow(){ //Magnitud máxima en una fila int row = 0; float max = 0.0; if (magnitudes[row1] > max){ @@ -121,11 +127,11 @@ return row; } -string valor(){ +string valor(){ //Determina qué tecla se presiona int R = maxRow() - 1; int C = maxCol(); //pc.printf("Las coordenadas son: %i, %i \n", R, C); //debug - string salida = "no"; + string salida = "---"; switch (C){ case 1: salida = valC1[R]; @@ -142,12 +148,10 @@ //**********// int main(){ - myled = 0.999; + myled = 0.995; NVIC_set_all_irq_priorities(1); NVIC_SetPriority(UART0_IRQn, 0); - // Set up serial port. - pc.baud (9600); // Begin sampling audio samplingBegin(); @@ -193,8 +197,8 @@ arm_cmplx_mag_f32(samples, magnitudes, FFT_SIZE); // Restart audio sampling. samplingBegin(); + //Correr identificacion de tonos - printf(valor().c_str()); printf("\r\n"); }