RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Display image from script launched from Emulation Station

    Scheduled Pinned Locked Moved Help and Support
    script
    4 Posts 3 Posters 310 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • flagrant99F
      flagrant99
      last edited by flagrant99

      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

      dispAM.sh

      #!/bin/bash
      python3 /home/pi/py/dispAM.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?

      S 1 Reply Last reply Reply Quote 0
      • S
        sleve_mcdichael @flagrant99
        last edited by

        Do I need to figure out what the default image viewer is?

        fbi.

        1 Reply Last reply Reply Quote 1
        • ?
          A Former User
          last edited by A Former User

          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
          
          1 Reply Last reply Reply Quote 1
          • flagrant99F
            flagrant99
            last edited by

            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
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            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.