Class GpioInterrupt
- java.lang.Object
- 
- com.pi4j.wiringpi.GpioInterrupt
 
- 
 public class GpioInterrupt extends Object This class provides static methods to configure the native Pi4J library to listen to GPIO interrupts and invoke callbacks into this class. Additionally, this class provides a listener registration allowing Java consumers to subscribe to GPIO pin state changes. Before using the Pi4J library, you need to ensure that the Java VM in configured with access to the following system libraries: - pi4j
- wiringPi
 This library depends on the wiringPi native system library. (developed by Gordon Henderson @ http://wiringpi.com/) - Author:
- Robert Savage (http://www.savagehomeautomation.com)
- See Also:
- https://pi4j.com/
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classGpioInterrupt.GpioEvent
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddListener(GpioInterruptListener listener)Java consumer code can call this method to register itself as a listener for pin state changes.static intdisablePinStateChangeCallback(int pin)This method is used to instruct the native code to stop the monitoring thread monitoring interrupts on the selected GPIO pin.static intenablePinStateChangeCallback(int pin)This method is used to instruct the native code to setup a monitoring thread to monitor interrupts that represent changes to the selected GPIO pin.static booleanhasListener(GpioInterruptListener listener)Returns true if the listener is already registered for event callbacks.static voidremoveListener(GpioInterruptListener listener)Java consumer code can all this method to unregister itself as a listener for pin state changes.static voidshutdown()
 
- 
- 
- 
Method Detail- 
enablePinStateChangeCallbackpublic static int enablePinStateChangeCallback(int pin) This method is used to instruct the native code to setup a monitoring thread to monitor interrupts that represent changes to the selected GPIO pin. The GPIO pin must first be exported before it can be monitored. - Parameters:
- pin- GPIO pin number (not header pin number; not wiringPi pin number)
- Returns:
- A return value of a negative number represents an error. A return value of '0' represents success and that the GPIO pin is already being monitored. A return value of '1' represents success and that a new monitoring thread was created to handle the requested GPIO pin number.
 
 - 
disablePinStateChangeCallbackpublic static int disablePinStateChangeCallback(int pin) This method is used to instruct the native code to stop the monitoring thread monitoring interrupts on the selected GPIO pin. - Parameters:
- pin- GPIO pin number (not header pin number; not wiringPi pin number)
- Returns:
- A return value of a negative number represents an error. A return value of '0' represents success and that no existing monitor was previously running. A return value of '1' represents success and that an existing monitoring thread was stopped for the requested GPIO pin number.
 
 - 
addListenerpublic static void addListener(GpioInterruptListener listener) Java consumer code can call this method to register itself as a listener for pin state changes. - Parameters:
- listener- A class instance that implements the GpioInterruptListener interface.
- See Also:
- GpioInterruptListener,- GpioInterruptEvent
 
 - 
removeListenerpublic static void removeListener(GpioInterruptListener listener) Java consumer code can all this method to unregister itself as a listener for pin state changes. - Parameters:
- listener- A class instance that implements the GpioInterruptListener interface.
- See Also:
- GpioInterruptListener,- GpioInterruptEvent
 
 - 
hasListenerpublic static boolean hasListener(GpioInterruptListener listener) Returns true if the listener is already registered for event callbacks. - Parameters:
- listener- A class instance that implements the GpioInterruptListener interface.
- See Also:
- GpioInterruptListener,- GpioInterruptEvent
 
 - 
shutdownpublic static void shutdown() 
 
- 
 
-