Calling applyPreset() on multiple segments - how do you stop a preset?

I dove in to WLED today and got my project about 95% there. I’ll split up questions in to other topics to keep things tidy.

My system has four segments. I created presets that operate on one or multiple segments. For example, I might have:

  1. Left On and Left Off - apply to segment 1
  2. Right On and Right Off - apply to segment 2
  3. Line On and Line Off - apply to segment 3 and 4
  4. All On and All Off - apply to all four segments

I am triggering patterns using applyPreset(x) based on inputs in the usermod V2 loop. I noticed I can applyPreset(LeftOn) and it starts animating, and if the other input is triggered it runs applyPreset(RightOn) and it animates at the same time – two segments running.

How do I stop a preset? I created the “off” presets to run those, but I’m not sure if this is the appropriate approach.

Thanks for any tips. The idea is someone could use with web UI to assign whatever effects and colors and settings to a present # that the usermod invokes, allowing non-programmers to pick what happens when certain input conditions are met.

I have a long background with embedded C programming, and hobbyist work on Arduinos and such, but don’t know C++ but it’s been fun trying to figure this out :slight_smile:

Can’t help you without seeing actual presets.

Here is an example of a Preset I made, which is intended to only apply to the first segment:

    "50": {
        "on": true,
        "bri": 128,
        "transition": 0,
        "mainseg": 3,
        "seg": [
                "id": 0,
                "start": 0,
                "stop": 108,
                "grp": 1,
                "spc": 0,
                "of": 0,
                "on": true,
                "frz": false,
                "bri": 255,
                "cct": 127,
                "col": [
                "fx": 3,
                "sx": 255,
                "ix": 128,
                "pal": 0,
                "c1": 128,
                "c2": 128,
                "c3": 16,
                "sel": true,
                "rev": true,
                "mi": false,
                "o1": false,
                "o2": false,
                "o3": false,
                "si": 0,
                "m12": 0
        "n": "50-Left"

You cannot “stop” preset. There is no such concept.
You can stop effect playing/animating in either of two ways: turn segment opacity off or freeze segment. The corresponding segment options are “on” and “frz”.

It is enough to send {"seg":[{"id":50,"on":false}]} to turn segment 50 off.

How would I send that from a usermod? Is JSON an http endpoint? This device won’t have any network.

But my understanding now is – only one preset at a time. But a preset can apply to segment 1, which starts the effect. Then you can call a different preset that applies to segment 2, which starts animating. Both go at the same time, until you call a preset that changes them.

Did I get close to understanding?

you don’t. you manipulate WLED state directly.

Applying preset is instantaneous. It is not a continuous action.
Each preset can affect anything JSON API allows it to affect. Each thing individually as specified in JSON.

Applying preset is instantaneous. It is not a continuous action.

When testing this, I had a Preset that turns all my segments off. I wanted to run that to turn all off, before applying a Preset that only turns on one segment. (Special case; usually I just want to leave the others on, but this was coming out of a mode where I wanted to “reset” to all off and start fresh.)


… would not turn everything off. I had to add a millis() timer delay between the two to make it work. I don’t know if it was time, or if it just needed to return form my usermod loop and then re-enter to complete applyPreset() processing.

applyPreset() is asynchronous since 0.14
look two posts above

1 Like

applyPreset() is asynchronous since 0.14
look two posts above

Duh. Thanks. Is there a way to read the status to determine if a preset has been applied, rather than using time and just hoping it’s done by then?

“i’ve been getting those mixed up for over 25 years, so i don’t see what i a need to learn the difference now ;)” - me, sadly