Class AbstractDigitalInputDevice

    • Field Detail

      • activeHigh

        protected boolean activeHigh
    • Constructor Detail

      • AbstractDigitalInputDevice

        public AbstractDigitalInputDevice​(PinInfo pinInfo,
                                          boolean activeHigh)
    • Method Detail

      • isActiveHigh

        public boolean isActiveHigh()
        Get active high configuration.
        Returns:
        Returns false if configured as pull-up, true for all other pull up / down options.
      • whenActivated

        public void whenActivated​(LongConsumer consumer)
        Action to perform when the device state is active.
        Parameters:
        consumer - Callback object to be invoked when activated (long parameter is nanoseconds time).
      • whenDeactivated

        public void whenDeactivated​(LongConsumer consumer)
        Action to perform when the device state is inactive.
        Parameters:
        consumer - Callback object to be invoked when activated (long parameter is nanoseconds time)
      • waitForActive

        public boolean waitForActive()
                              throws InterruptedException
        Wait indefinitely for the device state to go active.
        Returns:
        False if timed out waiting for the specified value, otherwise true.
        Throws:
        InterruptedException - If interrupted while waiting.
      • waitForActive

        public boolean waitForActive​(int timeout)
                              throws InterruptedException
        Wait the specified time period for the device state to go active.
        Parameters:
        timeout - Timeout value if milliseconds, <= 0 is indefinite.
        Returns:
        False if timed out waiting for the specified value, otherwise true.
        Throws:
        InterruptedException - If interrupted while waiting.
      • waitForInactive

        public boolean waitForInactive()
                                throws InterruptedException
        Wait indefinitely for the device state to go inactive.
        Returns:
        False if timed out waiting for the specified value, otherwise true.
        Throws:
        InterruptedException - If interrupted while waiting.
      • waitForInactive

        public boolean waitForInactive​(int timeout)
                                throws InterruptedException
        Wait the specified time period for the device state to go inactive.
        Parameters:
        timeout - Timeout value if milliseconds, <= 0 is indefinite.
        Returns:
        False if timed out waiting for the specified value, otherwise true.
        Throws:
        InterruptedException - If interrupted while waiting.
      • waitForValue

        public boolean waitForValue​(boolean value,
                                    int timeout)
                             throws InterruptedException
        Wait the specified time period for the device state to switch to the specified value, not taking into account active high / low logic.
        Parameters:
        value - The desired device state to wait for.
        timeout - Timeout value if milliseconds, <= 0 is indefinite.
        Returns:
        False if timed out waiting for the specified value, otherwise true.
        Throws:
        InterruptedException - If interrupted while waiting.
      • setListener

        protected abstract void setListener()
      • removeListener

        protected abstract void removeListener()