From 89a5bcb808711ee3cfe3b5e12a78709dc51291e6 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 30 May 2015 21:14:19 +0200 Subject: First working drafty arduino program --- arduino/fht_test.ino | 68 ---------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 arduino/fht_test.ino (limited to 'arduino/fht_test.ino') diff --git a/arduino/fht_test.ino b/arduino/fht_test.ino deleted file mode 100644 index 0e2f83c..0000000 --- a/arduino/fht_test.ino +++ /dev/null @@ -1,68 +0,0 @@ - -// FHT Options -#define FHT_N 256 -#define SCALE 256 -#define WINDOW 1 -#define REORDER 1 -#define LOG_OUT 1 -#define LIN_OUT 0 -#define LIN_OUT8 0 -#define OCTAVE 0 -#define OCT_NORM 0 - -#define BINS 128 - -#include - -void aquire_data() { - noInterrupts(); - - for (int i = 0; i < FHT_N; i++) { - while(!(ADCSRA & 0x10)); // wait for adc to be ready - ADCSRA = 0xf5; // restart adc - byte m = ADCL; // fetch adc data - byte j = ADCH; - int k = (j << 8) | m; // form into an int - k -= 0x0200; // form into a signed int - k <<= 6; // form into a 16b signed int - fht_input[i] = k; // put real data into bins - } - - interrupts(); -} - -void crunch_data() { - fht_window(); - fht_reorder(); - fht_run(); - //fht_mag_octave(); - fht_mag_log(); -} - -void setup() { - - Serial.begin(115200); - - TIMSK0 = 0; // turn off timer0 for lower jitter - ADCSRA = 0xe5; // set the adc to free running mode - ADMUX = 0x40; // use adc0 - DIDR0 = 0x01; // turn off the digital input for adc0 - -} - -char buf[2550] = ""; - -void loop() { - aquire_data(); - crunch_data(); - - for (int i = 0; i < BINS; i++) { - Serial.print(fht_log_out[i]); - Serial.print(' '); - } - - Serial.print('\n'); - - delay(10000); -} - -- cgit v1.2.3