Class TrcRGBLight

java.lang.Object
trclib.archive.TrcRGBLight

public abstract class TrcRGBLight extends Object
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.
  • Field Details

  • Constructor Details

    • TrcRGBLight

      public TrcRGBLight(String instanceName)
      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

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      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

      public TrcRGBLight.RGBColor 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

      public void setColor(TrcRGBLight.RGBColor color)
      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

      public 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.
      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

      public 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. 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

      public void setColor(TrcRGBLight.RGBColor color, double onPeriod)
      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.