Class PIRSensorHelper

java.lang.Object
com.opensourcewithslu.inputdevices.PIRSensorHelper

public class PIRSensorHelper extends Object
The PIRSensorHelper class is used to initialize a PIR motion sensor.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    Shows if the PIR sensor detects movement or not.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    void
    addEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
    Adds an event listener to the PIR sensor.
    void
    Initializes the listener that keeps track of if the PIR sensor detects motion or not.
    void
    Removes the event listener from the PIR sensor.

    Methods inherited from class java.lang.Object

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

    • isMoving

      public boolean isMoving
      Shows if the PIR sensor detects movement or not.
  • Constructor Details

    • PIRSensorHelper

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

    • initialize

      public void initialize()
      Initializes the listener that keeps track of if the PIR sensor detects motion or not. It is automatically called when the PIRSensorHelper is instantiated.
    • addEventListener

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

      public void removeEventListener()
      Removes the event listener from the PIR sensor.