Tutorial – Adding GPIO to a Radiobuttonshow

Greg Reynolds from the Canadian Air and Space Museum in Ottawa has provided a tutorial on how add GPIO based buttons to a Radiobuttonshow. He provides much useful information which is not immediately obvious from the manual including the directory structure of Pi Presents. He takes you through editing gpio.cfg and a copy of the pp_radiobuttonshow_1p3 example profile to show how to set up the control path between a button click and a video playing.

The tutorial is applicable to Version 1.3 (gapless). Version 1.2 (next) has detailed differences but the genral principles are the same.

The tutorial is a pdf document which can be found here

26 Responses to Tutorial – Adding GPIO to a Radiobuttonshow

  1. Henk says:

    Hi
    Thank you for the software and detailed help. I just have one question. When using Radiobuttonshow, is there a way to pause the initial display when you trigger a video with a gpio button, and let it resume after the action completes? Currently when a button is pressed, then the video with the button plays, but once that is done, then the initial display video starts from the beginning, but I need it to pause, and resume after the button action completes. Is there any way of accomplishing this?

  2. Gareth Jenkins says:

    Hi Ken
    Many thanks for the instant reply.
    I have used the second of the two approaches you suggested – I open the show with the second short looping video in Start, Close it with Show Control at the start of the selectable track and Open it again at the end of the selectable track. This does the trick – I now feel rather dense for not having been able to work it out for myself.

    I have donated £50 to the Museum of Technology, with the benefit of Gift Aid to show my appreciation for all of your work in producing this great tool and making it available.

    Best wishes

    Gareth

    • KenT says:

      Very kind of you to make a donation. Opening and closing shows with Show control is a different paradigm, probably more useful than I give it credit for in the manual and the examples. Its very useful.
      Ken

  3. Gareth Jenkins says:

    Hi Ken
    Many thanks for producing and making available such a powerful tool. I am hoping to use it to develop some new displays in a museum run by a charity I volunteer at, but have hit a snag and would be grateful for any help you can offer. I am using Raspian Buster and Beep 1.4.4 on a Pi 4.

    I am following the Greg Reynolds guide on how to add GPIO control to a Radiobutton show.

    I would like to have the Radiobutton show offer the choice between two videos. I have got the GPIO side and the selection of the two videos working. However, on the screen that offers the choice of the two videos I thought that rather than having one looping video it would be nice to have two looping videos showing simultaneously, each one being a clip from one of the main videos on offer.

    By creating a new show which is triggered by start I have been able to get the stage where I have the two video clips running on the screen showing the button options – one as part of the Launch Track and other in the new show I have created. However, when I use GPIO to start one of the main videos running the clip that is run by the new show I created does not stop. I have tried various settings but haven’t been able to find an option that stops both the Launch Track and my new show when the GPIO is used.

    Am I being too ambitious or should it be possible to show two video clips with the menu? If the latter, are you able to give me a steer as to the best way of achieving it?

    Many thanks
    Gareth

    • KenT says:

      I think the answer is to use Show Control commands to Open and Close the Show which shows the second video. Open the Show at the start of the first track and Close it at the start of each of the selectable tracks.
      Alternatively Open the show in Start, Close the show at the start of each selectable track, and Open it at the end of the selectable track.
      If none of this works tell me and I’ll do some experimentation.
      Ken

  4. Heribert Houben says:

    Hello, I am having some problems with GPIO controlled video:
    The show ist very simple, consisting of a picture which is shown at Start and some videos that are started by GPIO-buttons. After the video the show returns to the startpic.
    Problem is: If the GPIO switch is pressed, the video should not start anew while the video is still running. The video should run till the end and only then can be started again. If I set “disable Controls=yes” in the show, the video cannot be started at all… What to do?

    • KenT says:

      In the track controls add pp-stop null, (assuming) pp-stop was the associated with the stop command in the show.

      • Heribert Houben says:

        Thanks!
        But seems I do not understand the logic… I inserted “pp-stop null” to the controls field of the videotrack and this didn’t work, then to the end of the controls for the radiobuttonshow
        (where there was pp-stop return)
        ——————————————————————————————
        but1 play video1
        but2 play video2
        but3 play video3
        but4 play video4
        but5 play video5
        but6 play video6
        but7 play video7
        but8 play video8
        but9 play video9
        pp-key-1 play video1
        pp-key-2 play video2
        pp-key-3 play video3
        pp-key-4 play video4
        pp-key-5 play video5
        pp-key-6 play video6
        pp-key-7 play video7
        pp-key-8 play video8
        pp-key-9 play video9

        pp-stop return
        ———————————————————————–

        Shows

        radiobuttonshow [radiobuttonshow]
        Start [start]
        Medialists

        radiobuttonshow.json
        Edit Show
        Tracks in Selected Medialist

        First Track [first]
        defaultpic.jpg [track1]
        video1.mp4 [video1] (—–> in track controls “pp-stop null )
        video2.mp4 [video2]
        video3.mp4 [video3]
        video4.mp4 [video4]
        video5.mp4 [video5]
        video6.mp4 [video6]
        video7.mp4 [video7]
        video8.mp4 [video8]
        video9.mp4 [video9]
        ——————————————————————————–
        – no effects. Video starts every time I push the button..
        What am I doing wrong?

  5. Thomas Richardson says:

    I want to set up three GPIO buttons, each one plays a different video. However I want the second video to flash a single LED also, How do I config GPIO.cfg to recognize button 2 to play a video and flash an led also? What else do I modify for this to work?

  6. Tim Smith says:

    Hi Ken/all

    I have installed the latest version of gapless, but for some reason I can’t seem to get a GPIO button working at all. I have installed the pp_radiobuttonshow_1p3 example which includes the gpio.cfg for button inputs, but pulling these pins low does not seem to play any of the tracks as it should.

    input_test.py indicates that the buttons are being read correctly. Does anyone know why this is not translating into the actual presentation?

    Many thanks!

  7. Frank says:

    Hello! I Is it possible to use GPIO to select a specific video file? I Just found out about this software and started experimenting with it. GPIO basically works, but i am only able to proceed to the next track.
    Let me explain what I am panning to do: I want the pi to boot up and show a black screen in fullscreen. If someone presses button 1, it should play video 1 and return to the black screen. If someone presses button 2 it should play video 2 and return to the black screen.

    Is that possible? Thanks

  8. Nick says:

    OK so I must be the stupid one. I am now at 20 + hours trying to use pipresents. What I am trying to do is this: I want a TV in a museum to display a jpeg image (with details of the video to follow) and when a button is pushed, a video is played. When the video finishes playing, it goes back to the jpeg.
    I am using mediashow for this. It starts automatically to the JPEG, then for ‘next’ I have set it to ‘input’. I have modified the GPIO.cfg file so that pin 18 is direction ‘in’, falling name ‘button’, and everything else left as is.
    I have placed the GPIO.cfg file into a folder called ‘pp_io_config’ which is in my profile folder.
    I then entered ‘edit show’, and opened the control tab. I added the line ‘button play’.
    I have tested that the button is working with a small python script called ‘buttontest.py’ which confirms it is working fine.
    When I run the show, the JPEG displays as it should, but the button does not trigger the video to play. The down arrow on the keyboard does trigger this, and the video plays as it should.

    Am I on the right track?

    Any guidance would be hugely appreciated, my boss is starting to look at me like I am stupid.

    • KenT says:

      You do not need the play command which plays a child show. Also the trigger should remain at start.
      .In your app it appears all you need is a mediashow with 2 entries and for controls to rotate around the show.
      Set the duration of the image track to 0
      The control in the image track needs to be button down (plays the next track)
      The video track will end naturally and show the image track

      Gapless is the latest and greatest version of Pi Presents,

      • Nick says:

        Hi Ken

        Thank you so much for your reply. However I still can’t make the button work.

        #You do not need the play command which plays a child show.
        OK, I’ve deleted that.

        #Also the trigger should remain at start.
        Do you mean in the “edit show” dialog box? These are my settings: “trigger for start – start”. “Trigger for next – input”. “Next trigger parameters – button”. “Sequence – ordered”. “Track count limit – 0”. “Repeat/Single – Repeat”.

        #In your app it appears all you need is a mediashow with 2 entries and for controls to rotate around the show.
        Yes, that’s how it seems to me also.

        #Set the duration of the image track to 0
        Done.

        #The control in the image track needs to be button down (plays the next track)
        So I select the jpeg image in the medialist, click edit, then click on the control tab. In that field I typed “button down”. Is that what you meant?

        #The video track will end naturally and show the image track.

        Again, it works fine, but only advances from the jpeg to the video when I push the down arrow on the keyboard, not the button.

        What am I missing?
        Imagine you are explaining this to a child.
        Thank you again for your patience.
        Nick

        • KenT says:

          #Also the trigger should remain at start.
          Do you mean in the “edit show” dialog box?
          Yes

          These are my settings: “trigger for start – start”. “Trigger for next – input”. “Next trigger parameters – button”. “Sequence – ordered”. “Track count limit – 0”. “Repeat/Single – Repeat”.
          Trigger for next should be continue so button is not required as a trigger input

          #The control in the image track needs to be button down (plays the next track)
          So I select the jpeg image in the medialist, click edit, then click on the control tab. In that field I typed “button down”. Is that what you meant?

          Yes

          # Again, it works fine, but only advances from the jpeg to the video when I push the down arrow on the keyboard, not the button.

          What am I missing?

          It sounds like you are not using a gpio.cfg file to attach a physical button to the event with the button symbolic name

  9. Fernando Har says:

    Hello Ken,

    Thank you for the great software! I am using this for an Expo in Hong Kong for elderly health care support.

    I am using Pi3, Jessie, gapless version. In my profile, my “start show” is a “radiobuttonShow”. In the radiobuttonshow’s control tab I defined the mapping in which GPIO plays my tracks. (Total three tracks). Each go my tracks are “mediashow”, and each mediashow contains images. Everything goes well, I can start pipresent with my profile, and pressing GPIO buttons jumps to different tracks.

    However, I am having problem trying to make another GPIO button that performs “pp-up” or “pp-down” for moving between images when my mediashow is playing. Is that a limitation to the software or I have misconfigured my profile? Many thanks.

    Fernando Har

    • KenT says:

      Hi
      Its a limitation of a radiobuttonshow.
      In all other types of show input events are passed down to the lowest level subshow.
      However in a radiobuttonshow the above means that during the running of a show track it is not possible to interrupt it and run an alternative track, which is the primary feature of a radiobuttonshow. So in a radiobuttonshow subshows will have no controls.

      You can have one or the other but not both.
      You can change the behaviour in pp_radiobuttonshow to give control to subshows by commenting and uncommenting the lines in

      def handle_input_event(self,symbol):

      around line 136. If you do this you will lose the ability to interrupt the show to select another track during a show.

      I think I need to make the alternatives an option in the profile in the next release.

  10. Thank you for this tutorial. I am trying to use this to set up buttons to change images not videos but I don’t know what syntax to use under Controls. For video he used “play” what do you use for an image? I’ve tried several guesses and when I run Validate I get “error – incorrect number of fields in control”.

Leave a reply to Frank Cancel reply