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:
This library depends on the wiringPi native system library. (developed by Gordon Henderson @ http://wiringpi.com/)
Modifier and Type | Method and Description |
---|---|
static void |
addListener(GpioInterruptListener listener)
Java consumer code can all this method to register itself as a listener for pin state
changes.
|
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.
|
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.
|
static boolean |
hasListener(GpioInterruptListener listener)
Returns true if the listener is already registered for event callbacks.
|
static void |
removeListener(GpioInterruptListener listener)
Java consumer code can all this method to unregister itself as a listener for pin state
changes.
|
public 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.
pin
- GPIO pin number (not header pin number; not wiringPi pin number)public 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.
pin
- GPIO pin number (not header pin number; not wiringPi pin number)public static void addListener(GpioInterruptListener listener)
Java consumer code can all this method to register itself as a listener for pin state changes.
listener
- A class instance that implements the GpioInterruptListener interface.GpioInterruptListener
,
GpioInterruptEvent
public static void removeListener(GpioInterruptListener listener)
Java consumer code can all this method to unregister itself as a listener for pin state changes.
listener
- A class instance that implements the GpioInterruptListener interface.GpioInterruptListener
,
GpioInterruptEvent
public static boolean hasListener(GpioInterruptListener listener)
Returns true if the listener is already registered for event callbacks.
listener
- A class instance that implements the GpioInterruptListener interface.GpioInterruptListener
,
GpioInterruptEvent
Copyright © 2012–2019 Pi4J. All rights reserved.