I’m a little confused on how to properly implement CHSV. It is my understanding that FastLED converts HSV data to RGB on the fly, so if you say “leds[i].CHSV(x,y,z)” for an array defined with “struct CRGB leds[NUM_LEDS]” then it should work. However, when I try this in my sketch I get the compile error ‘struct CRGB’ has no member named ‘CHSV’
All the examples I’ve seen show the CHSV function being called that way and I cant’ figure out what I’m doing wrong.
I’m doing it this way because I’d like to directly access the brightness parameter (V) within the loop rather than some other brightness function.
Here’s my full sketch (it’s rough…just starting to put together the code):
#include “FastLED.h” // FastLED library.
#if FASTLED_VERSION < 3001000
#error “Requires FastLED 3.1 or later; check github for latest code.”
#endif
// Fixed definitions cannot change on the fly.
#define LED_DT 11 // Data pin to connect to the strip.
#define LED_CK 13 // Clock pin for WS2801 or APA102.
#define COLOR_ORDER BGR // It’s GRB for WS2812 and BGR for APA102.
#define LED_TYPE WS2812 // Using APA102, WS2812, WS2801. Don’t forget to modify LEDS.addLeds to suit.
#define NUM_LEDS 9 // Number of LED’s.
// Global variables can be changed on the fly.
uint8_t max_bright = 150; // Overall brightness definition. It can be changed on the fly.
struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
void setup() {
Serial.begin(57600); // Initialize serial port for debugging.
delay(1000); // Soft startup to ease the flow of electrons.
// LEDS.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2801 or APA102
LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2812
FastLED.setBrightness(max_bright);
set_max_power_in_volts_and_milliamps(5, 500); // FastLED Power management set at 5V, 500mA.
} // setup()
void loop(){
setcolors();
FastLED.show();
} // loop()
void setcolors(){
for (int i = 0; i < 3; i++) { // set BOTTOM LED color (yellow = 0,255,140 ; whiteish = 10,50,50)
leds[i].CHSV(HUE_YELLOW,255,255);
}
for (int i = 3; i < 6; i++) { // set MIDDLE LED color (the LEDs between nozzle and bottom. orange is roughly 0,255,60)
leds[i].CHSV(HUE_ORANGE,255,255);
}
for (int i = 6; i < 9; i++) { // set NOZZLE LED color (the LEDs at the top of the smoke plume. pure red is 0,255,0)
leds[i].CHSV(HUE_RED,255,255);
}
}