Mercurial > code > home > repos > light9
view light9/io/udmx.py @ 1541:c1bf296b0a74
collector uses cyclone and gets a web ui showing output attrs
Ignore-this: 6dda48ab8d89344e0c8271429c8175af
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Wed, 17 May 2017 07:39:21 +0000 |
parents | beffbc7f8a6d |
children | 626a79891061 |
line wrap: on
line source
from __future__ import division import logging import usb.core from usb.util import CTRL_TYPE_VENDOR, CTRL_RECIPIENT_DEVICE, CTRL_OUT log = logging.getLogger('udmx') """ Send dmx to one of these: http://www.amazon.com/Interface-Adapter-Controller-Lighting-Freestyler/dp/B00W52VIOS [4520784.059479] usb 1-2.3: new low-speed USB device number 6 using xhci_hcd [4520784.157410] usb 1-2.3: New USB device found, idVendor=16c0, idProduct=05dc [4520784.157416] usb 1-2.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [4520784.157419] usb 1-2.3: Product: uDMX [4520784.157422] usb 1-2.3: Manufacturer: www.anyma.ch [4520784.157424] usb 1-2.3: SerialNumber: ilLUTZminator001 See https://www.illutzmination.de/udmxfirmware.html?&L=1 sources/commandline/uDMX.c or https://github.com/markusb/uDMX-linux/blob/master/uDMX.c """ cmd_SetChannelRange = 0x0002 class Udmx(object): def __init__(self): self.dev = usb.core.find(idVendor=0x16c0, idProduct=0x05dc) log.info('found udmx at %r', self.dev) def SendDMX(self, buf): ret = self.dev.ctrl_transfer( bmRequestType=CTRL_TYPE_VENDOR | CTRL_RECIPIENT_DEVICE | CTRL_OUT, bRequest=cmd_SetChannelRange, wValue=len(buf), wIndex=0, data_or_wLength=buf) if ret < 0: raise ValueError("ctrl_transfer returned %r" % ret) def demo(chan, fps=44): import time, math u = Udmx() while True: nsin = math.sin(time.time() * 6.28) / 2.0 + 0.5 nsin8 = int(255 * nsin) try: u.SendDMX('\x00' * (chan - 1) + chr(210) + chr(nsin8) + chr(nsin8) + chr(nsin8)) except usb.core.USBError as e: print "err", time.time(), repr(e) time.sleep(1 / fps)