Class TiltSwitchHelper

java.lang.Object
com.opensourcewithslu.inputdevices.TiltSwitchHelper

public class TiltSwitchHelper extends Object
Helper class to control a tilt switch using Digital Input. This class provides methods to initialize a tilt switch by adding or removing an event listener.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    Boolean variable that is true if the tilt switch is being tilted and false otherwise.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    void
    addEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
    Adds an event listener to the tilt switch.
    void
    Removes the event listener from the tilt switch.

    Methods inherited from class java.lang.Object

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

    • isTilted

      public boolean isTilted
      Boolean variable that is true if the tilt switch is being tilted and false otherwise.
  • Constructor Details

    • TiltSwitchHelper

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

    • addEventListener

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

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