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:
InputEventListener<T>
,java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
AbstractDigitalInputDevice
,AnalogInputDevice
public abstract class GpioInputDevice<T extends DeviceEvent> extends GpioDevice implements InputEventListener<T>
Common base class for digital and analog input devices.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description GpioInputDevice(int gpio)
-
Method Summary
Modifier and Type Method Description void
addListener(InputEventListener<T> listener)
Add a new listener.protected abstract void
disableDeviceListener()
protected abstract void
enableDeviceListener()
void
removeAllListeners()
Remove all listeners.void
removeListener(InputEventListener<T> listener)
Remove a specific listener.void
valueChanged(T event)
-
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. -
valueChanged
- Specified by:
valueChanged
in interfaceInputEventListener<T extends DeviceEvent>
-
enableDeviceListener
protected abstract void enableDeviceListener() -
disableDeviceListener
protected abstract void disableDeviceListener()
-