Skip to content

Instantly share code, notes, and snippets.

@yyuemii
Created June 30, 2023 07:27
Show Gist options
  • Save yyuemii/ed30f5d0a1ead7c98059329b4a3c3aea to your computer and use it in GitHub Desktop.
Save yyuemii/ed30f5d0a1ead7c98059329b4a3c3aea to your computer and use it in GitHub Desktop.
python script that controls a neopixel led strip over artnet
import board
import neopixel
from stupidArtnet import StupidArtnetServer
PIXELS_PER_UNIVERSE = 170 # do not change this! how many pixels each universe can fully support
UNIVERSE_TOTAL = 2 # how many universes it takes to show all pixels (todo: do this programatically)
PIXEL_COUNT = 300 # total amount of pixels driven by neopixel
UNIVERSES = {}
artnet = StupidArtnetServer()
pixels = neopixel.NeoPixel(board.D18, PIXEL_COUNT, auto_write=False, brightness=0.5)
for i in range(UNIVERSE_TOTAL):
UNIVERSES[i] = artnet.register_listener(i)
while True:
for u in range(UNIVERSE_TOTAL):
buff = artnet.get_buffer(UNIVERSES[u])
if len(buff) == 0:
continue
for i in range(PIXELS_PER_UNIVERSE):
pixel = (u * PIXELS_PER_UNIVERSE) + i
read = i * 3
if (pixel >= PIXEL_COUNT):
break
pixels[pixel] = (buff[read], buff[read+1], buff[read+2])
pixels.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment