Class PushButtonHelper

java.lang.Object
com.opensourcewithslu.inputdevices.PushButtonHelper

public class PushButtonHelper extends Object
The PushButtonHelper class is used to create a listener that determines when a 4 pin button is pressed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Determines if the button is pressed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PushButtonHelper(com.pi4j.io.gpio.digital.DigitalInput buttonInput)
    The PushButtonHelper constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
    Adds an EventListener to the PushButton.
    void
    Initializes the PushButton.
    void
    removeEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
    Removes an EvenListener from the button.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • isPressed

      public Boolean isPressed
      Determines if the button is pressed.
  • Constructor Details

    • PushButtonHelper

      public PushButtonHelper(com.pi4j.io.gpio.digital.DigitalInput buttonInput)
      The PushButtonHelper constructor.
      Parameters:
      buttonInput - A Pi4J DigitalInput Object.
  • Method Details

    • initialize

      public void initialize()
      Initializes the PushButton. Automatically called when the PushButton is created.
    • addEventListener

      public void addEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
      Adds an EventListener to the PushButton.
      Parameters:
      function - A DigitalStateChangeListener Object.
    • removeEventListener

      public void removeEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
      Removes an EvenListener from the button.
      Parameters:
      function - The listener to be removed.