public class WiFiBox
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
COMMAND_ALL_OFF
The command code for "RGBW COLOR LED ALL OFF".
|
static int |
COMMAND_ALL_ON
The command code for "RGBW COLOR LED ALL ON".
|
static int |
COMMAND_ALL_WHITE
The command code for "SET COLOR TO WHITE (GROUP ALL)".
|
static int |
COMMAND_BRIGHTNESS
The command code for "DIRECT BRIGHTNESS SETTING" (part of a two-byte
command).
|
static int |
COMMAND_COLOR
The command code for "COLOR SETTING" (part of a two-byte command).
|
static int |
COMMAND_DISCO
The command code for "DISCO MODE".
|
static int |
COMMAND_DISCO_FASTER
The command code for "DISCO SPEED FASTER".
|
static int |
COMMAND_DISCO_SLOWER
The command code for "DISCO SPEED SLOWER".
|
static int |
COMMAND_GROUP_1_OFF
The command code for "GROUP 1 ALL OFF".
|
static int |
COMMAND_GROUP_1_ON
The command code for "GROUP 1 ALL ON".
|
static int |
COMMAND_GROUP_1_WHITE
The command code for "SET COLOR TO WHITE (GROUP 1)".
|
static int |
COMMAND_GROUP_2_OFF
The command code for "GROUP 2 ALL OFF".
|
static int |
COMMAND_GROUP_2_ON
The command code for "GROUP 2 ALL ON".
|
static int |
COMMAND_GROUP_2_WHITE
The command code for "SET COLOR TO WHITE (GROUP 2)".
|
static int |
COMMAND_GROUP_3_OFF
The command code for "GROUP 3 ALL OFF".
|
static int |
COMMAND_GROUP_3_ON
The command code for "GROUP 3 ALL ON".
|
static int |
COMMAND_GROUP_3_WHITE
The command code for "SET COLOR TO WHITE (GROUP 3)".
|
static int |
COMMAND_GROUP_4_OFF
The command code for "GROUP 4 ALL OFF".
|
static int |
COMMAND_GROUP_4_ON
The command code for "GROUP 4 ALL ON".
|
static int |
COMMAND_GROUP_4_WHITE
The command code for "SET COLOR TO WHITE (GROUP 4)".
|
static int |
DEFAULT_PORT
The default port for unconfigured boxes.
|
static int |
MIN_SLEEP_BETWEEN_MESSAGES
The sleep time between both messages for switching lights to the white
mode.
|
| Constructor and Description |
|---|
WiFiBox(java.net.InetAddress address)
A constructor creating a new instance of the WiFi box class using the
default port number.
|
WiFiBox(java.net.InetAddress address,
int port)
A constructor creating a new instance of the WiFi box class.
|
WiFiBox(java.lang.String host)
A constructor creating a new instance of the WiFi box class using the
default port number.
|
WiFiBox(java.lang.String host,
int port)
A constructor creating a new instance of the WiFi box class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLightListener(int group,
LightListener listener)
Use this function to add a new listener one group of lights connected to
the WiFiBox.
|
void |
brightness(int value)
Set the brightness value for the currently active group of lights (the
last one that was switched on, see
getActiveGroup()). |
void |
brightness(int group,
int value)
Set the brightness value for a given group of lights.
|
void |
color(java.awt.Color color)
Set the color value for the currently active group of lights (the last
one that was switched on, see
getActiveGroup()). |
void |
color(java.awt.Color color,
boolean forceColoredMode)
Set the color value for the currently active group of lights (the last
one that was switched on, see
getActiveGroup()). |
void |
color(int value)
Set the color value for the currently active group of lights (the last
one that was switched on, see
getActiveGroup()). |
void |
color(int group,
java.awt.Color color)
Set the color value for a given group of lights.
|
void |
color(int group,
java.awt.Color color,
boolean forceColoredMode)
Set the color value for a given group of lights.
|
void |
color(int group,
int value)
Set the color value for a given group of lights.
|
void |
color(int group,
MilightColor color)
Set the color value for a given group of lights.
|
void |
color(int group,
MilightColor color,
boolean forceColoredMode)
Set the color value for a given group of lights.
|
void |
color(MilightColor color)
Set the color value for the currently active group of lights (the last
one that was switched on, see
getActiveGroup()). |
void |
color(MilightColor color,
boolean forceColoredMode)
Set the color value for the currently active group of lights (the last
one that was switched on, see
getActiveGroup()). |
void |
colorAndBrightness(java.awt.Color color)
Set the color and brightness values for the currently active group of
lights (the last one that was switched on, see
getActiveGroup()). |
void |
colorAndBrightness(int group,
java.awt.Color color)
Set the color and brightness values for a given group of lights.
|
void |
colorAndBrightness(int group,
java.awt.Color color,
boolean forceColoredMode)
Set the color and brightness values for a given group of lights.
|
void |
colorAndBrightness(int group,
MilightColor color)
Set the color and brightness values for a given group of lights.
|
void |
colorAndBrightness(int group,
MilightColor color,
boolean forceColoredMode)
Set the color and brightness values for a given group of lights.
|
void |
colorAndBrightness(MilightColor color)
Set the color and brightness values for the currently active group of
lights (the last one that was switched on, see
getActiveGroup()). |
void |
discoMode()
Trigger the disco mode for the active group of lights (the last one that
was switched on, see
getActiveGroup()). |
void |
discoMode(int group)
Triggers the disco mode for a particular group of lights.
|
void |
discoModeFaster()
Increase the disco mode's speed for the active group of lights (the last
one that was switched on, see
getActiveGroup()). |
void |
discoModeSlower()
Decrease the disco mode's speed for the active group of lights (the last
one that was switched on, see
getActiveGroup()). |
int |
getActiveGroup()
This function returns the number of the currently active group of lights.
|
Lights |
getLights(int group)
Get the group of lights that is controlled by a given group number.
|
void |
off()
Switch all lights off (all groups).
|
void |
off(int group)
Switch all lights of a particular group off.
|
void |
on()
Switch all lights on (all groups).
|
void |
on(int group)
Switch all lights of a particular group on.
|
void |
removeLightListener(int group,
LightListener listener)
This function removes a listener from this WiFiBox which was added before
by
addLightListener(int, LightListener). |
java.lang.String |
toString()
This function describes the objet as a string.
|
void |
white()
Switch all lights in all groups to the white mode.
|
void |
white(int group)
Switch all lights in a particular group to the white mode.
|
public static final int DEFAULT_PORT
public static final int MIN_SLEEP_BETWEEN_MESSAGES
public static final int COMMAND_ALL_OFF
public static final int COMMAND_GROUP_1_OFF
public static final int COMMAND_GROUP_2_OFF
public static final int COMMAND_GROUP_3_OFF
public static final int COMMAND_GROUP_4_OFF
public static final int COMMAND_ALL_ON
public static final int COMMAND_GROUP_1_ON
public static final int COMMAND_GROUP_2_ON
public static final int COMMAND_GROUP_3_ON
public static final int COMMAND_GROUP_4_ON
public static final int COMMAND_ALL_WHITE
public static final int COMMAND_GROUP_1_WHITE
public static final int COMMAND_GROUP_2_WHITE
public static final int COMMAND_GROUP_3_WHITE
public static final int COMMAND_GROUP_4_WHITE
public static final int COMMAND_DISCO
public static final int COMMAND_DISCO_FASTER
public static final int COMMAND_DISCO_SLOWER
public static final int COMMAND_COLOR
public static final int COMMAND_BRIGHTNESS
public WiFiBox(java.net.InetAddress address,
int port)
address - is the address of the WiFi boxport - is the port of the WiFi box (omit this if unsure)public WiFiBox(java.net.InetAddress address)
address - is the address of the WiFi boxpublic WiFiBox(java.lang.String host,
int port)
throws java.net.UnknownHostException
host - is the host given as hostname such as "domain.tld" or string
repesentation of an ip addressport - is the port of the WiFi box (omit this if unsure)java.net.UnknownHostException - if the hostname could not be resolvedpublic WiFiBox(java.lang.String host)
throws java.net.UnknownHostException
host - is the host given as hostname such as "domain.tld" or string
repesentation of an ip addressjava.net.UnknownHostException - if the hostname could not be resolvedpublic Lights getLights(int group) throws java.lang.IllegalArgumentException
group - is the number of the group at the WiFi box (between 1 and 4)java.lang.IllegalArgumentException - if the group number is not between 1 and 4public void off()
throws java.io.IOException
java.io.IOException - if the message could not be sentpublic void off(int group)
throws java.io.IOException,
java.lang.IllegalArgumentException
group - the group to switch of (between 1 and 4)java.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if the group number is not between 1 and 4public void on()
throws java.io.IOException
java.io.IOException - if the message could not be sentpublic void on(int group)
throws java.io.IOException,
java.lang.IllegalArgumentException
group - the group to switch of (between 1 and 4)java.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if the group number is not between 1 and 4public void white()
public void white(int group)
throws java.lang.IllegalArgumentException
group - the group to switch of (between 1 and 4)java.lang.IllegalArgumentException - if the group number is not between 1 and 4public void discoMode()
throws java.io.IOException
getActiveGroup()).java.io.IOException - if the message could not be sentpublic void discoMode(int group)
throws java.lang.IllegalArgumentException
group - the group to switch of (between 1 and 4)java.lang.IllegalArgumentException - if the group number is not between 1 and 4public void discoModeFaster()
throws java.io.IOException
getActiveGroup()).java.io.IOException - if the message could not be sentpublic void discoModeSlower()
throws java.io.IOException
getActiveGroup()).java.io.IOException - if the message could not be sentpublic void brightness(int value)
throws java.io.IOException,
java.lang.IllegalArgumentException
getActiveGroup()).value - is the brightness value to set (between
MilightColor.MIN_BRIGHTNESS and MilightColor.MAX_BRIGHTNESS)java.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if the brightness value is not between
MilightColor.MIN_BRIGHTNESS and MilightColor.MAX_BRIGHTNESSpublic void brightness(int group,
int value)
throws java.io.IOException,
java.lang.IllegalArgumentException
group - is the number of the group to set the brightness forvalue - is the brightness value to set (between
MilightColor.MIN_BRIGHTNESS and MilightColor.MAX_BRIGHTNESS)java.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if group is not between 1 and 4 or the brightness value is
not between MilightColor.MIN_BRIGHTNESS and
MilightColor.MAX_BRIGHTNESSpublic void color(int value)
throws java.io.IOException,
java.lang.IllegalArgumentException
getActiveGroup()).value - is the color value to set (between MilightColor.MIN_COLOR and
MilightColor.MAX_COLOR)java.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if the color value is not between MilightColor.MIN_COLOR and
MilightColor.MAX_COLORpublic void color(MilightColor color, boolean forceColoredMode) throws java.io.IOException
getActiveGroup()).color - is the color to setforceColoredMode - true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modejava.io.IOException - if the message could not be sentpublic void color(MilightColor color) throws java.io.IOException
getActiveGroup()). Colors
with low saturation will be displayed in white mode for a better result.color - is the color to setjava.io.IOException - if the message could not be sentpublic void color(java.awt.Color color,
boolean forceColoredMode)
throws java.io.IOException
getActiveGroup()).color - is the color to setforceColoredMode - true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modejava.io.IOException - if the message could not be sentpublic void color(java.awt.Color color)
throws java.io.IOException
getActiveGroup()). Colors
with low saturation will be displayed in white mode for a better result.color - is the color to setjava.io.IOException - if the message could not be sentpublic void color(int group,
int value)
throws java.io.IOException,
java.lang.IllegalArgumentException
group - is the number of the group to set the color forvalue - is the color value to set (between MilightColor.MIN_COLOR and
MilightColor.MAX_COLOR)java.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if group is not between 1 and 4 or the color value is not
between MilightColor.MIN_COLOR and MilightColor.MAX_COLORpublic void color(int group,
MilightColor color,
boolean forceColoredMode)
throws java.io.IOException,
java.lang.IllegalArgumentException
group - is the number of the group to set the color forcolor - is the color to setforceColoredMode - true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modejava.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if group is not between 1 and 4public void color(int group,
MilightColor color)
throws java.io.IOException,
java.lang.IllegalArgumentException
group - is the number of the group to set the color forcolor - is the color to setjava.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if group is not between 1 and 4public void color(int group,
java.awt.Color color,
boolean forceColoredMode)
throws java.io.IOException,
java.lang.IllegalArgumentException
group - is the number of the group to set the color forcolor - is the color to setforceColoredMode - true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modejava.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if group is not between 1 and 4public void color(int group,
java.awt.Color color)
throws java.io.IOException,
java.lang.IllegalArgumentException
group - is the number of the group to set the color forcolor - is the color to setjava.io.IOException - if the message could not be sentjava.lang.IllegalArgumentException - if group is not between 1 and 4public void colorAndBrightness(MilightColor color)
getActiveGroup()). Both values are extracted from the
color given to the function by transforming it to an HSB color.color - is the color to extract hue and brightness frompublic void colorAndBrightness(java.awt.Color color)
getActiveGroup()). Both values are extracted from the
color given to the function by transforming it to an HSB color.color - is the color to extract hue and brightness frompublic void colorAndBrightness(int group,
MilightColor color,
boolean forceColoredMode)
group - is the number of the group to set the color forcolor - is the color to extract hue and brightness fromforceColoredMode - true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modejava.lang.IllegalArgumentException - if group is not between 1 and 4public void colorAndBrightness(int group,
MilightColor color)
group - is the number of the group to set the color forcolor - is the color to extract hue and brightness fromjava.lang.IllegalArgumentException - if group is not between 1 and 4public void colorAndBrightness(int group,
java.awt.Color color,
boolean forceColoredMode)
group - is the number of the group to set the color forcolor - is the color to extract hue and brightness fromforceColoredMode - true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modejava.lang.IllegalArgumentException - if group is not between 1 and 4public void colorAndBrightness(int group,
java.awt.Color color)
group - is the number of the group to set the color forcolor - is the color to extract hue and brightness fromjava.lang.IllegalArgumentException - if group is not between 1 and 4public void addLightListener(int group,
LightListener listener)
group - is the number of the group to add the listener tolistener - is the listener to addjava.lang.IllegalArgumentException - if group is not between 1 and 4public void removeLightListener(int group,
LightListener listener)
addLightListener(int, LightListener).group - is the number of the group to remove the listener fromlistener - is the listener to removejava.lang.IllegalArgumentException - if group is not between 1 and 4public int getActiveGroup()
public java.lang.String toString()
toString in class java.lang.Object