Craig Evans / Mbed 2 deprecated AudioIn

Dependencies:   N5110 mbed

Files at this revision

API Documentation at this revision

Comitter:
eencae
Date:
Thu Jul 24 15:25:26 2014 +0000
Parent:
2:8da22b498051
Commit message:
Simple code which samples audio on ADC, calculates FFT and displays spectrum on LCD display.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Jul 22 17:52:59 2014 +0000
+++ b/main.cpp	Thu Jul 24 15:25:26 2014 +0000
@@ -25,7 +25,7 @@
 PwmOut blue(p25);
 
 #define BUF_LEN 1024
-#define SAMP_FREQ 30000
+#define SAMP_FREQ 10000
 
 short samples[BUF_LEN];  // store the values read from ADC
 short mx[BUF_LEN*2]; // input data 16 bit, 4 byte aligned  x0r,x0i,x1r,x1i,....
@@ -34,6 +34,8 @@
 
 char buffer[14];  // screen buffer
 
+int tone;
+
 int main()
 {
     // initialise LCD and display welcomes message
@@ -63,9 +65,7 @@
         rgbDance();
         //printSpectrum();
         //printSamples();
-        //int tone = calcPeakFrequency();  // calculate peak frequcny and send over serial for debug
-        //serial.printf("f = %u\n",tone);
-
+        tone = calcPeakFrequency();  // calculate peak frequcny and send over serial for debug
         wait_ms(10);  // update display 100 ms
 
     }
@@ -203,6 +203,9 @@
             lcd.setPixel(i,j);  // draw bar graphs for spectrum bins
         }
     }
+    
+    sprintf(buffer,"%4u Hz",tone);
+    lcd.printString(buffer,40,0); 
     lcd.refresh();
 
 }