@@ -47,7 +47,6 @@ bool patternComplete = false;
47
47
int pixelInterval = 50 ; // Pixel Interval (ms)
48
48
int pixelQueue = 0 ; // Pattern Pixel Queue
49
49
int pixelCycle = 0 ; // Pattern Pixel Cycle
50
- uint16_t pixelCurrent = 0 ; // Pattern Current Pixel Number
51
50
uint16_t pixelNumber = LED_COUNT; // Total Number of Pixels
52
51
53
52
// setup() function -- runs once at startup --------------------------------
@@ -71,7 +70,6 @@ void loop() {
71
70
patternComplete = false ;
72
71
patternPrevious = currentMillis;
73
72
patternCurrent++; // Advance to next pattern
74
- pixelCurrent = 0 ;
75
73
if (patternCurrent >= 7 )
76
74
patternCurrent = 0 ;
77
75
}
@@ -115,13 +113,12 @@ void loop() {
115
113
// strip.Color(red, green, blue) as shown in the loop() function above),
116
114
// and a delay time (in milliseconds) between pixels.
117
115
void colorWipe (uint32_t color, int wait) {
118
- if (pixelInterval != wait)
119
- pixelInterval = wait; // Update delay time
120
- strip.setPixelColor (pixelCurrent, color); // Set pixel's color (in RAM)
121
- strip.show (); // Update strip to match
122
- pixelCurrent++; // Advance current pixel
123
- if (pixelCurrent >= pixelNumber) { // Loop the pattern from the first LED
124
- pixelCurrent = 0 ;
116
+ static uint16_t current_pixel = 0 ;
117
+ pixelInterval = wait; // Update delay time
118
+ strip.setPixelColor (current_pixel++, color); // Set pixel's color (in RAM)
119
+ strip.show (); // Update strip to match
120
+ if (current_pixel >= pixelNumber) { // Loop the pattern from the first LED
121
+ current_pixel = 0 ;
125
122
patternComplete = true ;
126
123
}
127
124
}
@@ -130,18 +127,29 @@ void colorWipe(uint32_t color, int wait) {
130
127
// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
131
128
// between frames.
132
129
void theaterChase (uint32_t color, int wait) {
133
- if (pixelInterval != wait)
134
- pixelInterval = wait; // Update delay time
135
- for (int i = 0 ; i < pixelNumber; i++) {
136
- strip.setPixelColor (i + pixelQueue, color); // Set pixel's color (in RAM)
130
+ static uint32_t loop_count = 0 ;
131
+ static uint16_t current_pixel = 0 ;
132
+
133
+ pixelInterval = wait; // Update delay time
134
+
135
+ strip.clear ();
136
+
137
+ for (int c=current_pixel; c < pixelNumber; c += 3 ) {
138
+ strip.setPixelColor (c, color);
137
139
}
138
- strip.show (); // Update strip to match
139
- for (int i=0 ; i < pixelNumber; i+=3 ) {
140
- strip.setPixelColor (i + pixelQueue, strip.Color (0 , 0 , 0 )); // Set pixel's color (in RAM)
140
+ strip.show ();
141
+
142
+ current_pixel++;
143
+ if (current_pixel >= 3 ) {
144
+ current_pixel = 0 ;
145
+ loop_count++;
146
+ }
147
+
148
+ if (loop_count >= 10 ) {
149
+ current_pixel = 0 ;
150
+ loop_count = 0 ;
151
+ patternComplete = true ;
141
152
}
142
- pixelQueue++; // Advance current pixel
143
- if (pixelQueue >= 3 )
144
- pixelQueue = 0 ; // Loop the pattern from the first LED
145
153
}
146
154
147
155
// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
0 commit comments