atuline / FastLED-Demos

Here's my updated FastLED demos from January, 2017.
GNU General Public License v3.0
611 stars 174 forks source link

i want to run normal program with class type of program #10

Open LedArts opened 7 years ago

LedArts commented 7 years ago

NEED HELP Can i run "class" code with normal example code. i try but only one of them is running. what should i do please tell me.

class example class colorWipe: public animation { public: colorWipe(void) { w = random(256); } virtual void init(void); virtual void show(void); private: byte w; int index; bool fwd; };

void colorWipe::init(void) { int p = random(2, 4); w += p*16 + 1; fwd = random(2); index = 0; if (!fwd) index = strip.numPixels() - 1; }

void colorWipe::show(void) { uint32_t color = Wheel(w); if (fwd) { if (index > int(strip.numPixels())) { // Start new sequence with the new color init(); complete = true; return; } strip.setPixelColor(index++, color); } else { if (index < 0) { // Start new sequence with the new color init(); complete = true; return; } strip.setPixelColor(index--, color); } complete = false; }

Normal example void theaterChase(uint32_t c, uint8_t wait) { for (int j=0; j<10; j++) { //do 10 cycles of chasing for (int q=0; q < 3; q++) { for (uint16_t i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, c); //turn every third pixel on } strip.show();

  delay(wait);

  for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
    strip.setPixelColor(i+q, 0);        //turn every third pixel off
  }
}

} }

only mgr.show is running in this loop void loop() { mgr.show(); theaterChase(strip.Color(127, 127, 127), 50); // White theaterChase(strip.Color(127, 0, 0), 50); // Red theaterChase(strip.Color(0, 0, 127), 50); // Blue } what should i do please tell me.