Package trclib.archive
Class TrcRGBLight
java.lang.Object
trclib.archive.TrcRGBLight
This class implements a platform independent RGB light. Typically, this class is extended by a platform dependent
RGB light device that can be driven by some sort of control signals. The platform dependent RGB light device must
implement the abstract methods required by this class. The abstract methods allow this class to control each light
channel ON and OFF.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
private static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TrcRGBLight.RGBColor
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
private final String
private TrcEvent
private double
private double
private final TrcTaskMgr.TaskObject
private final TrcStateMachine<TrcRGBLight.State>
private final TrcTimer
private final TrcEvent
private final TrcDbgTrace
-
Constructor Summary
ConstructorsConstructorDescriptionTrcRGBLight
(String instanceName) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
getBlue()
This method returns the state of the BLUE light.getColor()
This method returns the current color state of the light.private int
This method returns the current color value of the light.abstract boolean
getGreen()
This method returns the state of the GREEN light.abstract boolean
getRed()
This method returns the state of the RED light.private void
rgbLightTask
(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop) This method is called periodically to execute the RGB light operation.abstract void
setBlue
(boolean enabled) This method sets the BLUE light ON or OFF.void
setColor
(TrcRGBLight.RGBColor color) This method sets the RGB light with the specified color.void
setColor
(TrcRGBLight.RGBColor color, double onPeriod) This method sets the RGB light ON with the specified color for the specified amount of time.void
setColor
(TrcRGBLight.RGBColor color, double onPeriod, double offPeriod) This method blinks the RGB light with the specified color for the specified amount of ON time and OFF time.void
setColor
(TrcRGBLight.RGBColor color, double onPeriod, TrcEvent event) This method sets the RGB light ON with the specified color for the specified amount of time.private void
setColorValue
(int colorValue) This method sets the RGB light with the specified color value.abstract void
setGreen
(boolean enabled) This method sets the GREEN light ON or OFF.abstract void
setRed
(boolean enabled) This method sets the RED light ON or OFF.private void
setTaskEnabled
(boolean enabled) This method enables/disables the RGB light task that keeps track of the blinking period of the RGB light.toString()
This method returns the instance name.
-
Field Details
-
COLOR_BLACK
public static final int COLOR_BLACK- See Also:
-
COLOR_RED
public static final int COLOR_RED- See Also:
-
COLOR_GREEN
public static final int COLOR_GREEN- See Also:
-
COLOR_BLUE
public static final int COLOR_BLUE- See Also:
-
COLOR_YELLOW
public static final int COLOR_YELLOW- See Also:
-
COLOR_MAGENTA
public static final int COLOR_MAGENTA- See Also:
-
COLOR_CYAN
public static final int COLOR_CYAN- See Also:
-
COLOR_WHITE
public static final int COLOR_WHITE- See Also:
-
COLOR_MIN_VALUE
public static final int COLOR_MIN_VALUE- See Also:
-
COLOR_MAX_VALUE
public static final int COLOR_MAX_VALUE- See Also:
-
tracer
-
instanceName
-
rgbLightTaskObj
-
sm
-
timer
-
timerEvent
-
color
-
onPeriod
private double onPeriod -
offPeriod
private double offPeriod -
notifyEvent
-
-
Constructor Details
-
TrcRGBLight
Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the instance name.
-
-
Method Details
-
getRed
public abstract boolean getRed()This method returns the state of the RED light.- Returns:
- true if the RED light is ON, false otherwise.
-
getGreen
public abstract boolean getGreen()This method returns the state of the GREEN light.- Returns:
- true if the GREEN light is ON, false otherwise.
-
getBlue
public abstract boolean getBlue()This method returns the state of the BLUE light.- Returns:
- true if the RED light is BLUE, false otherwise.
-
setRed
public abstract void setRed(boolean enabled) This method sets the RED light ON or OFF.- Parameters:
enabled
- specifies true to turn the RED light ON, false to turn it off.
-
setGreen
public abstract void setGreen(boolean enabled) This method sets the GREEN light ON or OFF.- Parameters:
enabled
- specifies true to turn the GREEN light ON, false to turn it off.
-
setBlue
public abstract void setBlue(boolean enabled) This method sets the BLUE light ON or OFF.- Parameters:
enabled
- specifies true to turn the BLUE light ON, false to turn it off.
-
toString
This method returns the instance name. -
setTaskEnabled
private void setTaskEnabled(boolean enabled) This method enables/disables the RGB light task that keeps track of the blinking period of the RGB light.- Parameters:
enabled
- specifies true to enable RGB light task, false to disable.
-
getColorValue
private int getColorValue()This method returns the current color value of the light.- Returns:
- current color value.
-
getColor
This method returns the current color state of the light.- Returns:
- current color state.
-
setColorValue
private void setColorValue(int colorValue) This method sets the RGB light with the specified color value. If the specified color value is zero, the light is turned OFF.- Parameters:
colorValue
- specifies the color value.
-
setColor
This method sets the RGB light with the specified color. If the specified color is BLACK, the light is turned OFF.- Parameters:
color
- specifies the color.
-
setColor
This method blinks the RGB light with the specified color for the specified amount of ON time and OFF time.- Parameters:
color
- specifies the color.onPeriod
- specifies the period for the light to stay ON.offPeriod
- specifies the period for the light to stay OFF.
-
setColor
This method sets the RGB light ON with the specified color for the specified amount of time. When the amount of time expired, the specified event is signaled.- Parameters:
color
- specifies the color.onPeriod
- specifies the period for the light to stay ON.event
- specifies the event to signal when done.
-
setColor
This method sets the RGB light ON with the specified color for the specified amount of time.- Parameters:
color
- specifies the color.onPeriod
- specifies the period for the light to stay ON.
-
rgbLightTask
private void rgbLightTask(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop) This method is called periodically to execute the RGB light operation.- Parameters:
taskType
- specifies the type of task being run.runMode
- specifies the competition mode that is running. (e.g. Autonomous, TeleOp, Test).slowPeriodicLoop
- specifies true if it is running the slow periodic loop on the main robot thread, false otherwise.
-