Class PwmLed

    • Constructor Detail

      • PwmLed

        public PwmLed​(int gpio,
                      float initialValue)
               throws RuntimeIOException
        Parameters:
        gpio - The GPIO to which the LED is attached to.
        initialValue - Initial PWM output value (range 0..1).
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • PwmLed

        public PwmLed​(PwmOutputDeviceFactoryInterface deviceFactory,
                      int gpio,
                      float initialValue)
               throws RuntimeIOException
        Parameters:
        deviceFactory - Device factory to use to provision this device.
        gpio - The GPIO to which the LED is attached to.
        initialValue - Initial PWM output value (range 0..1).
        Throws:
        RuntimeIOException - If an I/O error occurred.
    • Method Detail

      • blink

        public void blink​(float onTime,
                          float offTime,
                          int iterations,
                          boolean background)
                   throws RuntimeIOException
        Blink the LED on and off repeatedly.
        Parameters:
        onTime - On time in seconds.
        offTime - Off time in seconds.
        iterations - 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.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • pulse

        public void pulse()
                   throws RuntimeIOException
        Pulse the LED on and off indefinitely in a background thread with a fade time of 1 second.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • pulse

        public void pulse​(float fadeTime,
                          int steps,
                          int iterations,
                          boolean background)
                   throws RuntimeIOException
        Pulse the LED on and off repeatedly.
        Parameters:
        fadeTime - Time in seconds from fully on to fully off.
        steps - Number of steps between fully on to fully off.
        iterations - Number of times to fade in and out.
        background - If true start a background thread to control the blink and return immediately. If false, only return once the blink iterations have finished.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • isLit

        public boolean isLit()
                      throws RuntimeIOException
        Return true if the PWM value is >0.
        Returns:
        True if >0, false if 0.
        Throws:
        RuntimeIOException - If an I/O error occurred.