Good Morning! I’m looking for some guidance and tutelage on adapting the code from two different projects into my own. I’m using an Uno and WS2812 chips in a zigzag matrix.
I found code for building a 15x10 matrix which included some patterns in C++ by Robert Atkins. I’d like to adapt these but use a pot to control the speed of the animation. I’d also like to adapt sound control similar to the one used in the following thundercloud lamp (https://github.com/jamesabruce/cloudlamp/blob/master/thundercloud/thundercloud.ino). However, most sound reactive projects output to a strip including the cloud light as well as Adafruits drum lights (https://learn.adafruit.com/gemma-powered-neopixel-led-sound-reactive-drums/overview), which is similar to my end goal of having my project reactive to a very loud live band.
Most of the folks I’ve asked about this at my local Maker group have been a little out of their depth on this code so I thought I’d ask here. I’m not a code expert by any means but I am a very quick learner.
http://www.mediafire.com/file/kho5lfw25bh9y75/15x10RGBLEDMatrixCode.rar
Here’s my sound reactive drums:
Oh hai 
Which of my matrix code did you find? Controlling animation speed with a pot might be as simple as using the value you analogRead() from the pin the pot’s connected to as (a multiplier of?) the value you pass in to FastLED.delay().
@Robert_Atkins Hello! The code I found has quite a few references to a “Gauntlet II project.” There several animations that are included in that rar file above. I’m not actually sure how some of the patterns are timed. If you wouldn’t mind, I’d appreciate if you dropped me an email.
Oh, that’s old stuff! Check out https://bitbucket.org/ratkins/technocolourdreamcoat2016controllertest/src
Happy to answer questions, but on holidays right now without a computer (so can’t un-RAR things, for example)
Well, The whole rar archive was setup by a YouTuber named Great Scott who put together that package to run on a 15x10 matrix minibar. I’m not the best coder (at all, really) so adapting animations is very difficult for me unless I’m shown how to do it. But that Animation 22 does look super awesome. I just can’t for the life of me figure out how the animations are timed nor the way I should go about speeding it up or slowing it down. It also looks like you added some sound reactivity so I’d like to pick your brain on that.
I’ve actually got some time on this project so we can get into specific code examples later so I don’t interrupt your holiday. How should I contact you directly? I can’t find your email.
Here is fine 
(That way the discussion is entered into the public record and might be able to help others)
When you say “timing”, you mean you want to slow down or speed up the effects? That’s done simply by introducing a call to FastLED.delay() in your main loop. Fiddle with the number and see what looks right.
If you want to make something happen on a particular schedule, look at the usage of the EVERY_N_MILISECONDS() macros in https://github.com/FastLED/FastLED/blob/master/examples/DemoReel100/DemoReel100.ino
In fact, for most of my stuff I don’t introduce a delay at all because the frame rate is bound by the maximum rate the microcontroller can send data out to the LEDs and I want it to go as fast as possible.
Good call on the public record.
Now, I may have been reading the code wrong. There is no spefic timing inside the effects cpp file?
There’s not. It just goes as fast as it can.
@Robert_Atkins are you back from holiday?
Oh hello! I wanted to check in with you on the code that I found (linked above) and well as what you suggested for the newer patterns. The code linked above has a “Sketch2.ino” a “Sketch3.ino” and a “sinzianaPanel.ino.” Are these all yours or were 2 & 3 written by the guy who’s project I copped? Also, is each cpp file a pattern? What does each one do, or should I just hook them up and see? Also, in your newer patterns that you linked, each file is a “.h” except for matrix.cpp. Why did you go a different route with patterns instead of cpp files?
I’ll ask my next round of questions once we tackle this.
The sinzianaPanel.ino is mine, the others aren’t.
Each .cpp file is a pattern, yes—hook them up and see what they do :). I changed from .cpp to .h on @Daniel_Garcia 's advice (don’t worry too much about why, it’s just C++ arcana; I’m assured the newer version with the .h is the right way to do it.)
Robert! I finally got time to sit down and get some rough prototyping in. I got the sinziana panel working without much effort. However, I couldn’t get your newer file (with all the .h files) working. I tried loading it directly onto my uno hooked up to the serpantine strip but i kept getting an error. I can’t remember what it was, it was late and I gave up quickly.
I built some custom playlists in the sinziana panel which was easy enough but a few patterns didn’t seem to work right: Bouncy only gave me a quick zip of color along an edge, boxes was the same along a different edge, and HiRez was similar. Also, I can’t figure out what effect.h and effect.cpp do.
I also tried to get the .h files from your newer project to run in sinzianaPanel.ino without much luck. Is there something I’m missing or a different way I have to run them than the sinziana panel on an uno?
I think there’s still some confusion here. Bouncy, Boxes and HiRez aren’t my code AFAIK. The split between .h and .cpp files is pretty fundamental to how it’s all organised and you won’t be able to “just” pull an effect from one to the other.
If I were you I’d start with the TechnocolourDreamcoat2016 repo linked above. Matrix.cpp/Matrix.h is as it says, definitions and implementation of translation of XY coordinates into a linear pixel address (i.e., the index into the leds[] array.) Effect.h is the base class for the effects (plus the definition of the Controls class, which is filled out by the .ino every loop, with values from the various hardware dials, buttons, and the MSGEQ7 spectrum analyser chip.) The rest are effects, implementations of the Effect.h interface. It’s those you can fiddle with/add to to introduce more effects. You just need to implement the interface described in Effect.h—that is, a draw() method (which takes a Controls instance as an argument) and blankEveryFrame(), which returns true if that effect wants the .ino to set the leds[] array to black every frame or if it wants to keep its last iteration and work on it again next round.