Skip to content

sparse map followed by trailing strip is not supported #5529

Closed

Description

@ttadam

What happened?

Hi there,

My setup is the following:
I have matrix with a sparse map, and a strip. Both are on different pin.
I attached my json file: ledmap (3).json
The matrix is followed by a strip.
However if I want to add new segment for the strip started 756 to 817 (as my map has lot of dummy pixels), it is not allowed, I cannot click on the thick to create a segment.
I found a workaround. extend my strip in the led config settings to 817, and this way I am able to create the segment, But that is unitutive, and I feel I deceived wled, so it is not an intended use case.

To Reproduce Bug

  • upload the attached json
  • create the strips as the image shows. (second stip lenght should be 61 and not 694)
Image - create 2d matrix 28x27 - create a second segment started from 756 to 817. It is not allowed, as the strip starts from 123 if I count in real pixels. but If I set it to 123 the segment box doesnt change to stip mode.

Expected Behavior

I would like to create sparse map matrix followed by a strip.

Install Method

Binary from WLED.me

What version of WLED?

WLED version 17.0.0-dev (But it is the same on other releases as well)

Which microcontroller/board are you seeing the problem on?

ESP32 with ethernet

Relevant log/trace output

Anything else?

Thanks!

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. DedeHai commented on Apr 23, 2026

    @DedeHai
    Collaborator

    Confirmed, the issue is that for trailing to work, total leds currently must be larger than matrix size, which is not fulfilled for sparse setups

  2. blazoncek commented on Apr 25, 2026

    @blazoncek
    Contributor

    FYI that was intentional and by design when I implemented it. KB also mentions tha all LEDS must be accounted for in matrix.

    This is not a bug but request for enhancement.

  3. ttadam commented on Apr 25, 2026

    @ttadam
    Author

    I don't understand.
    To me led & hardware page should be about the physical part of the setup. To be able to use my strip, I have to "fake" the led setup, like I did on the screenshot.
    Also this mixup confuses ledfx, because it thinks that I actually have that amount of pixel.

  4. blazoncek commented on Apr 26, 2026

    @blazoncek
    Contributor

    Indeed you faked it.

    Don't mix WLED's ability to create "fake" matrix using ledmap with what actual matrices are.

    If you think WLED should handle your configuration, please explain how should it do it in the following scenario:

    • 4 outputs configured with 100 LEDSs each
    • ledmap with 25x25 dimensions and 625 entries
    • 4th output is intended to be used as a trailing strip

    IMO if you want to use trailing strip your matrix has to be "full" (populated with LEDs and gapfile used to exclude some LEDs from displaying). Otherwise WLED can't determine which LED is the starting LED for strip.

  5. ttadam commented on Apr 26, 2026

    @ttadam
    Author

    Maybe I am using WLED in a wrong way but if that is the case then tell me how should I configure my setup then.
    I attach few pictures of my setup (party printer), which explains why I want to set it up this way. I know it is not the most serious use case, kinda pointless, but probably wled is not about seriosness. :)
    Am also avaible for short call if that would help to clarify things. Maybe we misscomunicating smth.

    I think LED & Hardware menu section should be about the actual hardware setup, number of physical pixels.
    And the 2D config screen should be where I configure the layout of these pixels and extend with virtual ones as well.
    When I create a new segment after the 2d matrix the limit should be the number of real pixels, but the total number of pixels.

    4 outputs configured with 100 LEDSs each -> This is what I would setup in the LED & Hardware menu
    ledmap with 25x25 dimensions and 625 entries -> I would create the matrixs, in settings, and upload the maps.
    4th output is intended to be used as a trailing strip -> this should start after the last led (which should be higher then the total physical number of LEDs )

    The current issue is that I cannot create segment above the number of physical pixels, even though my setup contains "virtual" pixels as well. The limit should be coming from the total number of pixels, not the physical pixels.

    Image Image Image
  6. DedeHai commented on Apr 29, 2026

    @DedeHai
    Collaborator

    you are not doing anything wrong, it is simply not supported at this point.

  7. deleted a comment from coderabbitai on Jul 9, 2026
  8. deleted a comment from coderabbitai on Jul 9, 2026
  9. DedeHai commented on Jul 9, 2026

    @DedeHai
    Collaborator

    @coderabbitai please check if sparse map with trailing strip can be supported in current structure

  10. coderabbitai commented on Jul 9, 2026

    @coderabbitai
    Contributor
    🧩 Analysis chain

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    rg -n "trailing" --iglob '*.cpp' --iglob '*.h' -i | head -100

    Length of output: 399


    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    echo "pwd:"; pwd
    echo "files:"; fd -e cpp -e h | head -20
    echo "---"
    rg -ni "trailing" -g '*.cpp' -g '*.h' || echo "no matches"

    Length of output: 1093


    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    fd . wled00 -e cpp -e h | xargs grep -l "ledmap\|isMatrix\|Segment::maxWidth\|setUpMatrix" 2>/dev/null | sort -u

    Length of output: 684


    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    grep -n "setUpMatrix\|isMatrix\|customMappingTable\|ledmap\|Segment::maxWidth\|Segment::maxHeight" wled00/FX_fcn.cpp | head -80

    Length of output: 4795


    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    sed -n '1880,2070p' wled00/FX_fcn.cpp

    Length of output: 6952


    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    grep -n "_length\b" wled00/FX_fcn.cpp | head -60

    Length of output: 1184


    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    sed -n '2110,2210p' wled00/FX_fcn.cpp

    Length of output: 4691


    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    grep -rn "customMappingTable\|customMappingSize" wled00/*.cpp wled00/*.h | grep -v FX_fcn.cpp

    Length of output: 1683


    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    sed -n '1,130p' wled00/FX_2Dfcn.cpp

    Length of output: 6231


    Analysis: Can sparse ledmap + trailing strip be supported?

    @DedeHai, confirmed — this can be supported, but it does need a real (if scoped) structural change, not a one-line fix.

    The root cause is exactly what you suspected: WS2812FX::getLengthTotal() in wled00/FX_fcn.cpp (lines 1909-1912) grants trailing-strip addressing only when

    if (isMatrix && _length > len) len = _length; // len = Segment::maxWidth*Segment::maxHeight

    i.e., only when total physical LEDs (_length) exceeds the full logical grid size (width*height). For a sparse setup, _length is smaller than the grid size by design (that's the point of sparsity), so this condition never triggers — the extra bus's LEDs never get exposed as a trailing range.

    This same limitation shows up in two places:

    • WS2812FX::setUpMatrix() (wled00/FX_2Dfcn.cpp, ~lines 20-110): it already tracks a pix counter that counts only the actually-used physical LEDs while walking panels/gaps, skipping -1 gap entries. But the trailing-fill loop (for (i = matrixSize; i < getLengthTotal(); i++) customMappingTable[i] = i;) is keyed off matrixSize (logical cell count), not off pix (actual physical LEDs consumed) — so it never runs when matrixSize >= getLengthTotal().
    • WS2812FX::deserializeMap() (wled00/FX_fcn.cpp, ~lines 2156-2183): for manually uploaded ledmap.json, the mapping buffer is allocated with size getLengthTotal() before the file is read, and entries beyond that are explicitly discarded (if (customMappingSize >= getLengthTotal()) break;). So even a user-crafted map with extra trailing indices gets truncated whenever _length <= matrixSize.

    A feasible fix would decouple "trailing capacity" from the raw _length vs. matrixSize product comparison, and instead base it on "physical LEDs not consumed by the matrix mapping":

    • Persist the pix (used-LED) count from setUpMatrix() as a stored value.
    • Redefine getLengthTotal() as matrixSize + (_length - usedMatrixLeds).
    • Start the identity-mapped trailing range at usedMatrixLeds instead of matrixSize inside setUpMatrix().
    • For manually-uploaded ledmaps, this info isn't known until the file is parsed, so it'd need either a two-pass parse of the map array or an explicit "total length" field in ledmap.json rather than deriving it implicitly.

    This is scoped to FX_fcn.cpp/FX_2Dfcn.cpp addressing logic and doesn't require reworking the segment/bus model overall, so it's a legitimate enhancement rather than a redesign — consistent with it being filed as a feature request rather than a bug.

    Happy to draft a concrete implementation plan if you want to move forward with it.

  11. ttadam commented on Jul 19, 2026

    @ttadam
    Author

    Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions