0

Q. about Neopixel Classes
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Q. about Neopixel Classes

by Blueshark on Sat Jan 26, 2019 8:15 pm

While looking for Neopixel code I've noticed that there are Two types of calls for Neopixels…..

What is the diffirence between pixel.XXXXX and strip.XXXXX

see code examples of what I'm talking about... same Function written in different ways....

Code: Select all | TOGGLE FULL SIZE
   void rainbowCycle(uint8_t wait)
{
  uint16_t i, j;

  for (j = 0; j < 256 * 5; j++)
  { // 5 cycles of all colors on wheel
    for (i = 0; i < strip.numPixels(); i++)
    {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }


Code: Select all | TOGGLE FULL SIZE
    void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< pixel.numPixels(); i++) {
      pixel.setPixelColor(i, Wheel(((i * 256 / pixel.numPixels()) + j) & 255));
    }
    pixel.show();
    delay(wait);
  }
}



Whats the difference between pixel.... and strip....


Cheers

Blueshark
 
Posts: 101
Joined: Thu Dec 21, 2017 7:19 pm

Re: Q. about Neopixel Classes

by kcl1s on Sat Jan 26, 2019 9:35 pm

When you declare a Neopixel object you give it a name. The strandtest example uses this
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
where strip is the name. It could be declared as pixel, lights, dodad or any other name you chose. Then you just use that name for your code as in dodad.show();
You can use different names and have Neopixels objects on more than one pin.
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(60, PIN2, NEO_GRB + NEO_KHZ800);

Hope this helps

Fellow hobbyist
Keith

kcl1s
 
Posts: 1085
Joined: Tue Aug 30, 2016 12:06 pm

Re: Q. about Neopixel Classes

by Blueshark on Sat Jan 26, 2019 10:24 pm

Thank You Keith, for the explanation...

This clears things up...

Blueshark
 
Posts: 101
Joined: Thu Dec 21, 2017 7:19 pm

Please be positive and constructive with your questions and comments.