Skip to content

Commit 7a425c1

Browse files
committed
Revert "Add ear code"
This reverts commit cfb187f.
1 parent 3fdb9e6 commit 7a425c1

File tree

1 file changed

+0
-74
lines changed

1 file changed

+0
-74
lines changed

M4_Eyes/user.cpp

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#if 1 // Change to 0 to disable this code (must enable ONE user*.cpp only!)
22

3-
#include "globals.h"
4-
53
// This file provides a crude way to "drop in" user code to the eyes,
64
// allowing concurrent operations without having to maintain a bunch of
75
// special derivatives of the eye code (which is still undergoing a lot
@@ -11,28 +9,10 @@
119
// User globals can go here, recommend declaring as static, e.g.:
1210
// static int foo = 42;
1311

14-
const int sampleWindow = 400; // Sample window width in mS (50 mS = 20Hz)
15-
16-
unsigned long end_millis= 0; // Start of sample window
17-
18-
unsigned int left_max = 0;
19-
unsigned int left_min = 1024;
20-
21-
unsigned int right_max = 0;
22-
unsigned int right_min = 1024;
23-
24-
unsigned int sample_count = 0;
25-
unsigned int sample;
26-
unsigned int peakToPeak;
27-
double volts;
28-
29-
30-
3112
// Called once near the end of the setup() function. If your code requires
3213
// a lot of time to initialize, make periodic calls to yield() to keep the
3314
// USB mass storage filesystem alive.
3415
void user_setup(void) {
35-
end_millis = millis() + sampleWindow;
3616
}
3717

3818
// Called periodically during eye animation. This is invoked in the
@@ -84,60 +64,6 @@ void user_loop(void) {
8464
}
8565
}
8666
*/
87-
88-
89-
if (millis() >= end_millis) {
90-
// process the current sampling
91-
if (left_max > left_min && right_max > right_min) {
92-
93-
// process left
94-
peakToPeak = left_max - left_min; // max - min = peak-peak amplitude
95-
volts = (peakToPeak * 5.0) / 1024; // convert to volts
96-
Serial.print("Left: ");
97-
Serial.println(volts);
98-
if (volts > 1.0) {
99-
Serial.println("I hear you on the left");
100-
}
101-
// process right
102-
peakToPeak = right_max - right_min; // max - min = peak-peak amplitude
103-
volts = (peakToPeak * 5.0) / 1024; // convert to volts
104-
Serial.print("Right ");
105-
Serial.println(volts);
106-
if (volts > 1.0) {
107-
Serial.println("I hear you on the right");
108-
}
109-
} else {
110-
Serial.print("Not enough sampling: ");
111-
Serial.println(sample_count);
112-
}
113-
// and reset for the next sampling
114-
right_max = left_max = 0;
115-
right_min = left_min = 1024;
116-
end_millis = millis() + sampleWindow;
117-
sample_count = 0;
118-
} else {
119-
for (int i = 5; i > 0; i--) {
120-
sample_count++;
121-
// sample left
122-
sample = analogRead(2);
123-
if (sample < 1024) { // toss out spurious readings
124-
if (sample > left_max) {
125-
left_max = sample; // save just the max levels
126-
} else if (sample < left_min) {
127-
left_min = sample; // save just the min levels
128-
}
129-
}
130-
// sample right
131-
sample = analogRead(3);
132-
if (sample < 1024) { // toss out spurious readings
133-
if (sample > right_max) {
134-
right_max = sample; // save just the max levels
135-
} else if (sample < right_min) {
136-
right_min = sample; // save just the min levels
137-
}
138-
}
139-
}
140-
}
14167
}
14268

14369
#endif // 0

0 commit comments

Comments
 (0)