Hello,
I could really use some help trying to understand why my launcher code for my Touch pHAT isn’t working properly.
I took the example launcher code from the Pimoroni files and modified to suit my needs.
I am launching some scripts when buttons A, C, D and ENTER are pressed.
Button A calls a shell script that launches Magic Mirror
Buttons C and D call another shell script which launches Chromium.
The Enter button just shuts down Chromium and Magic Mirror.
The issue I am having is when buttons C and D are calling Chromium, the buttons “lock up”. They stop working. However they will begin working again if I kill Chromium.
When Button A is pressed to launch Magic Mirror though, the buttons continue to work properly.
I am not sure what the difference would be between calling one shell script or the other.
It seems when Chromium is launched the script is waiting for a response or something.
Here is my code (please go easy as I’m just learning Python):
#!/usr/bin/env python
import os
import signal
import subprocess
from sys import exit, version_info
import touchphat
@touchphat.on_release('A')
def handle_touch(event):
os.system("pkill chromium")
os.system("pm2 stop mm")
os.system("pm2 start /home/pi/mm.sh")
@touchphat.on_release('C')
def handle_touch(event):
os.system("pkill chromium")
os.system("pm2 stop mm")
os.system("/home/pi/chromium.sh Peacock")
@touchphat.on_release('D')
def handle_touch(event):
os.system("pkill chromium")
os.system("pm2 stop mm")
os.system("/home/pi/chromium.sh Photos")
@touchphat.on_release('Enter')
def handle_touch(event):
os.system("pkill chromium")
os.system("pm2 stop mm")
signal.pause()
My mm.sh file only contains the following lines:
cd ./MagicMirror
DISPLAY=:0 npm start
My chromium.sh file contains the following lines:
export DISPLAY=:0
chromium-browser http://localhost/family_tree/index_offline.php?treeColor=$1 --kiosk --force-device-scale-factor=1.25 --use-gl=egl