Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Using millis or EVERY_N_MILLIS instead of delay statement in double for loops.
- *
- * By: Andrew Tuline
- *
- * Date: Jan, 2020
- *
- * If I can ditch a delay statement, I sure will.
- *
- */
- #include <FastLED.h>
- void setup(){
- Serial.begin(115200);
- }
- void loop(){
- // colorWipe(100); // Modified original with delays
- // testaWipe(100); // Using EVERY_N_MILLIS inside function
- // EVERY_N_MILLIS(100) { testWipe(); } // Using EVERY_N_MILLIS outside function
- milliWipe(100);
- }
- void milliWipe(uint8_t times) { // This one doesn't delay at all, but repeats the same thing until the counter increases. No harm, no foul.
- static long counte = 0;
- counte = millis() / times;
- counte = counte % 56;
- uint8_t k = counte % 7;
- uint8_t j = counte / 8;
- Serial.print(counte); Serial.print(" "); Serial.print(j); Serial.print(" "); Serial.println(k);
- }
- void testWipe() {
- static uint8_t counte = 0;
- counte +=1;
- counte = counte % 56;
- uint8_t k = counte % 7;
- uint8_t j = counte / 8;
- Serial.print(counte); Serial.print(" "); Serial.print(j); Serial.print(" "); Serial.println(k);
- } // testWipe()
- void testaWipe(uint8_t times) {
- EVERY_N_MILLIS(times) {
- static uint8_t counte = 0;
- counte +=1;
- counte = counte % 56;
- uint8_t k = counte % 7;
- uint8_t j = counte / 8;
- Serial.print(counte); Serial.print(" "); Serial.print(j); Serial.print(" "); Serial.println(k);
- }
- } // testaWipe()
- void colorWipe(uint8_t wait) {
- for(uint16_t j=0; j<8; j++) {
- for(uint16_t k=0; k<7; k++) {
- Serial.print(j*7+k); Serial.print(" "); Serial.print(j); Serial.print(" "); Serial.println(k);
- FastLED.delay(wait);
- }
- }
- } // colorWipe()
- /*
- void cd77_8X8_spiral_colorWipe(uint8_t ghue, uint8_t wait) {
- for(uint16_t j=0; j<bigboxarray_Size; j++) {
- uint16_t x=boxtotalarray[j];
- for(uint16_t k=0; k<x; k++) {
- leds[bigboxarray[j][k]]= CHSV(ghue, 255,255);
- FastLED.delay(wait);
- }
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement