Class TrcI2cLEDPanel

java.lang.Object
trclib.archive.TrcI2cLEDPanel

public abstract class TrcI2cLEDPanel extends Object
This class implements a platform independent I2C LED panel. This class is intended to be extended by a platform dependent I2C LED panel which provides the abstract methods required by this class. This class provides the APIs to assemble command requests and send them over to the panel asynchronously.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
     
    private final String
     
    private final TrcDbgTrace
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TrcI2cLEDPanel(String instanceName)
    Constructor: Creates an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    asyncWriteData(byte[] data)
    This method writes the data buffer to the device asynchronously.
    void
    This method clears all text lines in the lines array.
    void
    clearTextLine(int index)
    This method clears the specified line in the lines array.
    int
    color(int red, int green, int blue)
    This method converts the specified RGB values into a 16-bit color value in 565 format (5-bit R, 6-bit G and 5-bit B: RRRRRGGGGGGBBBBB).
    private void
    This method sends the command string to the I2C device.
    void
    setDelay(int delay)
    This method sets the Arduino loop delay.
    void
    setTextLine(int index, int x, int y, int fontColor, int orientation, int fontSize, int scrollInc, String text)
    This method sets the specified line in the LED panel with all the text info for displaying text on the panel.
    This method returns the instance name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • TrcI2cLEDPanel

      public TrcI2cLEDPanel(String instanceName)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
  • Method Details

    • asyncWriteData

      public abstract void asyncWriteData(byte[] data)
      This method writes the data buffer to the device asynchronously.
      Parameters:
      data - specifies the data buffer.
    • toString

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • setTextLine

      public void setTextLine(int index, int x, int y, int fontColor, int orientation, int fontSize, int scrollInc, String text)
      This method sets the specified line in the LED panel with all the text info for displaying text on the panel. Note that the (x, y) coordinates is rotation sensitive. If rotation is 0, the text orientation is normal horizontal and (0, 0) corresponds to the upper left corner of the physical panel. If rotation is 2, the text orientation is inverted horizontal and (0, 0) corresponds to the lower right corner of the physica panel.
      Parameters:
      index - specifies the line index of the array.
      x - specifies the x coordinate of the upper left corner of the text rectangle.
      y - specifies the y coordinate of the upper left corner of the text rectangle.
      fontColor - specifies the font color for displaying the text.
      orientation - specifies the text orientation (0: normal horizontal, 1: clockwise vertical, 2: inverted horizontal, 3: anti-clockwise vertical).
      fontSize - specifies the size of the font (1: 6x8, 2: 12x16, 3: 18x24, 4: 24x32).
      scrollInc - specifies the scroll increment (0: no scroll, 1: scroll to the right, -1: scroll to the left).
      text - specifies the text string to be displayed.
    • clearTextLine

      public void clearTextLine(int index)
      This method clears the specified line in the lines array.
      Parameters:
      index - specifies the line index of the array.
    • clearAllTextLines

      public void clearAllTextLines()
      This method clears all text lines in the lines array.
    • setDelay

      public void setDelay(int delay)
      This method sets the Arduino loop delay. This effectively controls how fast the text will scroll.
      Parameters:
      delay - specifies the delay in msec.
    • color

      public int color(int red, int green, int blue)
      This method converts the specified RGB values into a 16-bit color value in 565 format (5-bit R, 6-bit G and 5-bit B: RRRRRGGGGGGBBBBB).
      Parameters:
      red - specifies the red value.
      green - specifies the green value.
      blue - specifies the blue value.
      Returns:
      16-bit color value in 565 format.
    • sendCommand

      private void sendCommand(String command)
      This method sends the command string to the I2C device. If the command string is longer than 32 bytes, it will break down the command string into multiple I2C requests so that they can be reassembled on the device side.
      Parameters:
      command - specifies the command string to be sent to the I2C device.