Remove redundant definition of costant

pull/8/head
Enrique Condes 2017-04-25 14:22:34 -05:00
rodzic 3c6768bcb2
commit 363dae29f2
1 zmienionych plików z 13 dodań i 15 usunięć

Wyświetl plik

@ -18,14 +18,14 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "arduinoFFT.h" #include "arduinoFFT.h"
arduinoFFT FFT = arduinoFFT(); /* Create FFT object */ arduinoFFT FFT = arduinoFFT(); /* Create FFT object */
/* /*
These values can be changed in order to evaluate the functions These values can be changed in order to evaluate the functions
*/ */
const uint16_t samples = 64; const uint16_t samples = 64;
@ -36,11 +36,11 @@ const double startFrequency = 2;
const double stopFrequency = 16.4; const double stopFrequency = 16.4;
const double step_size = 0.1; const double step_size = 0.1;
/* /*
These are the input and output vectors These are the input and output vectors
Input vectors receive computed results from FFT Input vectors receive computed results from FFT
*/ */
double vReal[samples]; double vReal[samples];
double vImag[samples]; double vImag[samples];
unsigned long time; unsigned long time;
@ -49,8 +49,6 @@ unsigned long time;
#define SCL_TIME 0x01 #define SCL_TIME 0x01
#define SCL_FREQUENCY 0x02 #define SCL_FREQUENCY 0x02
#define Theta 6.2831 //2*Pi
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
@ -58,17 +56,17 @@ void setup()
exponent = FFT.Exponent(samples); exponent = FFT.Exponent(samples);
} }
void loop() void loop()
{ {
Serial.println("Frequency\tDetected\ttakes (ms)"); Serial.println("Frequency\tDetected\ttakes (ms)");
Serial.println("=======================================\n"); Serial.println("=======================================\n");
for(double frequency = startFrequency; frequency<=stopFrequency; frequency+=step_size) for(double frequency = startFrequency; frequency<=stopFrequency; frequency+=step_size)
{ {
/* Build raw data */ /* Build raw data */
double cycles = (((samples-1) * frequency) / sampling); double cycles = (((samples-1) * frequency) / sampling);
for (uint8_t i = 0; i < samples; i++) for (uint8_t i = 0; i < samples; i++)
{ {
vReal[i] = uint8_t((amplitude * (sin((i * (Theta * cycles)) / samples))) / 2.0); vReal[i] = uint8_t((amplitude * (sin((i * (twoPi * cycles)) / samples))) / 2.0);
vImag[i] = 0; //Reset the imaginary values vector for each new frequency vImag[i] = 0; //Reset the imaginary values vector for each new frequency
} }
/*Serial.println("Data:"); /*Serial.println("Data:");
@ -97,13 +95,13 @@ void loop()
while(1); /* Run Once */ while(1); /* Run Once */
} }
void PrintVector(double *vData, uint8_t bufferSize, uint8_t scaleType) void PrintVector(double *vData, uint8_t bufferSize, uint8_t scaleType)
{ {
for (uint16_t i = 0; i < bufferSize; i++) for (uint16_t i = 0; i < bufferSize; i++)
{ {
double abscissa; double abscissa;
/* Print abscissa value */ /* Print abscissa value */
switch (scaleType) switch (scaleType)
{ {
case SCL_INDEX: case SCL_INDEX:
abscissa = (i * 1.0); abscissa = (i * 1.0);