Segments
If you learn one WLED idea properly, make it this one. A segment is a named stretch of your LEDs — a start, a stop, and its own colour, effect, palette and brightness. Segments are what turn "a strip" into "the shelf lighting, the under-cabinet run, and the bit behind the TV", all on one controller, all at once.
The model
Every output you configure is one long line of LEDs. Segments divide that line into ranges: LEDs 0–49 might be one segment, 50–119 another. Each segment carries its own:
- effect and its speed/intensity (chapter 9),
- palette and up to three colours,
- brightness of its own, multiplied by the master brightness,
- direction (reverse), mirror, and an on/off switch of its own.
Segments may overlap; where they do, the later segment wins the LEDs it covers. A segment can also repeat its pattern with grouping (treat every n LEDs as one fat pixel) and spacing (dark gaps between the groups) — the trick behind turning a dense strip into chunky retro pixels.
The state object the API exchanges (chapter 11) shows a segment exactly as the firmware stores it — read from the code that writes it:
{ "id": 0, "start": 0, "stop": 60, "len": 60,
"on": true, "bri": 255,
"col": [[255, 160, 40], [0, 0, 0], [0, 0, 0]],
"fx": 0, "sx": 128, "ix": 128, "pal": 0,
"sel": true, "rev": false, "mi": false }
fx is the effect number, sx/ix
its speed and intensity, pal the
palette, col the three colour slots.
There are more keys in the real object
(grouping, spacing, offset, freeze, and
friends — the lab notes in wled-lab/
list them all), but these are the ones
you will actually touch.
How many, and what they cost
The documentation puts the ceiling at 16 segments on ESP8266 and 32 on ESP32 (up to 64 on ESP32 boards with PSRAM). The count is not free: every segment's effect is computed every frame, so sixteen busy segments on an ESP8266 is a real workload. In practice most installs use two to six. One related number to know before designing a palace: presets (chapter 10) save the whole segment layout, so a well-named set of segments is a design you only make once.
Working with segments in the UI
On the control page, the Segments area
lets you add a segment, set its start
and stop by number, name it (n in the
JSON — names survive, numbers blur),
tick which segments the colour and
effect controls are editing, and switch
segments on and off individually. The
habit worth forming early: name your
segments when you create them, and
save the layout as a preset before you
start experimenting. The experiment you
like at midnight is unrecoverable at
breakfast without one.
Two-dimensional segments
On a matrix panel, segments gain a
second axis — the state object grows
startY/stopY alongside start/
stop — and a family of 2D effects
(their names start with "2D") plays on
the grid. The arrangement of panels
themselves (serpentine wiring, panel
order) is set on the settings_2D.htm
page. Everything else in this chapter —
one state per segment, presets save it
all — works the same in two dimensions.