Package com.diozero.api
Class AbstractDigitalInputDevice
java.lang.Object
- All Implemented Interfaces:
DigitalInputDeviceInterface
,InputEventListener<DigitalInputEvent>
,java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
DigitalInputDevice
,DigitalInputOutputDevice
public abstract class AbstractDigitalInputDevice extends GpioInputDevice<DigitalInputEvent> implements DigitalInputDeviceInterface
-
Field Summary
Fields Modifier and Type Field Description protected boolean
activeHigh
-
Constructor Summary
Constructors Constructor Description AbstractDigitalInputDevice(int gpio, boolean activeHigh)
-
Method Summary
Modifier and Type Method Description protected void
disableDeviceListener()
protected void
enableDeviceListener()
boolean
isActiveHigh()
Get active high configuration.protected abstract void
removeListener()
protected abstract void
setListener()
void
valueChanged(DigitalInputEvent event)
void
whenActivated(Action action)
Action to perform when the device state is active.void
whenDeactivated(Action action)
Action to perform when the device state is inactive.Methods inherited from class com.diozero.api.GpioInputDevice
addListener, removeAllListeners, removeListener
-
Field Details
-
activeHigh
protected boolean activeHigh
-
-
Constructor Details
-
AbstractDigitalInputDevice
public AbstractDigitalInputDevice(int gpio, boolean activeHigh)
-
-
Method Details
-
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>
-
valueChanged
- Specified by:
valueChanged
in interfaceInputEventListener<DigitalInputEvent>
- Overrides:
valueChanged
in classGpioInputDevice<DigitalInputEvent>
-
whenActivated
Action to perform when the device state is active.- Parameters:
action
- Action callback object.
-
whenDeactivated
Action to perform when the device state is inactive.- Parameters:
action
- Action callback object.
-
setListener
protected abstract void setListener() -
removeListener
protected abstract void removeListener()
-