Class TiltSwitchHelper
java.lang.Object
com.opensourcewithslu.inputdevices.TiltSwitchHelper
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
Modifier and TypeFieldDescriptionboolean
Boolean variable that is true if the tilt switch is being tilted and false otherwise. -
Constructor Summary
ConstructorDescriptionTiltSwitchHelper
(com.pi4j.io.gpio.digital.DigitalInput tiltSwitchInput) TiltSwitchHelper constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.
-
Field Details
-
isTilted
public boolean isTiltedBoolean 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.
-