Package com.diozero.api
Class GpioInputDevice<T extends DeviceEvent>
java.lang.Object
com.diozero.api.GpioDevice
com.diozero.api.GpioInputDevice<T>
- Type Parameters:
T
- Event class that extends DeviceEvent. SeeDigitalInputEvent
andAnalogInputEvent
.
- All Implemented Interfaces:
DeviceEventConsumer<T>
,Closeable
,AutoCloseable
,Consumer<T>
- Direct Known Subclasses:
AbstractDigitalInputDevice
,AnalogInputDevice
public abstract class GpioInputDevice<T extends DeviceEvent> extends GpioDevice implements DeviceEventConsumer<T>
Common base class for digital and analog input devices.
-
Field Summary
Fields inherited from class com.diozero.api.GpioDevice
gpio
-
Constructor Summary
Constructors Constructor Description GpioInputDevice(int gpio)
-
Method Summary
Modifier and Type Method Description void
accept(T event)
void
addListener(DeviceEventConsumer<T> listener)
Add a new listener.protected abstract void
disableDeviceListener()
protected abstract void
enableDeviceListener()
void
removeAllListeners()
Remove all listeners.void
removeListener(DeviceEventConsumer<T> listener)
Remove a specific listener.Methods inherited from class com.diozero.api.GpioDevice
getGpio
-
Constructor Details
-
GpioInputDevice
public GpioInputDevice(int gpio)- Parameters:
gpio
- GPIO to which the device is connected.
-
-
Method Details
-
addListener
Add a new listener.- Parameters:
listener
- Callback instance.
-
removeListener
Remove a specific listener.- Parameters:
listener
- Callback instance to remove.
-
removeAllListeners
public void removeAllListeners()Remove all listeners. -
accept
- Specified by:
accept
in interfaceConsumer<T extends DeviceEvent>
-
enableDeviceListener
protected abstract void enableDeviceListener() -
disableDeviceListener
protected abstract void disableDeviceListener()
-