SunSPOT API V6.0


com.sun.spot.sensorboard.peripheral
Class TriColorLED

java.lang.Object
  extended by com.sun.spot.resources.Resource
      extended by com.sun.spot.sensorboard.peripheral.TriColorLED
All Implemented Interfaces:
IResource, ILed, ITransducer, ITriColorLED, IBasicPin

public class TriColorLED
extends Resource
implements IBasicPin, ITriColorLED, ITriColorLED

Provides access to the colored LEDs. LED state is now kept by the ITriColorLEDController.


Constructor Summary
TriColorLED(PinDescriptor pidx, ITriColorLEDController cntrl)
          Constructor.
 
Method Summary
 SensorEvent createSensorEvent()
          Create a SensorEvent of the appropriate type for this sensor.
 int getBlue()
          Return the current blue setting.
 LEDColor getColor()
          Get the current color of the LED.
 String getDescription()
          This method returns a readable description of the sensor.
 int getGreen()
          Return the current green setting.
 PinDescriptor getIndex()
          Return the PinDescriptor associated with this LED.
 double getMaxSamplingRate()
          Return the maximum sampling rate per second for this sensor.
 int getRed()
          Return the current red setting.
 boolean isOn()
          Return if the LED is on or off.
 void saveEventState(SensorEvent evt)
          Save the current sensor state in the specified event.
 void setColor(LEDColor rgb)
          Set the color of the LED
 void setColor(LEDColor rgb)
          Set the color of the LED.
 void setOff()
          Turn the LED off.
 void setOn()
          Turn the LED on, using the currently stored intensity values (initially zero).
 void setOn(boolean on)
          Turn the LED on or off
 void setRGB(int redRGB, int greenRGB, int blueRGB)
          Set the colour of the LED.
 
Methods inherited from class com.sun.spot.resources.Resource
addTag, getTags, getTagValue, hasTag, removeTag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.spot.resources.IResource
addTag, getTags, getTagValue, hasTag, removeTag
 
Methods inherited from interface com.sun.spot.resources.IResource
addTag, getTags, getTagValue, hasTag, removeTag
 

Constructor Detail

TriColorLED

public TriColorLED(PinDescriptor pidx,
                   ITriColorLEDController cntrl)
Constructor. Should only be called by EDemoBoard.

Parameters:
pidx - the pin connected to this LED
cntrl - the SPI controller for this LED
Method Detail

getIndex

public PinDescriptor getIndex()
Return the PinDescriptor associated with this LED.

Specified by:
getIndex in interface IBasicPin
Returns:
the PinDescriptor associated with this LED.

setRGB

public void setRGB(int redRGB,
                   int greenRGB,
                   int blueRGB)
Set the colour of the LED. The colour will only change if the LED is on, but the values supplied are stored.

Specified by:
setRGB in interface ITriColorLED
Parameters:
redRGB - the intensity of the red portion, in the range 0-255
greenRGB - the intensity of the green portion, in the range 0-255
blueRGB - the intensity of the blue portion, in the range 0-255

setColor

public void setColor(LEDColor rgb)
Set the color of the LED

Parameters:
rgb - the new color

setColor

public void setColor(LEDColor rgb)
Description copied from interface: ITriColorLED
Set the color of the LED.

Specified by:
setColor in interface ITriColorLED
Parameters:
rgb - the new color

setOn

public void setOn()
Turn the LED on, using the currently stored intensity values (initially zero).

Specified by:
setOn in interface ILed

setOff

public void setOff()
Turn the LED off.

Specified by:
setOff in interface ILed

setOn

public void setOn(boolean on)
Turn the LED on or off

Specified by:
setOn in interface ILed
Parameters:
on - turn LED on if true

isOn

public boolean isOn()
Return if the LED is on or off.

Specified by:
isOn in interface ILed
Returns:
true if the LED is currently on

getRed

public int getRed()
Return the current red setting.

Specified by:
getRed in interface ITriColorLED
Returns:
the current red setting

getGreen

public int getGreen()
Return the current green setting.

Specified by:
getGreen in interface ITriColorLED
Returns:
the current green setting

getBlue

public int getBlue()
Return the current blue setting.

Specified by:
getBlue in interface ITriColorLED
Returns:
the current blue setting

getColor

public LEDColor getColor()
Get the current color of the LED.

Specified by:
getColor in interface ITriColorLED
Returns:
the current color

getDescription

public String getDescription()
Description copied from interface: ITransducer
This method returns a readable description of the sensor. The description should tell the essentials of the sensor, including at least the sensor type (accelerometer, microphone, thermometer). The returned string MUST not be null or an empty string.

Specified by:
getDescription in interface ITransducer
Returns:
the description of the sensor

getMaxSamplingRate

public double getMaxSamplingRate()
Description copied from interface: ITransducer
Return the maximum sampling rate per second for this sensor.

Specified by:
getMaxSamplingRate in interface ITransducer
Returns:
the maximum sampling rate per second for this sensor or 0 if not applicable.

createSensorEvent

public SensorEvent createSensorEvent()
Description copied from interface: ITransducer
Create a SensorEvent of the appropriate type for this sensor.

Specified by:
createSensorEvent in interface ITransducer
Returns:
a SensorEvent of the appropriate type for this sensor.

saveEventState

public void saveEventState(SensorEvent evt)
Description copied from interface: ITransducer
Save the current sensor state in the specified event.

Specified by:
saveEventState in interface ITransducer
Parameters:
evt - the event to store the sensor state in

SunSPOT API V6.0


Copyright © 2006-2010 Oracle. All Rights Reserved.