public class DigitalInputDevice extends GpioInputDevice<DigitalInputEvent>
Modifier and Type | Field and Description |
---|---|
protected boolean |
activeHigh |
protected GpioDigitalInputDeviceInterface |
device |
listeners
pinNumber
Constructor and Description |
---|
DigitalInputDevice(GpioDeviceFactoryInterface deviceFactory,
int pinNumber,
GpioPullUpDown pud,
GpioEventTrigger trigger) |
DigitalInputDevice(int pinNumber) |
DigitalInputDevice(int pinNumber,
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
getPinNumber
protected boolean activeHigh
protected GpioDigitalInputDeviceInterface device
public DigitalInputDevice(int pinNumber) throws RuntimeIOException
pinNumber
- Pin number to which the device is connected.RuntimeIOException
- If an I/O error occurs.public DigitalInputDevice(int pinNumber, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException
pinNumber
- Pin number 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 pinNumber, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException
deviceFactory
- Device factory to use to provision this digital input device.pinNumber
- Pin number 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()
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
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 mattjlewis. All rights reserved.