Class MicroSwitchHelper
java.lang.Object
com.opensourcewithslu.inputdevices.MicroSwitchHelper
The MicroSwitchHelper class is used to initialize a micro switch.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMicroSwitchHelper
(com.pi4j.io.gpio.digital.DigitalInput microSwitchInput) MicroSwitchHelper constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.
-
Field Details
-
isPressed
public boolean isPressedShows 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.
-