Display image from script launched from Emulation Station
-
I want to display image from script launched from ES
I can already launch scripts from Emulation Station
So I want a script that displays my control layout screen shot and waits for joystick button press.Figured I should be able to do this from python so here is what I have so far
#!/bin/bash python3 /home/pi/py/dispAM.py
from PIL import Image import time # creating a object im = Image.open('/home/pi/py/myCtrls.jpg') im.show() print('calling sleep') time.sleep(5) #5 Seconds
I never see any image.
If I give bad path to image I get an error.
I see calling sleep.Do I need to figure out what the default image viewer is?
Should I install FEH and just call that instead? -
Do I need to figure out what the default image viewer is?
fbi
. -
You can set up screensaver and launch images, if that is what you mean. You don't need to make a python script.
EDIT: If you going to use a .sh file to start up your image, just do the following:
sudo apt-get update sudo apt-get -y install fbi
Then edit your sh file with:
#!/bin/bash fbi -a /home/pi/py/myCtrls.jpg
-
fbi works! Thanks.
Using python evdev lib to read joystick button input
pip3 install evdev
The following python allows my to display any pic and wait for Joystick button press.
In this case I wanted to be able to display my Emulation Station Control and Attract Mode Button mappings on demand.
import subprocess import time import evdev devices = [evdev.InputDevice(path) for path in evdev.list_devices()] for device in devices: if device.name.startswith('DragonRise Inc.'): device_path=device.path dragonrise = evdev.InputDevice(device_path) print(dragonrise) subprocess.Popen(["fbi","-a","/home/pi/py/MyCtrls.jpg"]) for event in dragonrise.read_loop(): if event.type == evdev.ecodes.EV_KEY: keyevent = evdev.categorize(event) if keyevent.keystate == evdev.KeyEvent.key_down: print(evdev.categorize(event)) break
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.