Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Question regarding strandtest
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Question regarding strandtest

by Rcayot on Sun Sep 13, 2020 9:51 am

I have my 8 LED neopixel wired up and running strandtest. Going through the code, I see something I do not know why it is used.

The line:
int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());

has a value 65536L, what is the meaning of the 'L'?

Code: Select all | TOGGLE FULL SIZE
for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
    for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
      // Offset pixel hue by an amount to make one full revolution of the
      // color wheel (range of 65536) along the length of the strip
      // (strip.numPixels() steps):
      int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
      // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
      // optionally add saturation and value (brightness) (each 0 to 255).
      // Here we're using just the single-argument hue variant. The result
      // is passed through strip.gamma32() to provide 'truer' colors
      // before assigning to each pixel:
      strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));


Thanks in advance,
Roger

Rcayot
 
Posts: 64
Joined: Sat Feb 08, 2020 6:48 pm

Re: Question regarding strandtest

by adafruit_support_bill on Sun Sep 13, 2020 11:40 am

The 'L' suffix in c++ instructs the compiler to use a long integer. The value 65536 would overflow the default 16-bit integer type in the Atmega processors used in most of the earlier model Arduinos.

adafruit_support_bill
 
Posts: 78990
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.