-
-
Notifications
You must be signed in to change notification settings - Fork 3
How to edit the source and make your own animations
Remora is an ESP32 based C++ project and should run on any board supporting this architecture.
For compiling and uploading this you just need to install VSCode with the extension PlatformIO and git pull the source of this Project. The most advanced branch is develop. There are other branches for M5StickC that have WiFi manager already configured so you don't need to copy your WiFi Credentials on the source.
The most important part of the code where all animations happen and the Neopixels Makuna library starts is Animate.cpp There is also the startUdpListener Method that fires after a successful WiFi connection and it's as default configured for Orca port 41961
In this class is also the callback function that gets fired every time an UDP Message arrives. And what happens is basically the following:
If the packet.length() of the message received is major than 9 it will just process the received bytes using the Pixels protocol. Something that you can test as soon as you start your Controller using the UDPX online tester and it's documented here on the Pixels library.
So enough of preambles, how to create a new Animation that will fire with ;21R ?
Well, first of all, you need a basic understanding of C/ C++ and to read the Neopixels library Wiki to understand how their API and animations work. It's very well documented and there are a lot of examples, most of them have been in a way or another implemented on Remora animations.
But I already cooked a bit some functions that will make your life easier.
if (command.charAt(0) == '2') {
lastPixel = 0;
moveDir = 1; // 1 -> right -1 <- left
// commandToBase36 will turn the char after the 2 in the right integer to calculate duration in millis
int duration = commandToBase36(command, 1) * 10;
// Get the color part
if (packet.length()>2) { // Only change the color if Hue angle is sent otherwise keep last Hue
int colorAngle = commandToBase36(command, 2);
CylonEyeColor = HslColor(colorAngle / 360.0f, 1.0f, maxL);
debugMessage("colorAngle:"+String(colorAngle));
}
debugMessage("> duration: "+String(duration));
// And this part is what you really need to code to make the new animation
animations.StartAnimation(0, 4, fadeAnimUpdate);
animations.StartAnimation(1, duration, moveAnimUpdate);
}
And a good start is to simply copy the function moveAnimUpdate to give it a new name and in this new function update things after reading Neopixels examples to get what you want to do. Neopixels is a great library and it supports up to 8 RMT channels in an ESP32, so theoretically you can control many Led stripes with a single board. That of course in case you want to really expand this into something much bigger.
Keep in mind every RGB or RGBw Pixel has a little chip inside, and even when they are all off, every pixel consumes 1mA. Sounds irrelevant but if you have 1000 pixels, you are drawing 1 Ampere over the wire, even when all LEDs are off.
Remora wiki v1.0 - Documentation written by Fasani Corp.