From 87521ddce2c60f7b178c453b38d2a7a8acae3c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Mon, 12 Feb 2024 18:28:48 +0100 Subject: [PATCH] changed from artnet to scan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- README.md | 32 +++++--------------------------- client/main.py | 24 +++++++++++++++++------- server/artnet_converter.py | 28 ---------------------------- 3 files changed, 22 insertions(+), 62 deletions(-) delete mode 100644 server/artnet_converter.py diff --git a/README.md b/README.md index 74e9c96..731148a 100644 --- a/README.md +++ b/README.md @@ -236,34 +236,12 @@ exit; sudo systemctl restart apache2 ``` -### Setup Open Lighting Archetecture as the ArtNET/sACN middle man: +### Clone the project to your Pi -Edit: +You can just clone the project itself into your home directory. -`sudo nano /etc/ola/ola-artnet.conf` +`cd ~ && git clone https://github.com/ping-mee/PiXelTubes` -``` -always_broadcast = false -enabled = true -ip = eth0 -long_name = PiXelTube Master -net = 0 -output_ports = 4 -short_name = PiXelTube Master -subnet = 0 -use_limited_broadcast = false -use_loopback = false -``` +Then just change directory into the server folder. -Save and exit. - - - -You can access the Pi's OLA webinterface via the following address: - -`http://:9090/` - -* From there click add universe > set universe ID > set universe name. -* Select Artnet input with the IP address from the ethernet port and as Artnet output the address from the wifi access point. - -Repeat this process for every universe you are going to use for your tubes. As an addition to Artnet you can also use sACN (E1.31) as an input. +`cd PiXelTubes/server` diff --git a/client/main.py b/client/main.py index bbba89b..077fe45 100644 --- a/client/main.py +++ b/client/main.py @@ -1,6 +1,6 @@ import os import wifi -from stupidArtnet import * +from sacn import sACNlistener from neopixel import * import requests import json @@ -72,17 +72,27 @@ def update_led_strip(dmx_values, dmx_address, strip, LED_PER_PIXEL): # Update the LED strip strip.show() -def listen_to_artnet(universe, dmx_address, strip, LED_PER_PIXEL): +def listen_to_sacn(universe, dmx_address, strip, LEDS_PER_PIXEL): try: - artnet = StupidArtnet() - artnet.start(universe=universe) + # Create a new sACN listener + listener = sACNlistener() + + # Configure the listener to listen to the specified universe + listener.register_listener(universe) + + # Start the listener + listener.start() while True: - dmx_values = artnet.listen() + # Get the latest data from the specified universe + packet = listener[universe].listen() - if dmx_values is not None: - update_led_strip(dmx_values, dmx_address, strip, LED_PER_PIXEL) + if packet is not None: + # Extract DMX values from the sACN packet + dmx_values = packet.dmx_frame + # Update the LED strip based on the received DMX values + update_led_strip(dmx_values, dmx_address, strip, LEDS_PER_PIXEL) except Exception as e: print(f"Error: {e}") diff --git a/server/artnet_converter.py b/server/artnet_converter.py deleted file mode 100644 index 2606dad..0000000 --- a/server/artnet_converter.py +++ /dev/null @@ -1,28 +0,0 @@ -import socket - -def forward_artnet(iface_in, iface_out): - # Create raw socket to receive and send ArtNet packets - sock_in = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(0x0003)) - sock_in.bind((iface_in, 0)) - - sock_out = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(0x0003)) - sock_out.bind((iface_out, 0)) - - while True: - # Receive ArtNet packet from the input interface - pkt, _ = sock_in.recvfrom(65535) - - # Modify the source MAC address if needed - # Modify other fields as required - - # Forward the packet to the output interface - sock_out.sendall(pkt) - - print(f"Forwarded ArtNet packet from {iface_in} to {iface_out}") - -# Specify the input and output interfaces -input_interface = "eth0" -output_interface = "wlan0" - -# Start forwarding ArtNet packets between interfaces -forward_artnet(input_interface, output_interface)