Two buttons and three segments switching

Hi there,

I have a little problem here. I have a rather long strip of 101 (meh) LEDs that I want to control with two buttons. My idea:
segment 0: from 0 to 31
segment 1: from 31 to 70
segment 2: from 70 to 101

button 1 short press toggles segment 0 on/off (without affecting the other segments)
button 1 double press toggles all segments on/off (all pre-press off are now on, all pre-press on stay on)

button 2 as button 1 just with segment 2 instead of segment 0.

I tried to appl Push button for each segment, but that does not really work well with the double press.
I tried to fiddle around with removing the segments in the presets I created, but that does not work either, as I seem to run into issues. Most of the time the preset turns on the correct segment (e.g. 0), but if the other segment (in this case 2) is on then seg 2 turns off.

Any ideas. I am really lost here, but I guess it is possible.

Thank you so much

To toggle segments cant you do something like that
{“seg”:{“id”:0,“on”:“t”}}
{“seg”:{“id”:1,“on”:“t”}} …etc

2 Likes

Exactly as @ALDIY said.
Create custom presets by entering JSON API instead of saving state.

Use API reference in KB.

BTW: A small correction to ALDIY’s API. You need to enclose multiple segments in square braces like:
{"seg":[{"id":0,....},{"id":1,....}]}

1 Like

Thanks. I will take a look what I can do. Looking at the reference I think this bit me in the butt

sel bool true if the segment is selected. Selected segments will have their state (color/FX) updated by APIs that don’t support segments (e.g. UDP sync, HTTP API). If no segment is selected, the first segment (id:0) will behave as if selected. WLED will report the state of the first (lowest id) segment that is selected to APIs (HTTP, MQTT, Blynk…), or mainseg in case no segment is selected and for the UDP API. Live data is always applied to all LEDs regardless of segment configuration.

I was already using the API call instead of state :wink:

Good for you. :wink:

Okay, it is working now.

What I did:
I have 4 presets:
21: Toggles segment 0 with the “t” option and turns segment 1 off “on”:false
31: Toggles segment 2 with the “t” option and turns segment 1 off “on”:false
41: Turns on segments 0, 1, 2
42: Turns off segments 0, 1, 2

If all segments are on, then presets 21 and 31 individually will leave the not adressed segment on, but that is okay.

Thanks for your help.

In German we say: “Schon macht man es richtig, dann funktioniert es!” roughly translates to: “As soon as you do it correctly, it works!”