I am using the open lighting architecture on a Raspberry Pi and I need to be able to start a show that runs in a constant loop with a button and kill that show and start another one with a button. I am using the pyface add-on with 4 buttons. I can start a process, but I cannot kill a process with the buttons.
If you are using ola in the command line you can stop the show by pressing control-c. I have been able to make a gui that can stop the process with tkinter but the same process doesn't work with physical buttons.
from time import sleep
import os
import signal
import piface.pfio as pfio
import time
import threading
from subprocess import Popen
import subprocess
import Queue
pfio.init()
pfio.digital_read(0)
pfio.digital_read(1)
pfio.digital_read(2)
def olaserverStart ():
os.system('olad -l 3')
def show1():
os.system('ola_recorder -p /home/pi/Mermaid -i 0')
def stop():
try:
sig = signal.CTRL_C_EVENT
except AttributeError:
sig = signal.SIGINT
send_signal(sig)
def universe():
global proc3
proc3 = subprocess.Popen('ola_patch -d 12 -p 0 -u 0', shell=True)
proc3.wait()
def universe1():
global proc4
proc4 = subprocess.Popen('ola_patch -d 6 -p 0 -u 0', shell=True)
proc4.wait()
olaserverStart()
universe()
universe1()
while True:
if (pfio.digital_read(0) == 1):
p3 = subprocess.Popen('ola_recorder -p /home/pi/Mermaid -i 0', shell=True)
p3.wait()
if (pfio.digital_read(1) == 1):
try:
sig = signal.CTRL_C_EVENT
except AttributeError:
sig = signal.SIGINT
p3.send_signal(sig)
if (pfio.digital_read(2) == 1):
os.system('ola_recorder -p /home/pi/Mermaid -i 0')
sleep(0.15);