net.rim.device.api.system
Class LED

java.lang.Object
  extended by net.rim.device.api.system.LED

public final class LED
extends Object

Contains LED API constants and methods.

Example

 if(LED.isSupported(LED.LED_TYPE_STATUS))
 {
     LED.setState(LED.STATE_ON);
     //or    
     LED.setState(LED.STATE_BLINKING);
     
     LED.setConfiguration(100, 1000, LED.BRIGHTNESS_100); 
 }
 

Since:
BlackBerry API 3.6.0

Field Summary
static int BRIGHTNESS_100
          LED 100% brightness.
static int BRIGHTNESS_12
          LED 12% brightness.
static int BRIGHTNESS_25
          LED 25% brightness.
static int BRIGHTNESS_50
          LED 50% brightness.
static int LED_TYPE_STATUS
          Status LED.
static int LED_TYPE_TRACKBALL
          Trackball LED.
static int STATE_AUDIO_SYNC
          LED is synchronized to the active audio output.
static int STATE_BLINKING
          LED is blinking.
static int STATE_OFF
          LED is off.
static int STATE_ON
          LED is on solid.
static int STATE_PATTERN
          LED is in pattern mode.
 
Method Summary
static boolean isPolychromatic()
          Returns true if the status LED is capable of displaying multiple colors.
static boolean isPolychromatic(int type)
          Returns true if the specified LED is capable of displaying multiple colors.
static boolean isSupported(int type)
          Returns true if the specified LED is supported on this hardware.
static void setColorConfiguration(int onTime, int offTime, int color)
          Configures the status LED.
static void setColorPattern(int type, int[] pattern, boolean repeat)
          Configures the specified LED to light using the pattern provided.
static void setColorPattern(int[] pattern, boolean repeat)
          Configures the status LED to light using the pattern provided.
static void setConfiguration(int onTime, int offTime, int brightness)
          Configures the status LED.
static void setConfiguration(int type, int onTime, int offTime, int brightness)
          Configures the specified LED.
static void setState(int state)
          Sets the status LED state.
static void setState(int type, int state)
          Sets the specified LED state.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

STATE_OFF

public static final int STATE_OFF
LED is off.

See Also:
Constant Field Values
Since:
BlackBerry API 3.6.0

STATE_ON

public static final int STATE_ON
LED is on solid.

See Also:
Constant Field Values
Since:
BlackBerry API 3.6.0

STATE_BLINKING

public static final int STATE_BLINKING
LED is blinking.

See Also:
Constant Field Values
Since:
BlackBerry API 3.6.0

STATE_PATTERN

public static final int STATE_PATTERN
LED is in pattern mode.

See Also:
Constant Field Values
Since:
BlackBerry API 4.2.0

STATE_AUDIO_SYNC

public static final int STATE_AUDIO_SYNC
LED is synchronized to the active audio output.

See Also:
Constant Field Values
Since:
BlackBerry API 4.2.0

BRIGHTNESS_12

public static final int BRIGHTNESS_12
LED 12% brightness.

See Also:
Constant Field Values
Since:
BlackBerry API 3.6.0

BRIGHTNESS_25

public static final int BRIGHTNESS_25
LED 25% brightness.

See Also:
Constant Field Values
Since:
BlackBerry API 3.6.0

BRIGHTNESS_50

public static final int BRIGHTNESS_50
LED 50% brightness.

See Also:
Constant Field Values
Since:
BlackBerry API 3.6.0

BRIGHTNESS_100

public static final int BRIGHTNESS_100
LED 100% brightness.

See Also:
Constant Field Values
Since:
BlackBerry API 3.6.0

LED_TYPE_STATUS

public static final int LED_TYPE_STATUS
Status LED.

See Also:
Constant Field Values
Since:
BlackBerry API 4.2.0

LED_TYPE_TRACKBALL

public static final int LED_TYPE_TRACKBALL
Trackball LED.

See Also:
Constant Field Values
Since:
BlackBerry API 4.2.1


Method Detail

isSupported

public static boolean isSupported(int type)
Returns true if the specified LED is supported on this hardware.

Parameters:
type - One of the LED_TYPE_ defines.
Returns:
True if the LED type is supported.
Throws:
IllegalArgumentException - If the type is an invalid type (see valid defined types in this class.)
Since:
BlackBerry API 4.3.0

isPolychromatic

public static boolean isPolychromatic()
Returns true if the status LED is capable of displaying multiple colors.

Returns:
True if the status LED is capable of displaying multiple colors.
Since:
BlackBerry API 4.0.0

isPolychromatic

public static boolean isPolychromatic(int type)
Returns true if the specified LED is capable of displaying multiple colors.

Parameters:
type - One of the LED_TYPE_ defines.
Returns:
True if the LED is capable of displaying multiple colors.
Throws:
IllegalArgumentException - If the type is an invalid type (see valid defined types in this class.)
Since:
BlackBerry API 4.2.0

setConfiguration

public static void setConfiguration(int onTime,
                                    int offTime,
                                    int brightness)
Configures the status LED.

If the LED is capable of displaying multiple colors, calling this method will display red at the specified brightness.

Parameters:
onTime - Time in milliseconds the LED should turn on for if blinking.
offTime - Time in milliseconds the LED should turn off for if blinking.
brightness - One of LED.BRIGHTNESS_12, LED.BRIGHTNESS_25, LED.BRIGHTNESS_50, LED.BRIGHTNESS_100.
Throws:
IllegalArgumentException - if onTime is negative
IllegalArgumentException - if offTime is negative
IllegalArgumentException - if brightness is not one of the predefined brightness levels. (See above)
Since:
BlackBerry API 3.6.0

setConfiguration

public static void setConfiguration(int type,
                                    int onTime,
                                    int offTime,
                                    int brightness)
Configures the specified LED.

If the LED is capable of displaying multiple colors, calling this method will display red at the specified brightness.

Parameters:
type - One of the LED_TYPE_ defines.
onTime - Time in milliseconds the LED should turn on for if blinking.
offTime - Time in milliseconds the LED should turn off for if blinking.
brightness - One of LED.BRIGHTNESS_12, LED.BRIGHTNESS_25, LED.BRIGHTNESS_50, LED.BRIGHTNESS_100.
Throws:
IllegalArgumentException - If the type is an invalid type (see valid defined types in this class.)
IllegalArgumentException - if onTime is negative
IllegalArgumentException - if offTime is negative
IllegalArgumentException - if brightness is not one of the predefined brightness levels. (See above)
Since:
BlackBerry API 4.2.0

setColorConfiguration

public static void setColorConfiguration(int onTime,
                                         int offTime,
                                         int color)
Configures the status LED.

If the LED is not capable of displaying multiple colors, the color parameter will be ignored, and the LED will display at LED.BRIGHTNESS_25.

Parameters:
onTime - Time in milliseconds the LED should turn on for if blinking.
offTime - Time in milliseconds the LED should turn off for if blinking.
color - Color to use, of the form 0x00RRGGBB.
Throws:
IllegalArgumentException - if onTime is negative
IllegalArgumentException - if offTime is negative
IllegalArgumentException - if color is invalid
Since:
BlackBerry API 4.0.0

setState

public static void setState(int state)
Sets the status LED state.

Parameters:
state - One of LED.STATE_ON, LED.STATE_OFF, LED.STATE_BLINKING, LED.STATE_AUDIO_SYNC.
Throws:
IllegalArgumentException - if state is not a valid state.
Since:
BlackBerry API 3.6.0

setState

public static void setState(int type,
                            int state)
Sets the specified LED state. Trackball LED can only be set if supported by device. Use LED.isSupported(int) to determine if trackball LED can be set.

Parameters:
type - One of the LED_TYPE_ defines.
state - One of LED.STATE_ON, LED.STATE_OFF, LED.STATE_BLINKING, LED.STATE_AUDIO_SYNC.
Throws:
IllegalArgumentException - If the type is an invalid type (see valid defined types in this class.)
IllegalArgumentException - if state is not a valid state for that type.
Since:
BlackBerry API 4.2.0

setColorPattern

public static void setColorPattern(int[] pattern,
                                   boolean repeat)
Configures the status LED to light using the pattern provided.

This method is only supported if the LED is capable of displaying multiple colors.

The LED pattern is an int array consisting of color/duration/transition tuples. The color is the RGB color (in the form 0x00RRGGBB), the duration is the duration in milliseconds for this color, and the transition is the time to transistion to the next color in milliseconds. So, a pattern to make the LED blink red would look like this: int[] pattern = { 0x007f0000, 150, 50, 0x00000000, 5850, 50 };

The pattern duration and transition times are interpreted as DWORD values, which are unsigned, so any negative values for these setttings are interpreted as positve values.

Parameters:
pattern - The LED pattern.
repeat - If true, the pattern is repeated continuously. The pattern can be stopped by calling setState( STATE_OFF ).
Throws:
NullPointerException - If the pattern is null.
Since:
BlackBerry API 4.0.0

setColorPattern

public static void setColorPattern(int type,
                                   int[] pattern,
                                   boolean repeat)
Configures the specified LED to light using the pattern provided.

This method is only supported if the LED is capable of displaying multiple colors.

The LED pattern is an int array consisting of color/duration/transition tuples. The color is the RGB color (in the form 0x00RRGGBB), the duration is the duration in milliseconds for this color, and the transition is the time to transistion to the next color in milliseconds. So, a pattern to make the LED blink red would look like this: int[] pattern = { 0x007f0000, 150, 50, 0x00000000, 5850, 50 };

Parameters:
type - One of the LED_TYPE_ defines.
pattern - The LED pattern.
repeat - If true, the pattern is repeated continuously. The pattern can be stopped by calling setState( STATE_OFF ).

The pattern duration and transition times are interpreted as DWORD values, which are unsigned, so any negative values for these setttings are interpreted as positve values.

Throws:
NullPointerException - If the pattern is null.
IllegalArgumentException - If the pattern is an invalid pattern.
Since:
BlackBerry API 4.2.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.