Class AddressableLEDBuffer

java.lang.Object
edu.wpi.first.wpilibj.AddressableLEDBuffer
All Implemented Interfaces:
LEDReader, LEDWriter

public class AddressableLEDBuffer extends Object implements LEDReader, LEDWriter
Buffer storage for Addressable LEDs.
  • Constructor Details

    • AddressableLEDBuffer

      public AddressableLEDBuffer(int length)
      Constructs a new LED buffer with the specified length.
      Parameters:
      length - The length of the buffer in pixels
  • Method Details

    • setRGB

      public void setRGB(int index, int r, int g, int b)
      Sets a specific led in the buffer.
      Specified by:
      setRGB in interface LEDWriter
      Parameters:
      index - the index to write
      r - the r value [0-255]
      g - the g value [0-255]
      b - the b value [0-255]
    • getLength

      public int getLength()
      Gets the buffer length.
      Specified by:
      getLength in interface LEDReader
      Returns:
      the buffer length
    • getRed

      public int getRed(int index)
      Gets the red channel of the color at the specified index.
      Specified by:
      getRed in interface LEDReader
      Parameters:
      index - the index of the LED to read
      Returns:
      the value of the red channel, from [0, 255]
    • getGreen

      public int getGreen(int index)
      Gets the green channel of the color at the specified index.
      Specified by:
      getGreen in interface LEDReader
      Parameters:
      index - the index of the LED to read
      Returns:
      the value of the green channel, from [0, 255]
    • getBlue

      public int getBlue(int index)
      Gets the blue channel of the color at the specified index.
      Specified by:
      getBlue in interface LEDReader
      Parameters:
      index - the index of the LED to read
      Returns:
      the value of the blue channel, from [0, 255]
    • createView

      public AddressableLEDBufferView createView(int startingIndex, int endingIndex)
      Creates a view of a subsection of this data buffer, starting from (and including) startingIndex and ending on (and including) endingIndex. Views cannot be written directly to an AddressableLED, but are useful tools for logically separating different sections of an LED strip for independent control.
      Parameters:
      startingIndex - the first index in this buffer that the view should encompass (inclusive)
      endingIndex - the last index in this buffer that the view should encompass (inclusive)
      Returns:
      the view object