Class MicroSwitchHelper

java.lang.Object
com.opensourcewithslu.inputdevices.MicroSwitchHelper

public class MicroSwitchHelper extends Object
The MicroSwitchHelper class is used to initialize a micro switch.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    Shows if the micro switch has been pressed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MicroSwitchHelper(com.pi4j.io.gpio.digital.DigitalInput microSwitchInput)
    MicroSwitchHelper constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
    Adds an event listener to the micro switch.
    void
    Initializes the listener that keeps track of if the micro switch has been pressed or not.
    void
    Removes the event listener from the micro switch.

    Methods inherited from class java.lang.Object

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

    • isPressed

      public boolean isPressed
      Shows if the micro switch has been pressed.
  • Constructor Details

    • MicroSwitchHelper

      public MicroSwitchHelper(com.pi4j.io.gpio.digital.DigitalInput microSwitchInput)
      MicroSwitchHelper constructor.
      Parameters:
      microSwitchInput - A Pi4J DigitalInput object.
  • Method Details

    • initialize

      public void initialize()
      Initializes the listener that keeps track of if the micro switch has been pressed or not. It is automatically called when the MicroSwitchHelper is instantiated.
    • addEventListener

      public void addEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
      Adds an event listener to the micro switch.
      Parameters:
      function - A Pi4J DigitalStateChangeListener object.
    • removeEventListener

      public void removeEventListener()
      Removes the event listener from the micro switch.