jackw01 / led-control

Advanced WS2812/SK6812 RGB/RGBW LED controller with on-the-fly Python animation programming, web code editor/control interface, 1D, 2D, and 3D display support, and E1.31 sACN support
https://jackw01.github.io/led-control/
MIT License
162 stars 35 forks source link

Ability to add custom secondary patterns #22

Closed ohthehugemanatee closed 2 years ago

ohthehugemanatee commented 2 years ago

Is there a reason there's no field for adding secondary patterns? I need to do this for my project, and would be happy to do it in a way that creates a patch for you.... but I'm worried that there may be a good reason you didn't add that already.

jackw01 commented 2 years ago

I didn't add this because I assumed that any custom functionality could always be implemented as a single primary pattern. I don't think it would make sense to add this now, but if you do come up with some useful secondary patterns that would make sense to have built in you could always make a pull request to get those added.

ohthehugemanatee commented 2 years ago

I'll give you my use case and you let me know what you think:

I'm using this project to control arrays of LED strips for a stage show. A central raspberry PI issues http calls to led-control running on a handful of pi-zeros in various places around the stage. Each pi zero controls its own strips; ie one pi zero controls the main backdrop, another one controls the lights on the piano, and another controls the long strip along the edge of the stage. Here are the custom secondary patterns that I'm finding I want to implement:

Some of them I can imagine being generally useful, like fade or wipe. Others are totally idiosyncratic to my own situation.

You can implement anything as a primary pattern, of course, but it gets pretty ugly. Fade, for example, would need a specific primary pattern specified as a second function, so the primary pattern can continue moving during the fade. This is exactly how primary/secondary patterns work already, but crammed into the one text field.

For now I'll submit individual PRs with the ones that seem generally useful. Let me know if you think other users might want to add their own secondaries and I'll figure out the UI stuff.

jackw01 commented 2 years ago

First of all, you really should look at DMX, which is a very simple communication protocol designed specifically for your application (distributed real-time control of stage lighting) instead of implementing this functionality yourself with HTTP requests. HTTP or any TCP-based protocol would have far too much latency for this.

I currently have sACN (DMX via UDP) support built in, and this provides reasonably low latency (good enough for real-time music visualization) for remote control over ethernet or WiFi. With this, you can run a program like LedFx on your central computer which can control multiple client devices on the same network. LEDControl provides the benefit of being able to drive RGBW LEDs with RGB-only data sent over DMX.

I think some of these features (one-off secondary patterns that need to be triggered somehow) are outside the scope of implementing inside LEDControl itself, but there are probably other open-source DMX or sACN control projects that have this functionality already.

I would gladly accept pull requests improving DMX support, such as by adding support for hardware DMX interfaces or a DMX sender mode that allows LEDControl to stream data to other DMX devices to mirror or extend its display.

ohthehugemanatee commented 2 years ago

Thanks for this, informative as always.

I stayed away from DMX in trying to build a first version of this because:

I'm happy for further advice on this area. But at the moment, a python script that does asynchronous HTTP requests is plenty fast enough.

Anyway the point of this issue was the secondary patterns, and your point is well made. I'll implement in a branch or a particularly interesting primary pattern. Thankyou!