-
Notifications
You must be signed in to change notification settings - Fork 31
/
vu10.ino
51 lines (40 loc) · 1.5 KB
/
vu10.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
/*
* VU: Palette blending demo
*/
CRGBPalette16 currentPalette;
CRGBPalette16 targetPalette;
void vu10() {
EVERY_N_SECONDS(5) { // Change the target palette to a random one every 5 seconds.
static uint8_t baseC = random8(); // You can use this as a baseline colour if you want similar hues in the next line.
for (int i = 0; i < 16; i++) {
targetPalette[i] = CHSV(random8(), 255, 255);
}
}
EVERY_N_MILLISECONDS(100) {
uint8_t maxChanges = 24;
nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges); // AWESOME palette blending capability.
}
EVERY_N_MILLISECONDS(20) { // FastLED based non-blocking delay to update/display the sequence.
soundtun();
FastLED.show();
}
}
void soundtun() {
int sampleLeft = abs(analogRead(LEFT_IN_PIN) - 512 - DC_OFFSET);
CRGB newcolourLeft = ColorFromPalette(currentPalette, constrain(sampleLeft, 0, 255), constrain(sampleLeft, 0, 255), LINEARBLEND);
nblend(ledsLeft[0], newcolourLeft, 128);
for (int i = N_PIXELS - 1; i > 0; i--) {
ledsLeft[i] = ledsLeft[i - 1];
}
if (STEREO) {
int sampleRight = abs(analogRead(RIGHT_IN_PIN) - 512 - DC_OFFSET);
CRGB newcolourRight = ColorFromPalette(currentPalette, constrain(sampleRight, 0, 255), constrain(sampleRight, 0, 255), LINEARBLEND);
nblend(ledsRight[0], newcolourRight, 128);
for (int i = N_PIXELS - 1; i > 0; i--) {
ledsRight[i] = ledsRight[i + 1];
}
}
else {
copyLeftToRight();
}
}