Package com.diozero.devices
Class RgbPwmLed
- java.lang.Object
-
- com.diozero.devices.RgbPwmLed
-
- All Implemented Interfaces:
DeviceInterface
,AutoCloseable
public class RgbPwmLed extends Object implements DeviceInterface
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close this devicefloat[]
getValues()
Get the value of all LEDs.void
off()
Turn all LEDs off.void
on()
Turn all LEDs on.void
setColor(Color color)
Sets theColor
of all the LEDs.void
setValues(float red, float green, float blue)
Set the value of all LEDs.void
toggle()
Toggle the state of all LEDs.
-
-
-
Constructor Detail
-
RgbPwmLed
public RgbPwmLed(int redPin, int greenPin, int bluePin) throws RuntimeIOException
- 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 Detail
-
close
public void close()
Description copied from interface:DeviceInterface
Close this device- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-
getValues
public float[] getValues() throws RuntimeIOException
Get the value of all LEDs.- Returns:
- Boolean array (red, green, blue).
- Throws:
RuntimeIOException
- If an I/O error occurred.
-
setValues
public void setValues(float red, float green, float blue) throws RuntimeIOException
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.
-
setColor
public void setColor(Color color) throws RuntimeIOException
Sets theColor
of all the LEDs.- Parameters:
color
- The color to set- Throws:
RuntimeIOException
- If an I/O error occurred.
-
on
public void on() throws RuntimeIOException
Turn all LEDs on.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
off
public void off() throws RuntimeIOException
Turn all LEDs off.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
toggle
public void toggle() throws RuntimeIOException
Toggle the state of all LEDs.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
-