Hi, I am trying to use the HSV Spectrum colour map,

Hi, I am trying to use the HSV Spectrum colour map, but FastLED is using the Rainbow colour map by default. I have read FastLED HSV Colors · FastLED/FastLED Wiki · GitHub many times but still cant work out how to change it.

I am setting up my LEDs with this code.

#include <FastLED.h>

#define LED_TYPE WS2812B
#define LED_PIN D1
#define COLOR_ORDER GRB
#define NUM_LEDS 144
#define BRIGHTNESS 255

CRGB leds[NUM_LEDS];

void setup() {
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
}

Then turning on the LEDS with…

FastLED.showColor(CHSV(hueCon, satCon, briCon));

hueCon, satCon, briCon are my converted and mapped values coming from an external source but using the Rainbow values

Thanks…

Have a look at this example. You can change it to use spectrum instead of rainbow.

@marmil Thanks, i will try to work it out from that.
What i am actually trying to do use Amazon Alexa to control the LED strip, which it does but the hue’s are slightly off.

I’m guessing you’re saying something like “Alexa, make lamp green”? Curious what sort of data and format does Alexa send?

Alexa sends… 3 values back, Hue, Saturation and Value (Brightness).
Hue is in the range of 0 to 359
Saturation is 0.0000 to 1.0000
Brightness is 0.0000 to 1.0000

Alexa. Make light Green returns…
“hue”: 120, “saturation”: 1.0000, “brightness”: 1.0000

Make light Sky Blue returns…
“hue”: 197, “saturation”: 0.4231, “brightness”: 0.9176

I then map all the values from Alexa to the range of 0 to 255.

Here is my code for doing the conversion and mapping.

      // Convert string "saturation" to a floating point then map it in the range of 0 to 255
      float satCon = saturation.toFloat();
      satCon = satCon * 10000; // Move the decimal 4 places to the Right
      satCon = map(satCon, 0, 10000, 0, 255);
      // Convert string "brightness" to a floating point then map it in the range of 0 to 255
      float briCon = brightness.toFloat();
      briCon = briCon * 10000; // Move the decimal 4 places to the Right
      briCon = map(briCon, 0, 10000, 0, 255);
      // convert string "hue" to an integer between 0 and 255
      int hueCon = hue.toInt();
      hueCon = map(hueCon, 0, 359, 0, 255);

      delay(20);
      FastLED.showColor(CHSV(hueCon, satCon, briCon));
      delay(20);

There is probably a better way to do this, but i am quite new to coding. The code works, but the Hue’s are slightly out. Hence i need to change fastLED to use the Spectrum colour map. This i have not managed to do yet.

@marmil Thank you, using your example i have managed to get the result i was looking for with this bit of code…

      // Assign values to the LEDs and then illuminate them
      CHSV hsv(hueCon, satCon, briCon);
      CRGB rgb;
      hsv2rgb_spectrum(hsv, rgb);
      for (int led = 0; led < (NUM_LEDS / 2); led++) {
        leds[led] = rgb;
        leds[(NUM_LEDS-1) - led] = rgb;
       FastLED.show();
       FastLED.delay(1); // create a wipe effect           
      }

Great, glad to hear it @Jezz_Doobie !
Do you have any info or code shared about your project anywhere? My brother just got a Dot so now you’ve spurred my interest to do a project for him.

@marmil Sure, I have uploaded the code to dropbox for you. Its not very tidy yet as its my 1st attempt at proper project.