parent
9acd2e9d78
commit
13d35d6664
|
@ -115,6 +115,9 @@ def start_mqtt_publishers():
|
||||||
mqtt_client = connect_mqtt()
|
mqtt_client = connect_mqtt()
|
||||||
artnetBindIp = get_eth0_ip()
|
artnetBindIp = get_eth0_ip()
|
||||||
artNet = Artnet.Artnet(BINDIP = artnetBindIp, DEBUG = True, SHORTNAME = "PiXelTubeMaster", LONGNAME = "PiXelTubeMaster", PORT = 6454)
|
artNet = Artnet.Artnet(BINDIP = artnetBindIp, DEBUG = True, SHORTNAME = "PiXelTubeMaster", LONGNAME = "PiXelTubeMaster", PORT = 6454)
|
||||||
|
cur.execute("SELECT mac_address, universe, dmx_address FROM tubes")
|
||||||
|
global result
|
||||||
|
result = cur.fetchall()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
# Gets whatever the last Art-Net packet we received is
|
# Gets whatever the last Art-Net packet we received is
|
||||||
|
@ -124,10 +127,7 @@ def start_mqtt_publishers():
|
||||||
#Checks to see if the current packet is for the specified DMX Universe
|
#Checks to see if the current packet is for the specified DMX Universe
|
||||||
dmxPacket = artNetPacket.data
|
dmxPacket = artNetPacket.data
|
||||||
# Create MQTT topic based on the universe and channel
|
# Create MQTT topic based on the universe and channel
|
||||||
cur.execute("SELECT mac_address, universe, dmx_address FROM tubes")
|
|
||||||
result = cur.fetchall()
|
|
||||||
for row in result:
|
for row in result:
|
||||||
try:
|
|
||||||
dmx_address = int(row[2])
|
dmx_address = int(row[2])
|
||||||
if artNetPacket.universe == int(row[1]):
|
if artNetPacket.universe == int(row[1]):
|
||||||
#Define RGB values per pixel
|
#Define RGB values per pixel
|
||||||
|
@ -170,15 +170,20 @@ def start_mqtt_publishers():
|
||||||
mqtt_client.publish(p4_topic, str([p4_r, p4_g, p4_b]))
|
mqtt_client.publish(p4_topic, str([p4_r, p4_g, p4_b]))
|
||||||
mqtt_client.publish(p5_topic, str([p5_r, p5_g, p5_b]))
|
mqtt_client.publish(p5_topic, str([p5_r, p5_g, p5_b]))
|
||||||
mqtt_client.publish(p6_topic, str([p6_r, p6_g, p6_b]))
|
mqtt_client.publish(p6_topic, str([p6_r, p6_g, p6_b]))
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
artNet.close()
|
artNet.close()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
def update_tube_index():
|
||||||
|
cur.execute("SELECT mac_address, universe, dmx_address FROM tubes")
|
||||||
|
global result
|
||||||
|
result = cur.fetchall()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
flask_thread = Process(target=flask_api)
|
flask_thread = Process(target=flask_api)
|
||||||
flask_thread.start()
|
flask_thread.start()
|
||||||
publisher_thread = Process(target=start_mqtt_publishers)
|
publisher_thread = Process(target=start_mqtt_publishers)
|
||||||
publisher_thread.start()
|
publisher_thread.start()
|
||||||
|
tube_index_updater_thread = Process(target=update_tube_index)
|
||||||
|
tube_index_updater_thread.start()
|
||||||
|
|
Loading…
Reference in New Issue