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();
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.
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.
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…
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.)