I'm using FastLEDs builtin fill_rainbow function for generating a rainbow spectrum on an LED strip. The issue is, I get a random red pixel midway through the yellow region. I've tried it on 3 different Arduino nano's, and two different LED-strips. Here's the code:
#include <FastLED.h>
#define DATA_PIN 2
#define NUM_LEDS 114
CRGB leds[NUM_LEDS];
uint8_t hue = 0;
void setup() {
Serial.begin(115200);
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
fill_rainbow( leds, NUM_LEDS, hue, 1);
for(int i=0; i<NUM_LEDS; i++) {
Serial.print(i);
Serial.print(' ');
Serial.print(leds[i].r);
Serial.print(' ');
Serial.print(leds[i].g);
Serial.print(' ');
Serial.println(leds[i].b);
}
CHSV hsv;
CRGB rgb;
//rgb = hsv;
}
void loop() {
fill_rainbow( leds, NUM_LEDS, hue, 1);
FastLED.show();
}
Here pixel number 60 gets the rgb code 160, 0, 0. When it should have something like 160, 150, 0.
The strangest part of all is that I can get rid of the problem in two ways, either by uncommenting the line rgb = hsv;, or by commenting out the fill_rainbow function in the loop function. This strange behavior leads me to believe im somehow messing up a pointer or misusing a FastLED feature. Additionally the fill_rainbow function is very simple and relies on FastLEDs hsv to rgb typecasting, which is another reason to believe I'm doing something wrong.
So help me out here, am i doing something silly, or have I discovered a bug with FastLEDs hsv to rgb converter?