Module diozero.core

Class DigitalInputDevice

All Implemented Interfaces:
DeviceInterface, DigitalInputDeviceInterface, DeviceEventConsumer<DigitalInputEvent>, AutoCloseable, Consumer<DigitalInputEvent>
Direct Known Subclasses:
Button, DebouncedDigitalInputDevice, SmoothedInputDevice

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

  • Method Details

    • close

      public void close()
      Description copied from interface: DeviceInterface
      Close this device
    • getName

      public String getName()
    • 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