Created
May 15, 2019 05:23
-
-
Save cagerton/210b21d0fce81a61e80a028abbe2d156 to your computer and use it in GitHub Desktop.
Simple example for using udmx to control a monoprice rgbaw-uv dmx light
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
""" | |
Simple rgb color fade tested with the monoprice rgbawuv | |
Requires python3.7 for the async coroutine syntax; should be trivial to backport though | |
Requires: | |
libusb==1.0.22b4 | |
numpy==1.16.3 | |
pyusb==1.0.2 | |
scikit-image==0.15.0 | |
udmx-pyusb==2.0.0 | |
""" | |
import asyncio | |
from pyudmx import pyudmx | |
from skimage import color | |
async def make_colors(): | |
for idx in range(20): | |
for hue in range(0, 255, 1): | |
yield color.hsv2rgb([[[hue/255., 1., 1.]]])[0][0] | |
await asyncio.sleep(0.02) | |
async def main(): | |
device = pyudmx.uDMXDevice() | |
if not device.open(): | |
raise RuntimeError("didn't open device") | |
async for rgb in make_colors(): | |
dmxvals = [int(255 * val) for val in rgb] + [0] * 8 | |
print(f'sending {dmxvals}') | |
device.send_multi_value(channel=1, values=dmxvals) | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment