Configuring WLED to wipe-on the LEDs on startup

Posted on Wed 22 November 2023 in electronics

WLED is an open source project for controlling LED-strips. I wanted my LED strip to "wipe on" when powering on, similar to the first half of the "Wipe" effect, but staying on after that. These are my notes.

Searching around for similar idea's, I found a usermod for a stairway. That module did much more than I needed, but it got me started. In the end, it looked like my desired effect was possible using Presets and Playlist.

I created two presets, a "wipe" and a "solid", and chained these together with a playlist. The playlist has a single entry, the "wipe" preset, and is configured to not repeat, and end on the "solid" preset. Getting the timing right was a bit of a journey: I needed to convert "effect speed" into "seconds to halfway". Luckily, open source code makes things easy. The source code shows the used formula: cycleTime = 750 + (255 - SEGMENT.speed)*150. This means that a speed of 253 gives a cycleTime of 1050ms. So by setting the playlist duration of the wipe preset to 0.5 seconds, I got the desired result.

Another thing to fix is that I wanted the wipe animation to always start at the beginning. This can be fixed by including "tb": 0 in the preset JSON.

Note that you want do disable the Turn LEDs on after power up/reset. When you leave this on, the LEDs first go to on, and only then start the animation.

For reference, here is the relevant part of my preset.json:

{
  "2":{
    "on":true,"bri":255,"transition":0,"tb":0,"mainseg":0,
    "seg":[
      {"id":0,"start":0,"stop":271,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"col":[[100,0,152,255],[0,0,0,0],[0,0,0,0]],"fx":3,"sx":253,"ix":128,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},
      {"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0}
    ],
    "n":"wipe"
  },
  "3":{
    "on":true,"bri":255,"transition":0,"mainseg":0,
    "seg":[
      {"id":0,"start":0,"stop":271,"grp":1,"spc":0,"of":0,"on":true,"frz":false,"bri":255,"cct":127,"set":0,"col":[[100,0,152,255],[0,0,0,0],[0,0,0,0]],"fx":0,"sx":16,"ix":108,"pal":0,"c1":128,"c2":128,"c3":16,"sel":true,"rev":false,"mi":false,"o1":false,"o2":false,"o3":false,"si":0,"m12":0},
      {"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0},{"stop":0}
    ],
    "n":"default on"
  },
  "1":{
    "playlist":{"ps":[2],"dur":[5],"transition":[0],"repeat":1,"end":3,"r":0},"on":true,
    "n":"power on animation"
  }
}