Funcional
Dependencies: FastAnalogIn HSI2RGBW_PWM NVIC_set_all_priorities mbed-dsp mbed TextLCD
Fork of Seniales-Tacometro by
Diff: main.cpp
- Revision:
- 1:736b34e0f484
- Parent:
- 0:0c037aff5039
- Child:
- 2:035d551759a5
--- a/main.cpp Tue Feb 25 17:42:59 2014 +0000 +++ b/main.cpp Sat Mar 08 18:56:14 2014 +0000 @@ -7,11 +7,11 @@ #include <ctype.h> #include "arm_math.h" #include "hsi2rgbw_pwm.h" +#include "FastAnalogIn.h" Serial pc(USBTX, USBRX); -AnalogIn left(PTC2); -AnalogIn right(PTB3); +FastAnalogIn Audio(PTC2); //#define RGBW_ext // Disable this line when you want to use the KL25Z on-board RGB LED. @@ -44,17 +44,17 @@ // Max allowed FFT_SIZE is 16 //////////////////////////////////////////////////////////////////////////////// -int SLOWDOWN = 16; // Create an optical delay in spectrumLoop - useful when only one RGB led is used. +int SLOWDOWN = 3; // Create an optical delay in spectrumLoop - useful when only one RGB led is used. // Only active when nonzero. // A value >= 1000 and <= 1000 + PIXEL_COUNT fixes the output to a single frequency // window = a single color. int SAMPLE_RATE_HZ = 40000; // Sample rate of the audio in hertz. -float SPECTRUM_MIN_DB = 30.0; // Audio intensity (in decibels) that maps to low LED brightness. -float SPECTRUM_MAX_DB = 60.0; // Audio intensity (in decibels) that maps to high LED brightness. +float SPECTRUM_MIN_DB = 40.0; // Audio intensity (in decibels) that maps to low LED brightness. +float SPECTRUM_MAX_DB = 80.0; // Audio intensity (in decibels) that maps to high LED brightness. int LEDS_ENABLED = 1; // Control if the LED's should display the spectrum or not. 1 is true, 0 is false. // Useful for turning the LED display on and off with commands from the serial port. -const int FFT_SIZE = 16; // Size of the FFT. -const int PIXEL_COUNT = 8; // Number of pixels. You should be able to increase this without +const int FFT_SIZE = 64; // Size of the FFT. +const int PIXEL_COUNT = 32; // Number of pixels. You should be able to increase this without // any other changes to the program. const int MAX_CHARS = 65; // Max size of the input command buffer @@ -192,7 +192,7 @@ void samplingCallback() { // Read from the ADC and store the sample data - samples[sampleCounter] = 1023 * ((left + right)/2); + samples[sampleCounter] = (1023 * Audio) - 511.0f; // Complex FFT functions require a coefficient for the imaginary part of the input. // Since we only have real data, set this coefficient to zero. samples[sampleCounter+1] = 0.0;