News:

LATEST RELEASE:  FPP 6.1 - Download from here - https://github.com/FalconChristmas/fpp/releases/tag/6.1

+-+-

+-User

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+-Site Stats

Members
Total Members: 15520
Latest: stacker1001
New This Month: 28
New This Week: 16
New Today: 7
Stats
Total Posts: 127290
Total Topics: 15624
Most Online Today: 73
Most Online Ever: 7634
(January 21, 2020, 02:14:03 AM)
Users Online
Members: 7
Guests: 26
Total: 33

Using GPIO inputs for multiple uses?

Started by VitoHGrind, September 28, 2022, 05:30:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VitoHGrind

I've created an interactive podium with 5 buttons where people can trigger different house effects. I'd like to be able to also allow these buttons to serve as inputs to the FPP Arcade plugin. Currently, it looks like GPIO inputs can be tied to one specific use, e.g. trigger a specific effect/fseq OR be used as arcade input, but not both. Is there a way to make this conditional on another button? In other words something like:
     if triggerButton = open, redButton press --> effect,
     if triggerButton = pressed/closed, redButton press --> arcade input

Poporacer

Quote from: VitoHGrind on September 28, 2022, 05:30:45 PMIs there a way to make this conditional on another button?
Yes, but you would have to write your own cod in order to keep track of the button states/
If to err is human, I am more human than most people.

VitoHGrind

Quote from: Poporacer on September 28, 2022, 07:27:10 PMYes, but you would have to write your own cod in order to keep track of the button states/
To be clear, it doesn't have to be conditional on another button. It could just as easily be conditional based on Arcade state.
    If Arcade is running, redButton press --> arcade input
    Else redButton press --> effect

Yep, I figured I'd have to write code, but I'm not sure where to even begin.  I assume the GPIO inputs are handled at the fpp level and just passed to the plugins.  Can anyone point me to where fpp handles the GPIO inputs?

Poporacer

If to err is human, I am more human than most people.

VitoHGrind

Quote from: Poporacer on September 29, 2022, 05:56:27 PMHow about here?
https://github.com/FalconChristmas/fpp/blob/master/src/gpio.cpp
Yeesh... ok maybe I don't want to go messing with the GPIO inputs at that level.  I was digging a little more and I came across this post:
https://falconchristmas.com/forum/index.php?topic=3141

Essentially, when a button is pressed, this script is triggered and checks for FPP status before doing something.  If IDLE, do option A, if not, do something else.  This seems like what I need, except that I want the status check to be specific to FPP Arcade, not to FPP overall. In the FPP Arcade, there is the isRunning function. I imagine I can use the guts of this code in place of the STATUS code below.  However, I'm not sure what to call?  I don't want to run a script, I want to either trigger an effect or pass along a button press.

isRunning Code - 
bool FPPArcadeGame::isRunning() {
    PixelOverlayModel *m = PixelOverlayManager::INSTANCE.getModel(modelName);
    if (m != nullptr) {
        FPPArcadeGameEffect *effect = dynamic_cast<FPPArcadeGameEffect*>(m->getRunningEffect());
        if (effect) {
            return true;
        }
    }
    return false;
}




CheckIfPlaying code is here-
#!/bin/sh
###########################################################
# CheckIfPlaying.sh - Run scripts based on whether or not #
# FPP is currently playing a sequence of some sort.       #
###########################################################

# Edit this line to hold the script name to run if nothing is currently being played
SCRIPT_IF_NOT_PLAYING="PL4.sh (NOT PLAYING)"

# Edit this line to hold the script name to run if something is currently playing
# Edit out this line for only the one action
#SCRIPT_IF_PLAYING="NIL.sh (PLAYING)"



###########################################################
# Guts of the script.  You probably don't need to edit    #
# anything below this block                               #
###########################################################

. /opt/fpp/scripts/common

# Get our current status
STATUS=$(fpp -s | cut -d',' -f2)

# Check that we got something meaningful
if [ -z "${STATUS}" ]; then
   echo "Error with status value" >&2
   exit 1
fi

# Act on the current status
case ${STATUS} in
   # IDLE
   0)
      if [ -e "${MEDIADIR}/scripts/${SCRIPT_IF_NOT_PLAYING}" ]; then
         eventScript "${MEDIADIR}/scripts/${SCRIPT_IF_NOT_PLAYING}"
      fi
      ;;
   # PLAYING
   1)
      # Do nothing
      ;;
   # STOPPING GRACEFULLY
   2|*)
      # Do nothing for stopping gracefully for now, or unknown
      ;;
esac

Powered by EzPortal
Powered by SMFPacks Menu Editor Mod