0

using GPIO as two events



We have a situation where we'd like to eliminate a pile of unreliable hardware with a single purple box. But to do it, I need to know if we need to change the cabling to the space, or if the functionality is available in the box. (Probably a 1010.)

Currently, we have a wire-pair that goes into the space that we use to provide a contact closure. This starts a whole sequence of events in the house-of-cards. At the end of the day, the contact-closure is opened, and the house-of-cards, provided it hasn't collapsed, turns everything off.

Can I get a Roku to treat an incoming closure on a GPIO as a separate event as the same GPIO opening?

In essence, I'd like to have a GPIO close at the start of the day. Player shifts to an active slide, and sends a RS232 command to a projector. At the end of the day, when the closure releases, go to a black slide, and tell the projector to turn off. (To make things more interesting, on the next day, it goes to Active Slide #2, and turns on Projector #2. The day after, back to Slide #1 and Projector #1 -- but I figure that's just a "four event" playlist, advancing each event with one "press" and one "release".)

Leo Kerr

1 comment

  • 0
    Avatar
    RokuLyndon


    This can be done with an custom script. Other than sending an on and off command to the projector, what else is the player doing. This is a simple example assuming you can send commands with IDs for the projector. Do the projectors have IDs so you can send a command that only one listens to?



    It plays an image, sends a command on a button press, and then waits for the button release to send an off command.



    projector = 1

    on_command1="1/ON"

    off_command1="1/OFF"

    on_command2="2/ON"

    off_command2="2/OFF"



    serial  = CreateObject ("roSerialPort",0,9600)

    image = CreateObject("roImagePlayer")

    gpio = CreateObject("roGpioControlPort")

    p=CreateObject("roMessagePort")

    gpio.EnableInput(0)

    gpio.SetPort(p)







    Loop:

    REM waits for button press, contact closure



    msg = wait(0,p)

    if type(msg) = "roGpioButton" then

     if msg.GetInt() = 0 then

             if projector = 1 then

               serial.SendLine(on_command1)

               image.DisplayFile("image1.jpg")

            elseif projector = 2 then

               serial.SendLine(on_command2)

               image.DisplayFile("image2.jpg")

            endif

     endif

    endif





    goto loop





    wait_for_open:

      while gpio.IsInputActive(0)

         REM Waits for button release, open contact, then changes projector

      end while



      projector=2



    goto loop
Please sign in to leave a comment.