Thanks to Mark Kriegsman I have the animations looking the way they should on my mock-up!
Hey that looks pretty good!
What’s the “stand” and how’d you make that?
Just a piece of scrap plywood spray painted black. This will eventually be the front of my bass amp and will respond to the frequencies/velocities of my playing.
BTW, I’m trying to make the paletteadvperpixel a calculated constant but when I attempted it I got 0. What’s the trick?
Just put “const” in front of it?
Can you show the code you have that’s not working?
Also: the compiler probably already knows that it’s a constant if you’re only assigning to it once.
I had to multiply the start index factor by 256 to get the animations at the correct speed again. I changed the variable to a uint16 and passed it along with the scale constant to the fillledsfrompalettecolors function.
So: working now? Or do you still have trouble? Sorry if I’m a bit confused still. If still trouble: just paste in the code and I’ll take a look.
Index/speed is ok. Here’s the line for the const:
const uint16_t paletteAdvancePerPixelx256 = (256*256)/NUM_LEDS;
So it’s OK now?
Const calculation still isn’t working. I’m getting around it now by just setting it to 574, but I’d like to be able to use a compile-time calculation to set the value.
The problem is that “256” is an “int”, which is a uint16_t or an int16_t depending on how it’s used. And (256256) is also of type “int”. BUT. But an “int” in Arduino is 16 bits, and 256256 is 65536, which is bigger than you can fit in 16 bits.
SO, any of these will work for the value of paletteAdvancePerPixelx256:
65536 / NUM_LEDS
(256L*256L) / NUM_LEDS
((uint32_t)256*(uint32_t)256) / NUM_LEDS
(256*256L) / NUM_LEDS
(256*(uint32_t)256) / NUM_LEDS
Basically: (1) untyped integer constants are “int” and (2) “int” is only 16 bits on Arduino and (3) 65536 is the same as “0” in 16 bits.
That help?
Yes, but the part I’m still working on is the “const” declaration. I can research that on my own since it’s not directly related to FastLED and I don’t want to wear out my welcome!
I was able to get the animation to run correctly by just changing the line in the example code to “startIndex = startIndex + 1*256” changing the “1” will adjust the speed the same way it does in the unmodified example. I’ll post my code in a few minutes if you like.
//includes & defines
#include <FastLED.h>
#define LED_PIN 6
#define NUM_LEDS 114
#define BRIGHTNESS 248
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
//const uint16_t paletteAdvancePerPixelx256 = (256*256)/NUM_LEDS; //“Evens up” the animation at the start/end of the strip
const uint16_t paletteAdvancePerPixelx256 = 574; //“Evens up” the animation at the start/end of the strip
#define UPDATES_PER_SECOND 100
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
//Setup code
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
//Loop code
ChangePalettePeriodically();
static uint16_t startIndex = 0;
startIndex = startIndex + 256*1; // motion speed - Multiply by 256 to get correct speed
FillLEDsFromPaletteColors( startIndex, paletteAdvancePerPixelx256);
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
//Functions
void FillLEDsFromPaletteColors( uint16_t paletteIndexx256, uint16_t paletteAdvancePerPixelx256)
{
//Disregard brightness settings. They are determined by the audio input signal
//uint8_t brightness = 255;
int tmp = map(analogRead(BRIGHTNESS_PIN), 0, 1024, 0, 255);
uint8_t brightness = constrain(map(audio1.GetValue(ble_duty), 600, 1024, tmp, 255), tmp, 255);
for( int i = 0; i < NUM_LEDS; i++) {
uint8_t index = paletteIndexx256 / 256;
leds[i] = ColorFromPalette( currentPalette, index, brightness, currentBlending);
paletteIndexx256 += paletteAdvancePerPixelx256;
}
}
//void ChangePalettePeriodically() unchanged from the example code
The times-256 is needed because now you’re doing everything in 16-bit fixed point numbers, with 8 bits of whole number and 8 bits of fraction in each. (“Q8.8” format)
Sometimes it helps me to write these things in hex, because 256 is the more readable(?) 0x100. So:
startIndex += 0x100;
I also sometimes suffix my “Q8.8” variables with “88” as a reminder to me, so I might use the name “startIndex88” in this case.
Nice side effect is that you can now use fractional speeds: half speed would be 128 (0x80); one and a quarter speed would be 256+64 (0x140), etc.
Love it! I made sure you get a mention in my “Acknowledgements” section of my final code!
…of course, no one will see it but me unless I decide to start selling these things! 
Happy to help! It’s a cool project-- keep us posted!
Hey Nice Project @Steve_Hurd but are you sharing the code anywhere?
Not yet. Right now I’m just using the demo animations in the FastLED library with the example that shows how to use palettes. This will eventually be connected to my bass rig and drive lights around the perimeter of my amp. All I have right now is the ability to change the overall brightness based on how loud I play. I just ordered the MSGEQ7 IC and plan to use it to change animations/colors based on the frequency I’m playing. I’m also going to connect the box to my Android via Bluetooth to change settings from my phone. It’s been a fun project so far! It’s the nerd equivalent of working on a car restoration in your garage!