Class AddressableLEDBuffer

java.lang.Object
edu.wpi.first.wpilibj.AddressableLEDBuffer

public class AddressableLEDBuffer
extends Object
Buffer storage for Addressable LEDs.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static interface  AddressableLEDBuffer.IndexedColorIterator
    A functional interface that allows for iteration over an LED buffer without manually writing an indexed for-loop.
  • Constructor Summary

    Constructors 
    Constructor Description
    AddressableLEDBuffer​(int length)
    Constructs a new LED buffer with the specified length.
  • Method Summary

    Modifier and Type Method Description
    void forEach​(AddressableLEDBuffer.IndexedColorIterator iterator)
    Iterates over the LEDs in the buffer, starting from index 0.
    int getBlue​(int index)
    Gets the blue channel of the color at the specified index.
    int getGreen​(int index)
    Gets the green channel of the color at the specified index.
    Color getLED​(int index)
    Gets the color at the specified index.
    Color8Bit getLED8Bit​(int index)
    Gets the color at the specified index.
    int getLength()
    Gets the buffer length.
    int getRed​(int index)
    Gets the red channel of the color at the specified index.
    void setHSV​(int index, int h, int s, int v)
    Sets a specific led in the buffer.
    void setLED​(int index, Color color)
    Sets a specific LED in the buffer.
    void setLED​(int index, Color8Bit color)
    Sets a specific LED in the buffer.
    void setRGB​(int index, int r, int g, int b)
    Sets a specific led in the buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • setRGB

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

      public void setHSV​(int index, int h, int s, int v)
      Sets a specific led in the buffer.
      Parameters:
      index - the index to write
      h - the h value [0-180)
      s - the s value [0-255]
      v - the v value [0-255]
    • setLED

      public void setLED​(int index, Color color)
      Sets a specific LED in the buffer.
      Parameters:
      index - The index to write
      color - The color of the LED
    • setLED

      public void setLED​(int index, Color8Bit color)
      Sets a specific LED in the buffer.
      Parameters:
      index - The index to write
      color - The color of the LED
    • getLength

      public int getLength()
      Gets the buffer length.
      Returns:
      the buffer length
    • getLED8Bit

      public Color8Bit getLED8Bit​(int index)
      Gets the color at the specified index.
      Parameters:
      index - the index to get
      Returns:
      the LED color at the specified index
    • getLED

      public Color getLED​(int index)
      Gets the color at the specified index.
      Parameters:
      index - the index to get
      Returns:
      the LED color at the specified index
    • getRed

      public int getRed​(int index)
      Gets the red channel of the color at the specified index.
      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.
      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.
      Parameters:
      index - the index of the LED to read
      Returns:
      the value of the blue channel, from [0, 255]
    • forEach

      Iterates over the LEDs in the buffer, starting from index 0. The iterator function is passed the current index of iteration, along with the values for the red, green, and blue components of the color written to the LED at that index.
      Parameters:
      iterator - the iterator function to call for each LED in the buffer.