Custom: Accepting GPIO button presses and releases as button events

Important: These changes apply to BrighAuthor version 3.5 or earlier, and are not required in later versions of BrightAuthor, which include button up or down options for GPIO events.

GPIO-ButtonUP-ButtonDown.jpg

If you want to be able to trigger events using both button presses and releases, there’s two simple changes you can make to the autorun script that BrightAuthor publishes to allow this if you are not using BrightAuthor 3.8 or newer.  

Note: The following change does not work inside of media lists or inside the interactive menu object.

Step 1:  Find the RunBSP function

1. Search for this function

  • Sub RunBsp(sysFlags As Object, sysInfo As Object, diagnosticCodes As Object)

2. Find this line, which creates the gpio object:

  • BSP.gpioPort = CreateObject("roGpioControlPort")

3. Comment out this line and add the following line to create a roControlPort Object. The resulting two lines should look like this:

    • 'BSP.gpioPort = CreateObject("roGpioControlPort")
    • BSP.gpioPort = CreateObject("roControlPort", "Brightsign") 

Step 2: Find the MediaItemEventHandler function

1. Search for this function:

  • Function MediaItemEventHandler(event As Object, stateData As Object) As Object

2. Find this line, which checks for a button event:

  • if type(event) = "roGpioButton" then

3. Comment out this line and replace it with a line that checks for button up and button down events. A button down event is like the normal button press. A button up event is the release of that button.

  • 'if type(event) = "roGpioButton" then
  • if type(event) = "roControlUp" or type(event) = "roControlDown" then

Step 3: Publish your project with your custom autorun

Have more questions? Submit a request

4 Comments

  • 0
    Avatar
    Alfonso Descalzo

    I´m using an XD1230 with BA BA 3.7.0.14 and last beta firmware, and can´t find these lines:

     

    • BSP.gpioPort = CreateObject("roGpioControlPort")
    •  'if type(event) = "roGpioButton" then

     

    Thanks

  • 0
    Avatar
    Alfonso Descalzo

    ...now with the BA 3.7.0.21, and the same,,, can´t find those lines or something similar,,

     

  • 0
    Avatar
    Alex

    These changes apply to BrightAuthor 3.7

    If you want to be able to listen for a button press and release in BrightAuthor, change the autorun script published by BrightAuthor to the following:

    Step 1: Find this function definition

    Sub GPIOEventHandler(event As Object)

    Step 2: Change the original line to the new line below

    Original:_ if m.state$ = "ButtonUp" then_

    New:_ if m.state$ = "ButtonUp" or m.state$ = "ButtonDown" then_

    Step 3: Change theoriginal line to the new lines below

    Original: m.state$ = "ButtonDown"

    New:

    if m.state$ = "ButtonUp" then _

    _     m.state$ = "ButtonDown" _

    _else _

    _     m.state$ = "ButtonUp" _

    _Endif

  • 0
    Avatar
    Alex

    The upcoming 3.8 Brightauthor version will have the ability to specify triggering the gpio event on button up or down. See attached image.

Please sign in to leave a comment.
Can't find what looking for? Try to
Powered by Zendesk