Class GpioInputDevice<T extends DeviceEvent>

java.lang.Object
com.diozero.api.GpioDevice
com.diozero.api.GpioInputDevice<T>
Type Parameters:
T - Event class that extends DeviceEvent. See DigitalInputEvent and AnalogInputEvent.
All Implemented Interfaces:
DeviceInterface, DeviceEventConsumer<T>, AutoCloseable, Consumer<T>
Direct Known Subclasses:
AbstractDigitalInputDevice, AnalogInputDevice

public abstract class GpioInputDevice<T extends DeviceEvent>
extends GpioDevice
implements DeviceEventConsumer<T>
Common base class for digital and analog input devices.
  • Constructor Details

    • GpioInputDevice

      public GpioInputDevice​(PinInfo pinInfo)
      Parameters:
      pinInfo - PinInfo object for the GPIO
  • Method Details

    • addListener

      public void addListener​(DeviceEventConsumer<T> listener)
      Add a new listener
      Parameters:
      listener - Callback instance
    • removeListener

      public void removeListener​(DeviceEventConsumer<T> listener)
      Remove a specific listener
      Parameters:
      listener - Callback instance to remove
    • removeAllListeners

      public void removeAllListeners()
      Remove all listeners
    • hasListeners

      public boolean hasListeners()
    • accept

      public void accept​(T event)
      Specified by:
      accept in interface Consumer<T extends DeviceEvent>
    • enableDeviceListener

      protected abstract void enableDeviceListener()
    • disableDeviceListener

      protected abstract void disableDeviceListener()