Hi all, I’m getting into the home stretch on my dog collar project, and I’m at one final wish-list item, and was wondering if you had any ideas.
As you know, I’m setting up a show collar where the unit will step through several patterns, I’ve got that working well now. The speed of the scrolling for all the patterns that do scroll is defined initially as
#define UPDATES_PER_SECOND 125
What I would like to do is for one of the patterns (the black and white scrolling pattern) to have that be much faster, say 225.
I know I can’t stick another " #define updates per second xxx" statement just above the code because that is the whole purpose of the define-type statements.
Any ideas on how to set a different scroll speed to any particular stepped pattern, and then have it go back to the defalt when moving on to a different pattern?
So I added this statement near the top by the counters: (but still keeping the “#define UPDATES_PER_SECOND 125” statement
and in the group by the counters the third line
// some counters to keep state
int paletteCounter = 1;
int brightnessCounter = 99;
int updatesPerSecond = 125;
Then I added one line above the function that I want to be different:
updatesPerSecond = 200;
void SetupBlackAndWhiteStripedPalette()
{
// ‘black out’ all 16 palette entries…
fill_solid( currentPalette, 16, CRGB::Black);
// and set every fourth one to white.
currentPalette[0] = CRGB::White;
currentPalette[4] = CRGB::White;
currentPalette[8] = CRGB::White;
currentPalette[12] = CRGB::White;
@Roger_Kolasinski your updatesPerSecond = 200 line needs to go inside your function or somewhere in your main loop. Where ever you’re choosing what function to run in the main loop, try putting something there that specifies your slower or faster updates per second.
So thanks all, below is a post of the code I cobbled up from others examples. I’m now constructing the physical prototype and all should fit into a nice enclosure. I’ll post the final product.
One thing though, I never could get the black-and-white stripe function to run at a faster scroll speed than what was originally #defined at the top of the code. If someone could show me by example how to change it so that function would scroll maybe twice as fast, I would really appreciate it.
As Daniel mentioned, you’ll need to change that define line to a variable. So this line: #define UPDATES_PER_SECOND 125
becomes this:
int updatesPerSecond = 125;
And then where you have:
FastLED.delay(1000 / UPDATES_PER_SECOND);
Update that to:
if( paletteCounter == 4) { updatesPerSecond = 242; } // custom speed for this one palette
else { updatesPerSecond = 125; }
FastLED.delay(1000 / updatesPerSecond );
This would be a quick way to check which palette is being used and change it for just that one palette choice. To make it more adjustable and be able to tweak each palette I’d probably try setting each one individually down in the ChangePalettePeriodically function like this:
if( paletteCounter == 0) {
fill_solid( currentPalette, 16, CRGB::Black);
currentBlending = NOBLEND;
updatesPerSecond = 142; // tweak this palette’s time here
}
Thanks. Our teams next performance is memorial day weekend in the USA, in a couple of weeks. I probably won’t have all of them done for the show but i will have at least one done for one of my dogs and will post that video