Upload easly a new effect

Hi, maybe this was already discussed, I think Wled is really a top project for led stripes, with all its features it’s much more than anyone can imagine…
it just misses a way to upload easly a new effect, probably taking advance of the internal flash of the board (for example Wemos mini has 4MB), adding this feature in my opinion will boost up the popularity involving more and more people, more effect developers, and sharing effects, beautiful.
It also helps to debug and improve more quickly the effect itself.
Upload from Wled web like for OTA is a good idea in my opinion, or maybe by FTP too… it just be necessary to define a file format. To avoid wled check for syntax and compile you may decide to use Arduino IDE for it, somehow. Maybe it can be necessary to define a new “virtual board” which instruct IDE how to compile it, without include what it’s already present in Wled,making the result smaller to upload.
Thank you for your kind attention

AirCookie posted a survey a while back that indicated he wanted to build something to let users create their own effects, possibly even a live effect editor.

this is what will push Wled to the sky :slight_smile:

How would you “describe” effects?

The different led programs, defined under “effects” tab of Wled app, for example Solid, Android, Aurora…

Right, but what sort of language/format would be used to define the effects?

A couple of ideas: If there is a standard already, for example another project similar wled, then it will be smart to take advance of that work… and chances are many effects can be already available.
Another choice may be write them in Arduino IDE language compatible, in this way it would be possible to compile it on IDE filtering all possible mistakes. The trick may be, if it’s not complicated, to create a “Wled board”, with all features/limitations the programmer should respect when generating effects.

The tool would need to define some mathematical equation for each of the available adjustments for each effect:

  • how effect changes with time
  • how brightness changes with time
  • how colors change with time

Then how the various WLED adjustments interact with the effect. How do adjustments for speed, brightness, intensity vary the effect. Is it 0-100% linear, or non-linear in some way, or some other way?

As far as the effect math, the “WLED effect builder tool” might use things like “number of pixels for base effect = xxxx”, “effect repeats ? Y | N”, “blank pixels between effect repeats = 0, 1, 2…”, “color / brightness / speed shift for repeated sections”, which could then generate effect logic suitable for importing as a json blob.

Just random thoughts, since you asked.

IMO anything that can be orchestrated using GUI tools is going to be:

  • bloated consuming a lot of flash/RAM memory
  • useless and replicated more efficiently in C/C++ code

If you are talking switching from C/C++ code to some other language, then my answer is simple: C is one of the simplest languages with clear and straightforward logic. If you are a programmer then it will be easy to convert JS, Python or any other language to C/C++.

The problem I can see with current state of FX development is lack of information of what certain variable and/or function does. Including FastLED, NeoPixelBus and other librarires used for FX creation.

In my opinion the most difficult part for wled will be to check the effect code to avoid any problems, an uncorrect code may compromise the work and settings of the actual installation, or siply loose control of it. Develope those checks needs time, occupy space on ESP and cpu resources, for this reason it’s desiderable to compile and check it externally, IDE environment is familiar, it has ESP libraries and probably enought for a good result.

How FastLED NeoPixelBus manage new effects?

1 Like

They don’t, they are just libraries.

  1. You could already write effects in the source code and then compile a new bin and upload via OTA. So I assume we aren’t talking about that. There is plenty of interesting solutions if we are talking about making that easier. The yaml/lambda functions in ESPHome are a good example. But even making a clean stub and guide for making new patterns would be fun. Maybe a tool that could build the patterns you created into a simulator/emulator ao I don’t have to sit outside to test them.

  2. There is a solution similar to the turtle language. Where comands would be in plain text. Things like rotate, setBrightness, setColor would be obvious. But you have to have a pretty extensive language to support stuff like sin(total_leds / 3 * 2 * pi) Look at this site for an example of turtle:

This also feels similar to micropython, which would be very hard to replicate in the wled, I think.

  1. It sounds like some of you are advocating for writing in C, compiling (and by compiling, I am including other steps in C/C++, like linking) it, and then uploading it to the esp via the web interface. The challenges I see to this approach are:
  • The memory and bloat of having the compiler built into the web interface. If this was only possible on an internet connected WLED, then we could load the compiler client side, from a resource on the web.
  • There are plenty of security problems. Any pointer can point to anywhere and change the code. It would be nearly impossible to sanitize a binary blob from the client. It would need at least the same security as the OTA upload. I would also hate if I accidentally broke the ability to flash via OTA, or worse, if I affected the bootloader.
  • There are functions the code needs to call, and those may be in different places on different builds or versions of WLED. If your C code called getSegmentLength(), that function may be at address X or Y in the flash. How would the compiler (well, the linker) know where that function was in the binary on the esp, from a compiler in memory on the client?
  • After we have saved this blob to the esp, can we even execute it? Will the esp let us execute code stored in the eeprom?
1 Like