Class DigitalInputDevice

All Implemented Interfaces:
DigitalInputDeviceInterface, DeviceEventConsumer<DigitalInputEvent>, Closeable, AutoCloseable, Consumer<DigitalInputEvent>
Direct Known Subclasses:
Button, WaitableDigitalInputDevice

public class DigitalInputDevice
extends AbstractDigitalInputDevice
Represents a generic digital input device.
  • Field Details

  • Constructor Details

    • DigitalInputDevice

      public DigitalInputDevice​(int gpio) throws RuntimeIOException
      Parameters:
      gpio - GPIO to which the device is connected.
      Throws:
      RuntimeIOException - If an I/O error occurs.
    • DigitalInputDevice

      public DigitalInputDevice​(int gpio, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException
      Parameters:
      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.
      Throws:
      RuntimeIOException - If an I/O error occurs.
    • DigitalInputDevice

      public DigitalInputDevice​(GpioDeviceFactoryInterface deviceFactory, int gpio, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException
      Parameters:
      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.
      Throws:
      RuntimeIOException - If an I/O error occurs.
    • DigitalInputDevice

      public DigitalInputDevice​(GpioDeviceFactoryInterface deviceFactory, PinInfo pinInfo, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException
      Parameters:
      deviceFactory - Device factory to use to provision this digital input device.
      pinInfo - Information about the GPIO pin 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.
      Throws:
      RuntimeIOException - If an I/O error occurs.
  • Method Details

    • close

      public void close()
    • getPullUpDown

      public GpioPullUpDown getPullUpDown()
      Get pull up / down configuration.
      Returns:
      Pull up / down configuration.
    • getTrigger

      public GpioEventTrigger getTrigger()
      Get event trigger configuration.
      Returns:
      Event trigger configuration.
    • getValue

      public boolean getValue() throws RuntimeIOException
      Read the current underlying state of the input pin. Does not factor in active high logic.
      Returns:
      Device state.
      Throws:
      RuntimeIOException - If an I/O error occurred.
    • isActive

      public boolean isActive() throws RuntimeIOException
      Read the current on/off state for this device taking into account the pull up / down configuration. If the input is pulled up isActive() will return true when when the value is false.
      Returns:
      Device active state.
      Throws:
      RuntimeIOException - If an I/O error occurred.
    • setListener

      protected void setListener()
      Specified by:
      setListener in class AbstractDigitalInputDevice
    • removeListener

      protected void removeListener()
      Specified by:
      removeListener in class AbstractDigitalInputDevice