public class WaitableDigitalInputDevice extends DigitalInputDevice
device
activeHigh
gpio
Constructor and Description |
---|
WaitableDigitalInputDevice(GpioDeviceFactoryInterface deviceFactory,
int gpio,
GpioPullUpDown pud,
GpioEventTrigger trigger) |
WaitableDigitalInputDevice(int gpio) |
WaitableDigitalInputDevice(int gpio,
GpioPullUpDown pud,
GpioEventTrigger trigger) |
Modifier and Type | Method and Description |
---|---|
protected void |
disableDeviceListener() |
void |
valueChanged(DigitalInputEvent event) |
boolean |
waitForActive()
Wait indefinitely for the device state to go active.
|
boolean |
waitForActive(int timeout)
Wait the specified time period for the device state to go active.
|
boolean |
waitForInactive()
Wait indefinitely for the device state to go inactive.
|
boolean |
waitForInactive(int timeout)
Wait the specified time period for the device state to go inactive.
|
boolean |
waitForValue(boolean value,
int timeout)
Wait the specified time period for the device state to switch to value.
|
close, getPullUpDown, getTrigger, getValue, isActive, removeListener, setListener
enableDeviceListener, isActiveHigh, whenActivated, whenDeactivated
addListener, removeAllListeners, removeListener
getGpio
public WaitableDigitalInputDevice(int gpio) throws RuntimeIOException
gpio
- GPIO to which the device is connected.RuntimeIOException
- If an I/O error occurred.public WaitableDigitalInputDevice(int gpio, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException
gpio
- GPIO to which the device is connected.pud
- Pull up/down configuration, values: NONE, PULL_UP, PULL_DOWN.trigger
- Event trigger configuration, values: NONE, RISING, FALLING, BOTH.RuntimeIOException
- If an I/O error occurred.public WaitableDigitalInputDevice(GpioDeviceFactoryInterface deviceFactory, int gpio, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException
deviceFactory
- Device factory to use to construct the device.gpio
- GPIO to which the device is connected.pud
- Pull up/down configuration, values: NONE, PULL_UP, PULL_DOWN.trigger
- Event trigger configuration, values: NONE, RISING, FALLING, BOTH.RuntimeIOException
- If an I/O error occurred.protected void disableDeviceListener()
disableDeviceListener
in class AbstractDigitalInputDevice
public void valueChanged(DigitalInputEvent event)
valueChanged
in interface InputEventListener<DigitalInputEvent>
valueChanged
in class AbstractDigitalInputDevice
public boolean waitForActive() throws InterruptedException
InterruptedException
- If interrupted while waiting.-public boolean waitForActive(int timeout) throws InterruptedException
timeout
- Timeout value if milliseconds, <= 0 is indefinite.InterruptedException
- If interrupted while waiting.-public boolean waitForInactive() throws InterruptedException
InterruptedException
- If interrupted while waiting.-public boolean waitForInactive(int timeout) throws InterruptedException
timeout
- Timeout value if milliseconds, <= 0 is indefinite.InterruptedException
- If interrupted while waiting.-public boolean waitForValue(boolean value, int timeout) throws InterruptedException
value
- The desired device state to wait for.timeout
- Timeout value if milliseconds, <= 0 is indefinite.InterruptedException
- If interrupted while waiting.-Copyright © 2016–2017 mattjlewis. All rights reserved.