Has anyone ever needed to change between different setup options in the same sketch

Has anyone ever needed to change between different setup options in the same sketch before? I’m not sure where to even start. Essentially, I have 8 strips on different pins and sometimes I like them all mirrored but other times I want to change the setup options so I can draw to the strips individually.

Anyone have an example where they switched setup options using a button or other control that they wouldn’t mind sharing?

My suggestion would be to just always leave it set it up so you can draw to all strips individually. Then if you want any mirroring do it all in code.

When in “mirror mode” you can set pixel colors for one strip, and then call a subroutine right before calling FastLED.show that copies that data to all the other strips. The “mirrorMode” variable could be toggled on/off with a button, timer, etc.

Add a variable in setup:
boolean mirrorMode = 0; //initially set “off”

In your loop:

if (mirrorMode = 1) { //mirror to other strips if true
mirrorStrips; // call subroutine to mirror data
}
FastLED.show();

Thanks. That makes perfect sense. Now I have to figure out how to write something that copies the data to the other strips. Ha!

A for loop would be a straight forward way to copy the data.
in the for loop:
leds2[i] = leds[i]; //copy RGB data to leds2
leds3[i] = leds[i]; //copy RGB data to leds3
etc.

or
leds[1][i] = leds[0][i]; //copy RGB data to leds[1]
leds[2][i] = leds[0][i]; //copy RGB data to leds[2]
etc.

Post your code to http://gist.github.com if you’d like suggestions.

CRGBArray would help with this.

leds(11,20)=leds(0,10); // copies 0-10 to 11-20
Show;

Another option is to check into CRGBsets… worked wonders for me and also play with pallets for color blends in reverse… :slight_smile:

In my example of you used
leds(11,20)=leds(10,0)
It will reverse the order of then in the copy process.

You could get fancy and add a physical toggle switch that switches between mirrored or not mirrored mode.

Do what Marc suggested but check the state of the switch each time through the main loop to set that variable to true or false instead of having to re-program the board each time you want to change things.

I do something similar with a virtual switch using an app called Blynk and can enable/disable mirroring on the fly. If you are using an ESP8266 I would highly recommend looking into Blynk.

Belated thanks to everyone for ideas. I’m just not getting started trying out some of your suggestions.

Not sure if anyone is still following this but I FINALLY got around to following your suggestions. I think I did something wrong though. The strips were mirrored but slightly out of sync. Maybe a pixel or two behind on animations. I might have to share the code, maybe I made a mistake. Wondered if that was to be expected…

Share the code. You shouldn’t be having any issues

Still following. Post your code to http://gist.github.com and someone should be able to help. :slight_smile:

I’ve continued to experiment with a few basic animations. Pretty consistent now. The mirrored strips are all in sync but the [0] strip is just slightly ahead. Here’s the gist! https://gist.github.com/coopooc/f57606ef669409ffbd9df73206f16a95

Put the call to the fill function before the mirroring code. Fill the [0] array then copy it. Move your line 12 to before line 3 in the gist.

This sync issue you created gives me some ideas to add to my notes for future projects. Proper ordering of the copying of the arrays could create an interesting pattern…

Ha, well, I’m glad that my mistake inspired a new line of research! I did eventually get it sorted out, though not with the example I originally posted. I ended up starting over with the fastled demoreel example sketch and had more success. Now that I have some good mirror patterns, I’m working on creating new non-mirrored patterns.

I’ll post a video of the prototype installed on the merry-go-round. Maybe someone will have some creative ideas for me. (If anyone is interested, my daughter inherited this merry-go-round from my grandparents. It was built in 1918, I think that’s right, and I rode it as a child. Pretty neat to have.)