Package edu.wpi.first.wpilibj
Class AddressableLEDBufferView
java.lang.Object
edu.wpi.first.wpilibj.AddressableLEDBufferView
A view of another addressable LED buffer. Views CANNOT be written directly to an LED strip; the
backing buffer must be written instead. However, views provide an easy way to split a large LED
strip into smaller sections (which may be reversed from the orientation of the LED strip as a
whole) that can be animated individually without modifying LEDs outside those sections.
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.wpi.first.wpilibj.LEDReader
LEDReader.IndexedColorIterator
-
Constructor Summary
ConstructorDescriptionAddressableLEDBufferView
(B backingBuffer, int startingIndex, int endingIndex) Creates a new view of a buffer.AddressableLEDBufferView
(LEDReader backingReader, LEDWriter backingWriter, int startingIndex, int endingIndex) Creates a new view of a buffer. -
Method Summary
Modifier and TypeMethodDescriptionint
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.getLED
(int index) Gets the most recently written color for a particular LED in the buffer.getLED8Bit
(int index) Gets the most recently written color for a particular LED in the buffer.int
Gets the length of the buffer.int
getRed
(int index) Gets the red channel of the color at the specified index.boolean
Checks if this view is reversed with respect to its backing buffer.reversed()
Creates a view that operates on the same range as this one, but goes in reverse order.void
setRGB
(int index, int r, int g, int b) Sets the RGB value for an LED at a specific index on a LED buffer.
-
Constructor Details
-
AddressableLEDBufferView
Creates a new view of a buffer. A view will be reversed if the starting index is after the ending index; writing front-to-back in the view will write in the back-to-front direction on the underlying buffer.- Type Parameters:
B
- the type of the buffer object to create a view for- Parameters:
backingBuffer
- the backing buffer to viewstartingIndex
- the index of the LED in the backing buffer that the view should start fromendingIndex
- the index of the LED in the backing buffer that the view should end on
-
AddressableLEDBufferView
public AddressableLEDBufferView(LEDReader backingReader, LEDWriter backingWriter, int startingIndex, int endingIndex) Creates a new view of a buffer. A view will be reversed if the starting index is after the ending index; writing front-to-back in the view will write in the back-to-front direction on the underlying buffer.- Parameters:
backingReader
- the backing LED data readerbackingWriter
- the backing LED data writerstartingIndex
- the index of the LED in the backing buffer that the view should start fromendingIndex
- the index of the LED in the backing buffer that the view should end on
-
-
Method Details
-
reversed
Creates a view that operates on the same range as this one, but goes in reverse order. This is useful for serpentine runs of LED strips connected front-to-end; simply reverse the view for reversed sections and animations will move in the same physical direction along both strips.- Returns:
- the reversed view
-
getLength
Description copied from interface:LEDReader
Gets the length of the buffer. -
setRGB
Description copied from interface:LEDWriter
Sets the RGB value for an LED at a specific index on a LED buffer. -
getLED
Description copied from interface:LEDReader
Gets the most recently written color for a particular LED in the buffer. -
getLED8Bit
Description copied from interface:LEDReader
Gets the most recently written color for a particular LED in the buffer.- Specified by:
getLED8Bit
in interfaceLEDReader
- Parameters:
index
- the index of the LED- Returns:
- the LED color
-
getRed
Description copied from interface:LEDReader
Gets the red channel of the color at the specified index. -
getGreen
Description copied from interface:LEDReader
Gets the green channel of the color at the specified index. -
getBlue
Description copied from interface:LEDReader
Gets the blue channel of the color at the specified index. -
isReversed
Checks if this view is reversed with respect to its backing buffer.- Returns:
- true if the view is reversed, false otherwise
-