Class DigitalOutputDevice

    • Constructor Detail

      • DigitalOutputDevice

        public DigitalOutputDevice​(int gpio)
                            throws RuntimeIOException
        Defaults to active high logic, initial value is off.
        Parameters:
        gpio - GPIO to which the output device is connected.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • DigitalOutputDevice

        public DigitalOutputDevice​(int gpio,
                                   boolean activeHigh,
                                   boolean initialValue)
                            throws RuntimeIOException
        Parameters:
        gpio - GPIO to which the output device is connected.
        activeHigh - If true then setting the value to true will turn on the connected device.
        initialValue - Initial output value.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • DigitalOutputDevice

        public DigitalOutputDevice​(GpioDeviceFactoryInterface deviceFactory,
                                   int gpio,
                                   boolean activeHigh,
                                   boolean initialValue)
                            throws RuntimeIOException
        Parameters:
        deviceFactory - Device factory to use to construct the device.
        gpio - GPIO to which the output device is connected.
        activeHigh - If true then setting the value to true will turn on the connected device.
        initialValue - Initial output value.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • DigitalOutputDevice

        public DigitalOutputDevice​(GpioDeviceFactoryInterface deviceFactory,
                                   PinInfo pinInfo,
                                   boolean activeHigh,
                                   boolean initialValue)
                            throws RuntimeIOException
        Parameters:
        deviceFactory - Device factory to use to construct the device.
        pinInfo - Information about the GPIO pin to which the output device is connected.
        activeHigh - If true then setting the value to true will turn on the connected device.
        initialValue - Initial output value.
        Throws:
        RuntimeIOException - If an I/O error occurred.
    • Method Detail

      • isOn

        public boolean isOn()
                     throws RuntimeIOException
        Get the device on / off status.
        Returns:
        Returns true if the device is currently on.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • setOn

        public void setOn​(boolean on)
                   throws RuntimeIOException
        Turn the device on or off.
        Parameters:
        on - New on/off value.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • setValueUnsafe

        public void setValueUnsafe​(boolean value)
                            throws RuntimeIOException
        Unsafe operation that has no synchronisation checks and doesn't compensate for active low logic. Included primarily for performance tests.
        Parameters:
        value - The new value
        Throws:
        RuntimeIOException - If an I/O error occurs
      • setValue

        public void setValue​(float value)
        Set the output value to true if value != 0, does not compensate for active low logic
        Specified by:
        setValue in interface OutputDeviceInterface
        Parameters:
        value - The new value
      • onOffLoop

        public void onOffLoop​(float onTime,
                              float offTime,
                              int n,
                              boolean background,
                              Action stopAction)
                       throws RuntimeIOException
        Toggle the device on-off.
        Parameters:
        onTime - On time in seconds.
        offTime - Off time in seconds.
        n - Number of iterations. Set to <0 to blink indefinitely.
        background - If true start a background thread to control the blink and return immediately. If false, only return once the blink iterations have finished.
        stopAction - Action to perform when the loop finishes
        Throws:
        RuntimeIOException - If an I/O error occurs
      • getCycleCount

        public int getCycleCount()