Package com.diozero.devices
Class RgbPwmLed
java.lang.Object
com.diozero.devices.RgbPwmLed
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class RgbPwmLed
extends java.lang.Object
implements java.io.Closeable
Three pin controlled RGB LED.
-
Constructor Summary
Constructors Constructor Description RgbPwmLed(int redPin, int greenPin, int bluePin)
RgbPwmLed(PwmOutputDeviceFactoryInterface deviceFactory, int redPin, int greenPin, int bluePin)
-
Method Summary
-
Constructor Details
-
RgbPwmLed
- Parameters:
redPin
- GPIO for the red LED.greenPin
- GPIO for the green LED.bluePin
- GPIO for the blue LED.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
RgbPwmLed
public RgbPwmLed(PwmOutputDeviceFactoryInterface deviceFactory, int redPin, int greenPin, int bluePin) throws RuntimeIOException- Parameters:
deviceFactory
- Device factory to use to provision this device.redPin
- GPIO for the red LED.greenPin
- GPIO for the green LED.bluePin
- GPIO for the blue LED.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
getValues
Get the value of all LEDs.- Returns:
- Boolean array (red, green, blue).
- Throws:
RuntimeIOException
- If an I/O error occurred.
-
setValues
Set the value of all LEDs.- Parameters:
red
- Red LED value (0..1).green
- Green LED value (0..1).blue
- Blue LED value (0..1).- Throws:
RuntimeIOException
- If an I/O error occurred.
-
on
Turn all LEDs on.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
off
Turn all LEDs off.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
toggle
Toggle the state of all LEDs.- Throws:
RuntimeIOException
- If an I/O error occurred.
-