public class DLights
extends java.lang.Object
The dLight is a RGB color LED connected to a sensor port. Up to four dLights can be daisy chained on a single port. The individual dLights are identified within this class by a sequence number (1-4). All dLights can be addressed simultaniously as a group by using sequence number 0.
The DLights class supports two different color schemes for instructing the dLights; RGB and HSL. It supports just RGB for querying the dLights
Constructor and Description |
---|
DLights(I2CPort port)
Constructor for DLights.
|
DLights(Port port) |
Modifier and Type | Method and Description |
---|---|
void |
disable(int lightNo)
Disables the dLight.
|
void |
disableBlinking(int lightNo)
Disables blinking.
|
void |
enable(int lightNo)
Enables the dLight.
|
void |
enableBlinking(int lightNo)
Enables blinking pattern.
|
void |
getColor(int lightNo,
int[] rgb)
Returns the RGB color of the LED Each of the color values is between 0
(fully off) and 255 (fully on).
|
DLight |
getDLight(int lightNo)
Returns the I2C driver for a single dLight.
|
int |
getExternalLED(int lightNo)
Gets the PWM value of the external LED driver of the dLight.
|
boolean |
isBlinkingEnabled(int lightNo)
Queries the blinking status of the dLight
|
boolean |
isEnabled(int lightNo)
Queries the status of the dLight
|
void |
setBlinkingPattern(int lightNo,
float seconds,
int percentageOn)
Specifies the blinking pattern of the LED.
|
void |
setColor(int lightNo,
int[] rgb)
Changes the color of the LED according to specified RGB color.
|
void |
setColor(int lightNo,
int red,
int green,
int blue)
Changes the color of the LED according to specified RGB color.
|
void |
setExternalLED(int lightNo,
int value)
Sets the PWM value of the external LED driver of the dLight.
|
void |
setHSLColor(int lightNo,
int hue,
int saturation,
int luminosity)
Changes the color of the LED according to specified HSL color.
|
public DLights(I2CPort port)
Nb. It also enables HIGH-SPEED I2C on this port.
port
- The I2CPort that the dLights are attached to.public DLights(Port port)
public DLight getDLight(int lightNo)
Nb. For ordinary use there is no need to use the I2C driver for a single dLight that this method returns. The method and the DLight instance it returns are nly useful if one needs to access the dLight directly over I2C.
lightNo
- The sequence number of the dLight (1-4). Please note that the group number 0 is invalid for this method.public void enable(int lightNo)
lightNo
- The sequence number of the dLight (0-4).public void disable(int lightNo)
Values for color and blinking pattern are not overwritten and will still be in effect after enabling the dLight again.
lightNo
- The sequence number of the dLight (0-4).public boolean isEnabled(int lightNo)
lightNo
- (1-4). Please note that the group number 0 is invalid for this method.public void setColor(int lightNo, int red, int green, int blue)
lightNo
- The sequence number of the dLight (0-4).red
- green
- blue
- public void setColor(int lightNo, int[] rgb)
lightNo
- The sequence number of the dLight (0-4).rgb
- an integer array containing RGB colorspublic void setHSLColor(int lightNo, int hue, int saturation, int luminosity)
hue
- The hue value in the range of 0-360saturation
- The saturation value in the range of 0-100luminosity
- The saturation luminosity value in the range of 0-100public void setBlinkingPattern(int lightNo, float seconds, int percentageOn)
lightNo
- The sequence number of the dLight (0-4).seconds
- The total time of a blinking cycle (in seconds)percentageOn
- The percentage of the time the LED is on within a blinking cyclepublic void enableBlinking(int lightNo)
lightNo
- The sequence number of the dLight (0-4).public void disableBlinking(int lightNo)
lightNo
- The sequence number of the dLight (0-4).public boolean isBlinkingEnabled(int lightNo)
lightNo
- (1-4). Please note that the group number 0 is invalid for this method.public void getColor(int lightNo, int[] rgb)
lightNo
- The sequence number of the dLight (1-4). Please note that the group number 0 is invalid for this method.rgb
- the RGB color of the LEDpublic void setExternalLED(int lightNo, int value)
lightNo
- The sequence number of the dLight (0-4).value
- The values should be between 0 (fully off) and 255 (fully on).public int getExternalLED(int lightNo)
lightNo
- The sequence number of the dLight (1-4). Please note that the group number 0 is invalid for this method.