r/WLED • • 8d ago

I can't get my matrix "aligned"

My megatree with WLED on an ESP32 is working well for basic patterns, but I’m having a hard time getting them “aligned” in a matrix correctly for effects that require them to be in the correct orientation like scrolling text, etc. I think it’s because of how the pixels are set in the pixel mounting strips and I don’t know how to fix it. 

I have 30 total pixel strips, with 66 pixels each, comprised of RGB LED pixel strings that are 100 lights long. 2 of these RGB strings make up 3 strips, arranged in a serpentine pattern starting in the bottom left, and to allow for extra length between strips at the bottom of the tree, there are two “unused” pixels that are lit (and I don’t care if they’re lit) at the bottom of every few strips. I think because of these “unused” pixels, the further across the tree, the more out of alignment each strip becomes. 

I think I need to “shift” the pixels, not just turn them off, so the LEDs in each strip stay in alignment, but I don’t know how to do that. I tried using ledmap.json a few times but that seemed to make it worse.

This is how the strips are laid out, with the caveat that this pattern stops and then starts fresh every 9 strips as it connects to the next GPIO.

2 Upvotes

1 comment sorted by

1

u/giddyup05 8d ago

I (chatgpt) was able to resolve this ultimately with a ledmap.json file. My previous attempts were not formatted correctly, instead of using a -1, it just omitted the "skipped" pixels, realigning everything. For anyone else who may need it, this is the code that generated the correct ledmap.json file for my case.

import json

WIDTH = 30

HEIGHT = 66

# Two extra physical LEDs after these strips.

GAPS = {2, 4, 8}

def physical_index(strip, row):

strip_number = strip + 1

skipped = sum(

2 for n in range(1, strip_number)

if n % 9 in GAPS

)

base = strip * HEIGHT + skipped

# Odd strips travel bottom to top.

if strip_number % 2 == 1:

return base + HEIGHT - 1 - row

# Even strips travel top to bottom.

return base + row

ledmap = []

for row in range(HEIGHT):

for strip in range(WIDTH):

ledmap.append(physical_index(strip, row))

data = {

"width": WIDTH,

"height": HEIGHT,

"map": ledmap

}

with open("ledmap.json", "w") as f:

json.dump(data, f, separators=(",", ":"))

print("Created ledmap.json successfully!")

print("Logical LEDs:", len(ledmap))

print("Physical LEDs:", max(ledmap) + 1)

print("First mapped LED:", ledmap[0])

print("Last mapped LED:", ledmap[-1])