First of all I'd like to say how inspiring this FastLed community is,

First of all I’d like to say how inspiring this FastLed community is, even to a non programmer like myself.

I’ve been using Jason Coon’s excellent Web Server using a ESP8266 to drive a 1 metre 60 LED light stick for light painting. I have no problem using custom color palletes generated using PaletteKnife http://fastled.io/tools/paletteknife/
… but I have a very simple programming question. How do I code a function that will just give me the chosen color gradient palette along the length of the stick with no animation ? Also with an option to reverse it would be useful.

For those that arent familer with the web server …the color palettes are choosen from a list using ‘ColorFromPalette’

Thanks.
Jon.

Set the chosen pattern and only .show () once… :)…

You should be able to make a for loop, from 0 to NUM_LEDS - 1, setting each LED to the ColorFromPalette using the LED’s index. If you had 256 LEDs, each color from the palette would be shown on a single LED. Since you only have 60 LEDs, you’ll need to decide how you want them distributed. Increment the color index by 2, and you’d still only get colors 0-119. Increment by 4, and you’d get 0-239, etc.

Thanks for your help guys, but I’m struggling to find the right syntax. Is something like this a start? I’m not sure where to increment the color index (by 4 would be a good choice in my case with 60 leds.). …

void static_Palette ()
{
for ( int i = 0; i < NUM_LEDS; i++)

{ leds[i] = ColorFromPalette (palettes
[currentPaletteIndex]) ???
}
}

If by no animation you mean to have the palette displayed statically across your LEDs, I suggest you look at the “fill_palette” function. It’s a handy function to fill a range of LEDs based on a palette (look into the colorutils.h file in the fastLED distribution for details). Note that it’s a “shortcut” convenience function; you could just as well simply use a “for loop” + colorFromPalette instead in your code.

As Jason pointed out, you’ll want to play with the “increment” value to map the palette pattern across your LEDs. I got a pleasing result on my 60 LED ring by using “(256 / NUM_LEDS)+1” as the increment value (i.e. no repeating palette pattern).

Thanks Matt,
I’ve tried fill_palette and it seems to work, other than the fact the palette is still cycling along the length of the strip. I think I’m incrementing the wrong variable ? …

void staticPalette ()
{
CRGBPalette16 myPal = palettes[currentPaletteIndex];
static uint8_t index = 0;
index++;
fill_palette( leds, NUM_LEDS, index, 1, myPal, 255, LINEARBLEND);
}

@Black_Spline
Yes, looks like one index (start led) is possibly wrong. If you check the source file, you’ll see that the function handles the indexing of the LEDs via a “for loop” so no need to do it yourself. What worked for me is:

void staticPalette ()
{
fill_palette( leds, NUM_LEDS,0,(256 / NUM_LEDS)+1, gCurrentPalette, 255, LINEARBLEND);
}

parameters being: (LED reference, how many LEDs, start LED, palette increment, palette, brightness, blend type).

In my case, the palettes were defined globally (gCurrentPalette) as they’re modified elsewhere. I also encourage you to fiddle with the “palette increment” value till you find something which pleases you.

Thanks Matt. It works, just had to adjust the 256/NUM_LEDS so the gradient palettes fit the strip without repetition.

@Black_Spline
Glad to hear it works.

As to going in reverse, I think the easiest would be to copy the function in the source file, paste it in your sketch (rename it to e.g. fill_palleteInverse), and then change the loop parameters so that you decrement from num_led-1 to 0 (instead of incrementing from 0 to num_led). Not tested but I believe it should work.

Going over the code, I also realised that I got it wrong in the description of the third parameter. Should really be “color start index” rather than of “start LED”. Apologies.

Thanks, I’ll give it a go. Just tried a bit of ‘baton twirling’ indoors due to the weather. Some palettes seem to quite well …
missing/deleted image from Google+

@Black_Spline
Very nice picture! Good colours indeed, and nice flowing movements!

I’m curious about your build. You mentioned 60 LEDs and an ESP8266, but nothing about materials nor construction. It would be really great if you could share some of these details with some pics (if possible) of both the build and – naturally – the results.

thanks

@matt_p Its just a prototype at the moment, so excuse the hot glue. (Pictures linked at bottom of post).

I wanted to use a florescent tube cover as a diffuser - like a lot of light painters do - that use flash lights, but unfortunately here in the UK they arent easy or cheap to get hold of. Instead I’m using an Aluminium round face profile strip, used for cabinet lighting.
The ‘control’ box contains an on/off switch, a 3Ah LiPoly battery feeding a 5 volt regulator which in turn powers the ESP8266 and the strip. With all the lights on at full power its only taking 700mA, but with gradient palettes at lower brightness its more like 200-400 mA.

I will post ‘proper’ pictures once the weather has improved and I can test it outdoors.

I would also like to get OTA (wifi) sketch upload working for the ESP8266 so I can upload palettes without having to connect to USB. As I’m not a programmer , this might be problematic though.
https://drive.google.com/open?id=0B5G3aZlHk9K_bnAtR1hpQldCQjA

Here are some preliminary test shots.