def main_artsync(universe1, universe2, ip='127.0.0.1', tmp=0.5): target_ip = ip packet_size = 512 port = 6454 a1 = StupidArtnet(target_ip, port, universe1, packet_size) a2 = StupidArtnet(target_ip, port, universe2, packet_size) anim = Animation(filename, a1, a2) anim.anime_artsync(Animation.anime_1, tmp)
def main_no_artsync(universe1, universe2, ip1='127.0.0.1', ip2='127.0.0.1', tmp=0.5): packet_size = 512 port = 6454 a1 = StupidArtnet(ip1, port, universe1, packet_size) a2 = StupidArtnet(ip2, port, universe2, packet_size) anim = Animation(filename, a1, a2) anim.anime_noartsync(Animation.anime_1, tmp)
def main_artsync(universe, ip='127.0.0.1', nb_packet=50, tmp=5): packet_size = 512 port = 6454 a = StupidArtnet(ip, port, universe, packet_size) a.flash_all() # send single packet with all channels at 255 file.write(StupidArtnet.print_object_and_packet(a)) a.start_artSync(nb_packet) time.sleep(tmp) a.stop_artSync()
def main_artsync(universe1, universe2, ip='127.0.0.1', tmp=5, nb_packet=50): packet_size = 512 port = 6454 a1 = StupidArtnet(ip, port, universe1, packet_size) a2 = StupidArtnet(ip, port, universe2, packet_size) a1.flash_all() # send single packet with all channels at 255 a2.flash_all() file.write(StupidArtnet.print_object_and_packet(a1)) file.write(StupidArtnet.print_object_and_packet(a2)) group = ArtNetGroup(a1, a2) group.start(True) time.sleep(tmp) group.stop()
def main_artsync(universe, start_channel, end_channel, ip='127.0.0.1', tmp=5): target_ip = ip packet_size = 512 port = 6454 a = StupidArtnet(target_ip, port, universe, packet_size) packet = Animation.anime_2(packet_size, start_channel, end_channel) a.set(packet[0]) file.write(StupidArtnet.print_object_and_packet(a)) group = ArtNetGroup(a) group.start(True) time.sleep(tmp) group.stop() group.set(bytearray(512)) group.show(True)
def main_artsync(universe1, universe2, ip1='127.0.0.1', ip2='127.0.0.2', slp=5): packet_size = 512 port = 6454 a1 = StupidArtnet(ip1, port, universe1, packet_size) a2 = StupidArtnet(ip2, port, universe2, packet_size) a1.flash_all() # send single packet with all channels at 255 a2.flash_all() file.write(StupidArtnet.print_object_and_packet(a1)) file.write(StupidArtnet.print_object_and_packet(a2)) group = ArtNetGroup(a1, a2) group.show(True)
def main_artsync(universe, ip='127.0.0.1', tmp=5, pause=5): target_ip = ip packet_size = 512 port = 6454 a = StupidArtnet(target_ip, port, universe, packet_size) anim = Animation(filename, a) anim.anime_pause_artsync(Animation.anime_1, tmp, pause)
def main_no_artsync(universe, ip='127.0.0.1'): target_ip = ip packet_size = 512 port = 6454 a = StupidArtnet(target_ip, port, universe, packet_size) a.flash_all() # send single packet with all channels at 255 file.write(StupidArtnet.print_object_and_packet(a)) a.show()
def main_artsync(universe, start_channel, end_channel, ip='127.0.0.1', tmp=0.5): target_ip = ip packet_size = 512 port = 6454 a = StupidArtnet(target_ip, port, universe, packet_size) anim = Animation(filename, a) anim.anime_artsync(Animation.anime_2, tmp, start_channel, end_channel)
def main_artsync(universe, ip='127.0.0.1', slp=5): target_ip = ip packet_size = 512 port = 6454 sync = StupidArtSync(ip) a = StupidArtnet(target_ip, port, universe, packet_size) a.flash(255) # send single packet with all channels at 255 file.write(StupidArtnet.print_object_and_packet(a)) sync.send() a.show() sync.send()
def __init__(self, *args, **kwargs): if Pinspots.instance != None: raise Exception( "Error: Class is Singleton - Use getPinspotWorld()") else: Pinspots.instance = self super().__init__(*args, **kwargs) config = Config.getConfig() # Get channels for fixture with open("profiles/" + config["fixtureType"] + ".json", 'r') as p: self.profile = json.load(p) # Important constants - currently from config, eventually from fixture profile self.controllerIP = config["enodeIP"] self.numUniverses = config["numUniverses"] self.numPinspots = config["numFixtures"] self.bytesPerPacket = config["channelsPerPacket"] self.bytesPerFixture = self.profile["channelCount"] self.fixturesPerUniverse = config["fixturesPerUniverse"] # Create bytearrays for each universe's status self.universe_arrays = list() for x in range(self.numUniverses): self.universe_arrays.append(bytearray(self.bytesPerPacket)) # Create universes using StupidArtnet(eNode IP Address, universe, packet size) self.universes = list() for x in range(self.numUniverses): self.universes.append( StupidArtnet(self.controllerIP, x, self.bytesPerPacket)) # Print universe for testing print(self.universes[x]) # Start universe self.universes[x].start() # Reset lights self.reset()
from lib.StupidArtnet import StupidArtnet import time import random # THESE ARE MOST LIKELY THE VALUES YOU WILL BE NEEDING target_ip = '192.168.1.10' # typically in 2.x or 10.x range universe = 0 # see docs packet_size = 100 # it is not necessary to send whole universe # CREATING A STUPID ARTNET OBJECT # SETUP NEEDS A FEW ELEMENTS # TARGET_IP = DEFAULT 127.0.0.1 # UNIVERSE = DEFAULT 0 # PACKET_SIZE = DEFAULT 512 # FRAME_RATE = DEFAULT 30 a = StupidArtnet(target_ip, universe, packet_size) # MORE ADVANCED CAN BE SET WITH SETTERS IF NEEDED # NET = DEFAULT 0 # SUBNET = DEFAULT 0 # CHECK INIT print(a) # YOU CAN CREATE YOUR OWN BYTE ARRAY OF PACKET_SIZE packet = bytearray(packet_size) # create packet for Artnet for i in range(packet_size): # fill packet with sequential values packet[i] = (i % 256) # ... AND SET IT TO STUPID ARTNET a.set(packet) # only on changes
from lib.StupidArtnet import StupidArtnet import datetime import time from MQTT import MQTT_start from switch import getRGB MQTT_start() target_ip = '192.168.1.230' # typically in 2.x or 10.x range packet_size = 512 a = StupidArtnet(target_ip, 0, 512) print(a) # YOU CAN CREATE YOUR OWN BYTE ARRAY OF PACKET_SIZE packet = bytearray(packet_size) # create packet for Artnet for i in range(packet_size): # fill packet with sequential values packet[i] = (i % 256) # ... AND SET IT TO STUPID ARTNET a.set(packet) # only on changes w, h = 21, 8 Matrix = [[0 for x in range(w)] for y in range(h)] t1 = [[0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 1, 0], [1, 0, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0], [0, 1, 1, 1]] t2 = [[0, 0, 0, 0], [0, 1, 1, 0], [1, 0, 0, 1], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]] t3 = [[0, 0, 0, 0], [0, 1, 1, 0], [1, 0, 0, 1], [0, 0, 0, 1], [0, 1, 1, 0], [0, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]] t4 = [[0, 0, 0, 0], [1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1], [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]]
from lib.StupidArtnet import StupidArtnet from lib.ArtNetGroup import ArtNetGroup import time ledstrip_data = [[[(0, 0), (0, 81), (0, 162)]], [], [], [], [], []] print(ledstrip_data[0][0][1][1] + 12) port = 6454 ip = '192.168.0.50' group = ArtNetGroup() tab_parabole = [] for x in range(150): tab_parabole.append(int(-x * (x - 255) / 63.75)) for i in range(100): a = StupidArtnet(ip, port, i) a.flash_all() group.add(a) group.start(False) time.sleep(30) flash = True for d in range(5): for i in group.listArtNet: if flash: i.blackout() else: i.flash_all() flash = not flash time.sleep(2)
def main(universe, ip='127.0.0.1'): target_ip = ip packet_size = 512 port = 6454 a = StupidArtnet(target_ip, port, universe, packet_size) a.blackout()
def main_no_artsync(universe1, universe2, ip1='127.0.0.1', ip2='127.0.0.2', tmp=5): packet_size = 512 port = 6454 a1 = StupidArtnet(ip1, port, universe1, packet_size) a2 = StupidArtnet(ip2, port, universe2, packet_size) a1.flash_all() # send single packet with all channels at 255 a2.flash_all() file.write(StupidArtnet.print_object_and_packet(a1)) file.write(StupidArtnet.print_object_and_packet(a1)) a1.start() a2.start() time.sleep(tmp) a1.stop() a2.stop()
def main(): a = StupidArtnet(ip, universe, packet_size) packet = bytearray(packet_size) # create packet for Artnet vu = bytearray(int(packet_size / CHANNELS)) # create initial part of a VU # red for i in range(45, 50): # TODO: CHANNELS vu[3 * i + 0] = 255 # yellow for i in range(30, 45): # TODO: CHANNELS vu[3 * i + 0] = 255 vu[3 * i + 1] = 128 # green for i in range(0, 30): # TODO: CHANNELS vu[3 * i + 1] = 255 stream = False audio = pyaudio.PyAudio() #device_index = find_input_device(audio) try: stream = audio.open( format=pyaudio.paInt16, channels=CHANNELS, rate=RATE, input=True, output=True, #input_device_index = 0,#device_index, frames_per_buffer=INPUT_FRAMES_PER_BLOCK) while True: block = stream.read(INPUT_FRAMES_PER_BLOCK) left, right = get_rms(block, CHANNELS) left /= THRESHOLD right /= THRESHOLD if (left > 1): left = 1 if (right > 1): right = 1 asciil = (" " * int(10 - left * 10)) + ("#" * int(left * 10)) asciir = ("#" * int(right * 10) + (" " * int(10 - right * 10))) print("[{0}][{1}]\r".format(asciil, asciir), end="") left = int(left * ledAmount / CHANNELS) right = int(right * ledAmount / CHANNELS) for i in range(0, int(ledAmount / CHANNELS)): packet[147 - 3 * i] = vu[3 * i + 0] if i <= left else 0 packet[148 - 3 * i] = vu[3 * i + 1] if i <= left else 0 packet[149 - 3 * i] = vu[3 * i + 2] if i <= left else 0 for i in range(0, int(ledAmount / CHANNELS)): packet[3 * i + 150] = vu[3 * i + 0] if i <= right else 0 packet[3 * i + 151] = vu[3 * i + 1] if i <= right else 0 packet[3 * i + 152] = vu[3 * i + 2] if i <= right else 0 a.set(packet) a.show() finally: if (stream): stream.stop_stream() stream.close() audio.terminate()
from PIL import ImageDraw from PIL import ImageFont import io # THESE ARE MOST LIKELY THE VALUES YOU WILL BE NEEDING target_ip = '192.168.178.81' # typically in 2.x or 10.x range universe = 0 # see docs packet_size = 300 # it is not necessary to send whole universe # CREATING A STUPID ARTNET OBJECT # SETUP NEEDS A FEW ELEMENTS # TARGET_IP = DEFAULT 127.0.0.1 # UNIVERSE = DEFAULT 0 # PACKET_SIZE = DEFAULT 512 # FRAME_RATE = DEFAULT 30 a = StupidArtnet(target_ip, universe, packet_size) # MORE ADVANCED CAN BE SET WITH SETTERS IF NEEDED # NET = DEFAULT 0 # SUBNET = DEFAULT 0 # CHECK INIT print(a) packet = bytearray(packet_size) # create packet for Artnet fnt4 = ImageFont.truetype('small_pixel.ttf', 4) fnt5 = ImageFont.truetype('small_pixel.ttf', 5) fnt6 = ImageFont.truetype('small_pixel.ttf', 6) fnt7 = ImageFont.truetype('small_pixel.ttf', 7) fnt8 = ImageFont.truetype('small_pixel.ttf', 8)
def write_file(self, file): [ file.write(StupidArtnet.print_object_and_packet(i)) for i in self.listArtNet ]
h60f = math.floor(h60) hi = int(h60f) % 6 f = h60 - h60f p = v * (1 - s) q = v * (1 - f * s) t = v * (1 - (1 - f) * s) r, g, b = 0, 0, 0 if hi == 0: r, g, b = v, t, p elif hi == 1: r, g, b = q, v, p elif hi == 2: r, g, b = p, v, t elif hi == 3: r, g, b = p, q, v elif hi == 4: r, g, b = t, p, v elif hi == 5: r, g, b = v, p, q r, g, b = int(r * 255), int(g * 255), int(b * 255) return (r, g, b) for x in range(0, 128): colorvalue = getHsvColor(x) rgb = hsvToRgb(colorvalue, param.hsvSaturation, param.hsvValue) print("Theremin value: %i HSV value: %9.5f RGB: %s" % (x, colorvalue, rgb)) packet_size = param.fixtures * param.fixtureChannels a = StupidArtnet(param.target_ip, param.universe, packet_size) packet = bytearray(packet_size) # create packet for Artnet
def main_no_artsync(universe1, universe2, ip='127.0.0.1'): packet_size = 512 port = 6454 a1 = StupidArtnet(ip, port, universe1, packet_size) a2 = StupidArtnet(ip, port, universe2, packet_size) a1.flash_all() # send single packet with all channels at 255 a2.flash_all() file.write(StupidArtnet.print_object_and_packet(a1)) file.write(StupidArtnet.print_object_and_packet(a2)) a1.show() a2.show()
def main_artsync(universe1, universe2, ip='127.0.0.1', slp=5): packet_size = 512 port = 6454 sync = StupidArtSync(ip) a1 = StupidArtnet(ip, port, universe1, packet_size) a2 = StupidArtnet(ip, port, universe2, packet_size) a1.flash_all() # send single packet with all channels at 255 a2.flash_all() file.write(StupidArtnet.print_object_and_packet(a1)) file.write(StupidArtnet.print_object_and_packet(a2)) sync.send() a1.show() a2.show() time.sleep(5) sync.send()
#!/usr/bin/env python3 # Mostly stolen from https://www.youtube.com/watch?v=ZA_PxLuofV4 / https://learndataanalysis.org/control-lcd-number-widget-with-a-slider-pyqt5-tutorial/ from lib.StupidArtnet import StupidArtnet import sys from PyQt5.QtWidgets import (QApplication, QWidget, QLCDNumber, QSlider, QVBoxLayout) from PyQt5.QtCore import Qt ip = "192.168.1.234" # Change to correct IP address! universe = 1 ledAmount = 100 packet_size = ledAmount * 3 a = StupidArtnet(ip, universe, packet_size, fps=20) packet = bytearray(packet_size) # create packet for Artnet r = 0 g = 0 b = 0 c = 0 class AppDemo(QWidget): def __init__(self): super().__init__() self.resize(600, 500) self.setWindowTitle('flutnet - ArtNet pixelflut') self.lcd = QLCDNumber() sliderLed = QSlider(Qt.Horizontal) sliderLed.setMaximum(ledAmount)
def methode(a, b, c): return a * b * c def methode2(a, b, c, d): return a + b + c + d port = 6454 ip = '192.168.1.142' group = ArtNetGroup() for i in range(1): a = StupidArtnet(ip, port, i) group.add(a) ledstrip_data = [[[(group.listArtNet[0].BUFFER, 0, 81, -1, -1, -1), (0, 162)]], [], [], [], [], []] print(ledstrip_data[0][0][0][0][0]) print(group.listArtNet[0].BUFFER[0]) ledstrip_data[0][0][0][0][0] = 14 print(ledstrip_data[0][0][0][0][0]) print(group.listArtNet[0].BUFFER[0]) jpp = [(lambda a, b, c: a * b * c, 4, 4, 4), (methode2, 4, 4, 4, 4)] for i in jpp:
import random import sys target_ip = '192.168.30.195' packet_size = 384 universes = {} UNIVERSES = 32 print("initializing") BLACK = [0x0, 0x0, 0x0] WHITE = [0x55, 0x55, 0x55] HEIGHT = 64 UNICOLS = 2 for i in range(1, UNIVERSES + 1): universes[i] = StupidArtnet(target_ip, i, packet_size) CONTENT = { "WHITE": {k: WHITE * UNICOLS * HEIGHT for k in range(1, UNIVERSES + 1)}, "BLACK": {k: BLACK * UNICOLS * HEIGHT for k in range(1, UNIVERSES + 1)}, } def vertical_line_for(n): d = {} for i in range(0, UNIVERSES): idx = i + 1 d.setdefault(idx, []) for cols in [0, 1]:
#!/usr/bin/env python from lib.StupidArtnet import StupidArtnet import time ip = "192.168.1.234" # Change to correct IP address! universe = 1 ledAmount = 50 packet_size = ledAmount * 3 #ACKtree = ChristmasTree.ChristmasTree(ip, port, ledAmount) a = StupidArtnet(ip, universe, packet_size) packet = bytearray(packet_size) # create packet for Artnet while 1: # Red on, blue off for i in range(0, ledAmount / 2): packet[3 * i + 0] = 255 for i in range(ledAmount / 2, ledAmount): packet[3 * i + 2] = 0 a.set(packet) a.show() time.sleep(0.3) # Blue on, red off for i in range(0, ledAmount / 2): packet[3 * i + 0] = 0 for i in range(ledAmount / 2, ledAmount):