-
Notifications
You must be signed in to change notification settings - Fork 10
/
fht_readings_arm.ino
69 lines (49 loc) · 1.13 KB
/
fht_readings_arm.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#define ARM_MATH_CM3
#include <arm_math.h>
#include "fht_setup.h"
#include "led_setup.h"
#include "beat_detection.h"
void pad( int number, byte width = 3 ) {
if (number >= 0) {
SerialUSB.print(" ");
} else {
SerialUSB.print("-");
number = 0 - number;
}
int currentMax = 10;
for (byte i=1; i<width; i++){
if (number < currentMax) {
SerialUSB.print("0");
}
currentMax *= 10;
}
SerialUSB.print(number);
}
int log_level = 0;
void setup(){
if( log_level ){
while (!Serial); // wait for serialUSB monitor to be opened
SerialUSB.begin(1); // rate ignored for native port
}
fft_setup();
led_setup();
}
int count = 0;
void loop(){
if(log_level>0){
SerialUSB.print(millis());
}
fft_loop();
//fft_print_bins();
if( count == 0 ){ // too jittery if we do the lights every 1/100 second
uint16_t * buckets = fft_buckets(6, log_level);
led_show(buckets, log_level);
//detect_beat(buckets, log_level);
// uint16_t * bins = get_bins(1);
// led_show_32(bins, log_level);
}
if(log_level>0){
SerialUSB.println();
}
if(++count >= 3) count = 0;
}