tl;dr Just give me the code! Here you go: https://gist.github.com/StefanPetrick/5e853bea959e738bc6c2c2026683e3a4
Hi everyone! 2d matrix effects are a nice thing to code - but this requires lots of physical leds and a strong power supply to feed them.
So why not creating a 2d effect with just a very small amout of leds?
Here is the idea: Imagine a virtual 256x256 matrix. And imagine a circle constisting of NUM_LEDS leds. Now place this circle on the virtual matrix. The circle can be mathematically described as 2 overlapping functions - a sinus on x and a cosinus wave on y. The angle position of every single led we know - assuming the circle consists of 256 angle units the absolute x/y position defined by the relative angle of the given led is uint8_t angle = (i * 255) / NUM_LEDS;
So long story short - my code does the following: Calculate one time a look up table which contains the x/y position of any led within the virtual 256x256 matrix. This allows to calculate the noise data only for the few positions we really need = it´s fast while it still has the precision of a high-res matrix.
Based on that it´s easy to move the noise field in any direction(s).
The code contains 3 independent examples: example_1 moves the content up and down while shifting it slowly to the side. example_2 moves just along one axis and example_3 moves along the z axis of the noise space. Of course this simple movements can be combined or described by more complex functions, or they could be controlled by audio or sensor data or anything else you can imagine.
The color mapping could be improved as well - I decided to use a simple HSV mapping in order to keep the code simple and easy readable for the beginning.
The code is meant to inspire you to play with it yourself and create nice animations even for a limited setup. That´s why I kept the code short. It´s about the idea and not so mutch about delivering a plug and play animation.
Questions, suggestions and comments are highly appreciated. Has the code enough comments to get the idea? Is it useful for you?
What will you create based on this mapping?
Looking foreward to seeing it!