News:

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

+-+-

+-User

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

+-Site Stats

Members
Total Members: 15649
Latest: zj023
New This Month: 53
New This Week: 0
New Today: 0
Stats
Total Posts: 128335
Total Topics: 15780
Most Online Today: 58
Most Online Ever: 7634
(January 21, 2020, 02:14:03 AM)
Users Online
Members: 4
Guests: 23
Total: 27

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

Support FPP

+- Recent Topics

help getting started, next step? by Poporacer
January 28, 2023, 05:10:18 PM

Trying to configure LOR CF50D Floods on FPP Pi Player with PiCap by half.fast
January 28, 2023, 03:19:37 PM

wifi issues on BBB running fpp v6.3 by k6ccc
January 28, 2023, 02:04:23 PM

BBB / FPP sending data to ESP32 WLED by srwmemphis
January 28, 2023, 04:39:02 AM

raspberry PI 3 / PI 4 by mrfix1
January 27, 2023, 07:13:55 AM

Bug in newest release by tbone321
January 26, 2023, 06:14:26 PM

Cannot Connect to F48V4-NS Through Rasberry Pi by Poporacer
January 26, 2023, 03:13:43 PM

new piCaps in the works? by Bwinter
January 26, 2023, 11:25:32 AM

DIY voucher request by CaptainMurdoch
January 26, 2023, 11:14:38 AM

Which volume to grow during setup? by RickR
January 26, 2023, 09:55:17 AM

Powered by EzPortal
Powered by SMFPacks Menu Editor Mod