-
Notifications
You must be signed in to change notification settings - Fork 31
/
vu5.ino
73 lines (62 loc) · 2.05 KB
/
vu5.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
70
71
72
73
/*
* VU: Old-skool green and red from bottom or middle
*/
void vu5(bool is_centered, uint8_t channel) {
CRGB* leds;
uint8_t i = 0;
uint8_t *peak; // Pointer variable declaration
uint16_t height = auxReading(channel);
if(channel == 0) {
leds = ledsLeft; // Store address of peakLeft in peak, then use *peak to
peak = &peakLeft; // access the value of that address
}
else {
leds = ledsRight;
peak = &peakRight;
}
if (height > *peak)
*peak = height; // Keep 'peak' dot at top
if(is_centered) {
// Color pixels based on old school green / red
for (uint8_t i = 0; i < N_PIXELS_HALF; i++) {
if (i >= height) {
// Pixels greater than peak, no light
leds[N_PIXELS_HALF - i - 1] = CRGB::Black;
leds[N_PIXELS_HALF + i] = CRGB::Black;
} else {
if (i > N_PIXELS_HALF - (N_PIXELS_HALF / 3)){
leds[N_PIXELS_HALF - i - 1] = CRGB::Red;
leds[N_PIXELS_HALF + i] = CRGB::Red;
}
else {
leds[N_PIXELS_HALF - i - 1] = CRGB::Green;
leds[N_PIXELS_HALF + i] = CRGB::Green;
}
}
}
// Draw peak dot
if (*peak > 0 && *peak <= N_PIXELS_HALF - 1) {
if (*peak > N_PIXELS_HALF - (N_PIXELS_HALF / 3)){
leds[N_PIXELS_HALF - *peak - 1] = CRGB::Red;
leds[N_PIXELS_HALF + *peak] = CRGB::Red;
} else {
leds[N_PIXELS_HALF - *peak - 1] = CRGB::Green;
leds[N_PIXELS_HALF + *peak] = CRGB::Green;
}
}
} else {
// Color pixels based on old school green/red vu
for (uint8_t i = 0; i < N_PIXELS; i++) {
if (i >= height) leds[i] = CRGB::Black;
else if (i > N_PIXELS - (N_PIXELS / 3)) leds[i] = CRGB::Red;
else leds[i] = CRGB::Green;
}
// Draw peak dot
if (*peak > 0 && *peak <= N_PIXELS - 1)
if (*peak > N_PIXELS - (N_PIXELS / 3)) leds[*peak] = CRGB::Red;
else leds[*peak] = CRGB::Green;
}
dropPeak(channel);
averageReadings(channel);
FastLED.show();
}