Package com.diozero.api
Class AbstractDigitalInputDevice
- java.lang.Object
-
- com.diozero.api.GpioDevice
-
- com.diozero.api.GpioInputDevice<DigitalInputEvent>
-
- com.diozero.api.AbstractDigitalInputDevice
-
- All Implemented Interfaces:
DeviceInterface
,DigitalInputDeviceInterface
,DeviceEventConsumer<DigitalInputEvent>
,Closeable
,AutoCloseable
,Consumer<DigitalInputEvent>
- Direct Known Subclasses:
DigitalInputDevice
,DigitalInputOutputDevice
public abstract class AbstractDigitalInputDevice extends GpioInputDevice<DigitalInputEvent> implements DigitalInputDeviceInterface
Abstract base class for low-level GPIO digital input devices.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
activeHigh
-
Fields inherited from class com.diozero.api.GpioDevice
gpio
-
-
Constructor Summary
Constructors Constructor Description AbstractDigitalInputDevice(int gpio, boolean activeHigh)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
accept(DigitalInputEvent event)
protected void
disableDeviceListener()
protected void
enableDeviceListener()
boolean
isActiveHigh()
Get active high configuration.protected abstract void
removeListener()
protected abstract void
setListener()
void
whenActivated(LongConsumer consumer)
Action to perform when the device state is active.void
whenDeactivated(LongConsumer consumer)
Action to perform when the device state is inactive.-
Methods inherited from class com.diozero.api.GpioInputDevice
addListener, removeAllListeners, removeListener
-
Methods inherited from class com.diozero.api.GpioDevice
getGpio
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.diozero.api.DeviceInterface
close
-
Methods inherited from interface com.diozero.api.DigitalInputDeviceInterface
close, getValue
-
-
-
-
Method Detail
-
isActiveHigh
public boolean isActiveHigh()
Get active high configuration.- Returns:
- Returns false if configured as pull-up, true for all other pull up / down options.
-
enableDeviceListener
protected void enableDeviceListener()
- Specified by:
enableDeviceListener
in classGpioInputDevice<DigitalInputEvent>
-
disableDeviceListener
protected void disableDeviceListener()
- Specified by:
disableDeviceListener
in classGpioInputDevice<DigitalInputEvent>
-
accept
public void accept(DigitalInputEvent event)
- Specified by:
accept
in interfaceConsumer<DigitalInputEvent>
- Overrides:
accept
in classGpioInputDevice<DigitalInputEvent>
-
whenActivated
public void whenActivated(LongConsumer consumer)
Action to perform when the device state is active.- Parameters:
consumer
- Callback object to be invoked when activated (long parameter is nanoseconds time).
-
whenDeactivated
public void whenDeactivated(LongConsumer consumer)
Action to perform when the device state is inactive.- Parameters:
consumer
- Callback object to be invoked when activated (long parameter is nanoseconds time)
-
setListener
protected abstract void setListener()
-
removeListener
protected abstract void removeListener()
-
-