Class PIRSensorHelper
java.lang.Object
com.opensourcewithslu.inputdevices.PIRSensorHelper
The PIRSensorHelper class is used to initialize a PIR motion sensor.
-
Field Summary
Modifier and TypeFieldDescriptionboolean
Shows if the PIR sensor detects movement or not. -
Constructor Summary
ConstructorDescriptionPIRSensorHelper
(com.pi4j.io.gpio.digital.DigitalInput pirSensorOutput) PIRSensorHelper constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.
-
Field Details
-
isMoving
public boolean isMovingShows 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.
-