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.
Revision 3:0df6485bc3ec, committed 2014-07-24
- 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(); }