Class AnalogInputMonitor
- java.lang.Object
-
- com.pi4j.jni.AnalogInputMonitor
-
public class AnalogInputMonitor extends Object
This class provides static methods to configure the native Pi4J library to listen to GPIO analog input value changes and invoke callbacks into this class. Additionally, this class provides a listener registration allowing Java consumers to subscribe to GPIO analog input value changes.
- Author:
- Robert Savage (http://www.savagehomeautomation.com)
- See Also:
- https://pi4j.com/
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addListener(AnalogInputListener listener)
Java consumer code can all this method to register itself as a listener for pin analog input value changes.static int
disablePinValueChangeCallback(int pin)
This method is used to instruct the native code to stop the monitoring thread monitoring analog input values on the selected GPIO pin.static int
enablePinValueChangeCallback(int pin, int pollingRate, double changeThreshold)
This method is used to instruct the native code to setup a monitoring thread to monitor analog input values for changes on the selected GPIO pin.static boolean
hasListener(AnalogInputListener listener)
Returns true if the listener is already registered for event callbacks.static void
removeListener(AnalogInputListener listener)
Java consumer code can all this method to unregister itself as a listener for pin analog input value changes.
-
-
-
Method Detail
-
enablePinValueChangeCallback
public static int enablePinValueChangeCallback(int pin, int pollingRate, double changeThreshold)
This method is used to instruct the native code to setup a monitoring thread to monitor analog input values for changes on the selected GPIO pin.
- Parameters:
pin
- GPIO pin numberpollingRate
- the polling rate in milliseconds for the input monitoring thread to read analog input values from the hardwarechangeThreshold
- the amount of change (delta) in the analog input value required before a new analog input change event is dispatched.- 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.
-
disablePinValueChangeCallback
public static int disablePinValueChangeCallback(int pin)
This method is used to instruct the native code to stop the monitoring thread monitoring analog input values on the selected GPIO pin.
- Parameters:
pin
- GPIO 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.
-
addListener
public static void addListener(AnalogInputListener listener)
Java consumer code can all this method to register itself as a listener for pin analog input value changes.
- Parameters:
listener
- A class instance that implements the AnalogInputListener interface.- See Also:
AnalogInputListener
,AnalogInputEvent
-
removeListener
public static void removeListener(AnalogInputListener listener)
Java consumer code can all this method to unregister itself as a listener for pin analog input value changes.
- Parameters:
listener
- A class instance that implements the AnalogInputListener interface.- See Also:
AnalogInputListener
,AnalogInputEvent
-
hasListener
public static boolean hasListener(AnalogInputListener listener)
Returns true if the listener is already registered for event callbacks.
- Parameters:
listener
- A class instance that implements the AnalogInputListener interface.- See Also:
AnalogInputListener
,AnalogInputEvent
-
-