Skip to content

Commit 154511b

Browse files
author
Red Team
authored
Fixed negative color wheel pos
1 parent bb40452 commit 154511b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

music_visualizer_sparkfun_spectrum_shield.ino

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// LED LIGHTING SETUP
1414
#define LED_PIN 6
15-
#define NUM_LEDS 100 // 250
15+
#define NUM_LEDS 200 // 250
1616
#define BRIGHTNESS 64
1717
#define LED_TYPE WS2811
1818
#define COLOR_ORDER GRB
@@ -72,6 +72,7 @@ void setup()
7272
// FUNCTION TO GENERATE COLOR BASED ON VIRTUAL WHEEL
7373
// https://github.com/NeverPlayLegit/Rainbow-Fader-FastLED/blob/master/rainbow.ino
7474
CRGB Scroll(int pos) {
75+
pos = abs(pos);
7576
CRGB color (0,0,0);
7677
if(pos < 85) {
7778
color.g = 0;
@@ -86,6 +87,16 @@ CRGB Scroll(int pos) {
8687
color.g = 255 - color.b;
8788
color.r = 1;
8889
}
90+
/*
91+
Serial.print(pos);
92+
Serial.print(" -> ");
93+
Serial.print("r: ");
94+
Serial.print(color.r);
95+
Serial.print(" g: ");
96+
Serial.print(color.g);
97+
Serial.print(" b: ");
98+
Serial.println(color.b);
99+
*/
89100
return color;
90101
}
91102

@@ -109,7 +120,11 @@ void doubleRainbow()
109120
{
110121
for(int i = NUM_LEDS - 1; i >= midway; i--) {
111122
if (i < react + midway) {
123+
//Serial.print(i);
124+
//Serial.print(" -> ");
112125
leds[i] = Scroll((i * 256 / 50 + k) % 256);
126+
//Serial.print(i);
127+
//Serial.print(" -> ");
113128
leds[(midway - i) + midway] = Scroll((i * 256 / 50 + k) % 256);
114129
}
115130
else

0 commit comments

Comments
 (0)