public class DigitalInputDevice extends GpioInputDevice<DigitalInputEvent> implements DigitalInputDeviceInterface
Modifier and Type | Field and Description |
---|---|
protected boolean |
activeHigh |
protected GpioDigitalInputDeviceInterface |
device |
listeners
gpio
Constructor and Description |
---|
DigitalInputDevice(GpioDeviceFactoryInterface deviceFactory,
int gpio,
GpioPullUpDown pud,
GpioEventTrigger trigger) |
DigitalInputDevice(int gpio) |
DigitalInputDevice(int gpio,
GpioPullUpDown pud,
GpioEventTrigger trigger) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
disableListener() |
protected void |
enableListener() |
GpioPullUpDown |
getPullUpDown()
Get pull up / down configuration.
|
GpioEventTrigger |
getTrigger()
Get event trigger configuration.
|
boolean |
getValue()
Read the current underlying state of the input pin.
|
boolean |
isActive()
Read the current on/off state for this device taking into account the
pull up / down configuration.
|
boolean |
isActiveHigh()
Get active high configuration.
|
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.
|
addListener, removeAllListeners, removeListener
getGpio
protected boolean activeHigh
protected GpioDigitalInputDeviceInterface device
public DigitalInputDevice(int gpio) throws RuntimeIOException
gpio
- GPIO to which the device is connected.RuntimeIOException
- If an I/O error occurs.public DigitalInputDevice(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 occurs.public DigitalInputDevice(GpioDeviceFactoryInterface deviceFactory, int gpio, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException
deviceFactory
- Device factory to use to provision this digital input 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 occurs.public void close()
close
in interface DigitalInputDeviceInterface
close
in interface Closeable
close
in interface AutoCloseable
public void valueChanged(DigitalInputEvent event)
valueChanged
in interface InputEventListener<DigitalInputEvent>
valueChanged
in class GpioInputDevice<DigitalInputEvent>
protected void enableListener()
enableListener
in class GpioInputDevice<DigitalInputEvent>
protected void disableListener()
disableListener
in class GpioInputDevice<DigitalInputEvent>
public GpioPullUpDown getPullUpDown()
public GpioEventTrigger getTrigger()
public boolean isActiveHigh()
public boolean getValue() throws RuntimeIOException
getValue
in interface DigitalInputDeviceInterface
RuntimeIOException
- If an I/O error occurred.public boolean isActive() throws RuntimeIOException
isActive()
will return true
when when the value is
false
.RuntimeIOException
- If an I/O error occurred.public void whenActivated(Action action)
action
- Action callback object.public void whenDeactivated(Action action)
action
- Action callback object.Copyright © 2016–2017 mattjlewis. All rights reserved.