forked from s-marley/Uno_vu_line
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vu6.ino
70 lines (58 loc) · 1.71 KB
/
vu6.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
/*
* VU: Rainbow from bottom or middle with hue cycling
*/
void vu6(bool is_centered, uint8_t channel) {
const uint8_t SPEED = 10;
static uint8_t hueOffset = 30;
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
}
#ifdef TWO_STRIPS
else {
leds = ledsRight;
peak = &peakRight;
}
#endif
if(height > *peak)
*peak = height; // Keep 'peak' dot at top
EVERY_N_MILLISECONDS(SPEED) {hueOffset++;}
if(is_centered) {
// Color pixels based on rainbow gradient
for (uint8_t i = 0; i < N_PIXELS_HALF; i++) {
if (i >= height) {
leds[N_PIXELS_HALF - i - 1] = CRGB::Black;
leds[N_PIXELS_HALF + i] = CRGB::Black;
} else {
leds[N_PIXELS_HALF - i - 1] = CHSV(hueOffset + (10 * i),255,255);
leds[N_PIXELS_HALF + i] = CHSV(hueOffset + (10 * i),255,255);
}
}
// Draw peak dot
if (*peak > 0 && *peak <= N_PIXELS_HALF - 1) {
leds[N_PIXELS_HALF - *peak - 1] = CHSV(hueOffset,255,255);
leds[N_PIXELS_HALF + *peak] = CHSV(hueOffset,255,255);
}
}
else {
// Color pixels based on rainbow gradient
for (uint8_t i = 0; i < N_PIXELS; i++) {
if (i >= height) {
leds[i] = CRGB::Black;
} else {
leds[i] = CHSV(hueOffset + (10 * i),255,255);
}
}
// Draw peak dot
if (*peak > 0 && *peak <= N_PIXELS - 1)
leds[*peak] = CHSV(hueOffset, 255, 255);
}
dropPeak(channel);
averageReadings(channel);
//FastLED.show();
LEDShowEnable=true;
}