I had just built a custom RGB LED strip (WS2812B) out of 126 LEDs and an ESP8266 running WLED. I wanted to set it up for screen ambience. I wasn't real happy with the default LED zone options in Prismatik Lightpack and couldn't get it just right. So I made a script to automate creating zones out of my display dimensions and how many LEDs are assigned on each side.
Created
October 4, 2024 05:01
-
-
Save V3ntus/ab93112ddbf265aea33287339f9b223a to your computer and use it in GitHub Desktop.
Prismatik Lightpack - LED zone generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monitor dimensions | |
HEIGHT: float = 1440.0 | |
WIDTH: float = 3440.0 | |
# Zone thickness from edges in percent of screen real-estate | |
VERTICAL_THICKNESS: float = 0.3 # Used to calculate width of zones going vertically (sides) | |
HORIZONTAL_THICKNESS: float = 0.15 # Used to calculate height of zones going horizontally (top/bottom) | |
# Number of LEDs per edge | |
LEDS: int = { | |
"B": 43, | |
"L": 20, | |
"T": 43, | |
"R": 20, | |
} | |
TOTAL_LEDS: int = sum(LEDS.values()) | |
# Zone size and position calculations | |
ZONES = { | |
"B": { | |
"W": WIDTH / LEDS["B"], | |
"H": HEIGHT * HORIZONTAL_THICKNESS, | |
}, | |
"L": { | |
"W": WIDTH * VERTICAL_THICKNESS, | |
"H": HEIGHT / LEDS["L"], | |
}, | |
"T": { | |
"W": WIDTH / LEDS["T"], | |
"H": HEIGHT * HORIZONTAL_THICKNESS, | |
}, | |
"R": { | |
"W": WIDTH * VERTICAL_THICKNESS, | |
"H": HEIGHT / LEDS["R"], | |
}, | |
} | |
LED_MIXIN = """IsEnabled=true | |
CoefRed=1 | |
CoefGreen=0.66 | |
CoefBlue=0.34""" | |
# Starting from the bottom right corner of my monitor and going clockwise... | |
for INDEX in range(1, TOTAL_LEDS + 1): | |
# Bottom array | |
if INDEX <= LEDS["B"]: | |
print(f""" | |
[LED_{INDEX}] | |
{LED_MIXIN} | |
Position=@Point({int(WIDTH - (INDEX * ZONES["B"]["W"]))} {int(HEIGHT - ZONES["B"]["H"])}) | |
Size=@Size({int(ZONES["B"]["W"])} {int(ZONES["B"]["H"])}) | |
""") | |
# Left array | |
elif INDEX <= (LEDS["B"] + LEDS["L"]): | |
LEDS_SO_FAR = LEDS["B"] | |
print(f""" | |
[LED_{INDEX}] | |
{LED_MIXIN} | |
Position=@Point(0 {int(HEIGHT - ((INDEX - LEDS_SO_FAR) * ZONES["L"]["H"]))}) | |
Size=@Size({int(ZONES["L"]["W"])} {int(ZONES["L"]["H"])}) | |
""") | |
# Top array | |
elif INDEX <= (LEDS["B"] + LEDS["L"] + LEDS["T"]): | |
LEDS_SO_FAR = LEDS["B"] + LEDS["L"] | |
print(f""" | |
[LED_{INDEX}] | |
{LED_MIXIN} | |
Position=@Point({int((INDEX - LEDS_SO_FAR - 1) * ZONES["T"]["W"])} 0) | |
Size=@Size({int(ZONES["T"]["W"])} {int(ZONES["T"]["H"])}) | |
""") | |
# Right array | |
elif INDEX <= (LEDS["B"] + LEDS["L"] + LEDS["T"] + LEDS["R"]): | |
LEDS_SO_FAR = LEDS["B"] + LEDS["L"] + LEDS["T"] | |
print(f""" | |
[LED_{INDEX}] | |
{LED_MIXIN} | |
Position=@Point({int(WIDTH - ZONES["R"]["W"])} {int((INDEX - LEDS_SO_FAR - 1) * ZONES["R"]["H"])}) | |
Size=@Size({int(ZONES["R"]["W"])} {int(ZONES["R"]["H"])}) | |
""") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's what the output looks like:

As said in the code, my LED strip starts at the bottom right corner of my monitor and works its way up clockwise.