#!/usr/bin/python3 import sys import json import subprocess from time import sleep from PyDMXControl.controllers import OpenDMXController from PyDMXControl.profiles.Generic import Dimmer # python3 playchannel.py channeltest = sys.argv[1] # 0-255 dim / brightness range # fadein, fadeout in milliseconds brightness = 15 fadein = 1000 fadeout = 1000 data = json.load(open('sequence.json')) print("\n * Reset USB device") subprocess.call(['usbreset', "FT232R USB UART"]) print("\n ** DMX start...") dmx = OpenDMXController() ## sort by "channel" -> channel/line number lines = sorted(data, key=lambda x: x["channel"]) ## remove dupes and add lights once in this order channels = [] for l in lines: if l['channel'] not in channels: channels.append(l['channel']) line = dmx.add_fixture(Dimmer, name=l['channel']) #print("\nAll channels:") #print(channels) #dmx.web_control() c = [ i for i in lines if i["channel"] == channeltest ] print(f"\n - Play channel: {channeltest}") print("\nSequence JSON entry:") print(c) print(f"fadein: {fadein}") print(f"fadeout: {fadeout}") try: line = dmx.get_fixtures_by_name(channeltest)[0] line.dim(brightness, fadein) print("\n -*- Press Ctrl-C to stop...\n") sleep(1000) except KeyboardInterrupt: line.dim(0, fadeout) sleep(fadeout/1000 + 1) dmx.close() print() sys.exit() print()