AddressableLED
- class wpilib.AddressableLED(port: int)
Bases:
pybind11_object
A class for driving addressable LEDs, such as WS2812B, WS2815, and NeoPixels.
By default, the timing supports WS2812B and WS2815 LEDs, but is configurable using SetBitTiming()
Some LEDs use a different color order than the default GRB. The color order is configurable using SetColorOrder().
Only 1 LED driver is currently supported by the roboRIO. However, multiple LED strips can be connected in series and controlled from the single driver.
Constructs a new driver for a specific port.
- Parameters:
port – the output port to use (Must be a PWM header)
- class ColorOrder(value: int)
Bases:
pybind11_object
Order that color data is sent over the wire.
Members:
kRGB : ///< RGB order
kRBG : ///< RBG order
kBGR : ///< BGR order
kBRG : ///< BRG order
kGBR : ///< GBR order
kGRB : ///< GRB order. This is the default order.
- kBGR = <ColorOrder.kBGR: 2>
- kBRG = <ColorOrder.kBRG: 3>
- kGBR = <ColorOrder.kGBR: 4>
- kGRB = <ColorOrder.kGRB: 5>
- kRBG = <ColorOrder.kRBG: 1>
- kRGB = <ColorOrder.kRGB: 0>
- property name
- property value
- class LEDData(*args, **kwargs)
Bases:
AddressableLEDData
Overloaded function.
__init__(self: wpilib._wpilib.AddressableLED.LEDData) -> None
__init__(self: wpilib._wpilib.AddressableLED.LEDData, r: int, g: int, b: int) -> None
- setHSV(h: int, s: int, v: int) None
A helper method to set all values of the LED.
- Parameters:
h – the h value [0-180]
s – the s value [0-255]
v – the v value [0-255]
- setLED(*args, **kwargs)
Overloaded function.
setLED(self: wpilib._wpilib.AddressableLED.LEDData, color: wpilib._wpilib.Color) -> None
setLED(self: wpilib._wpilib.AddressableLED.LEDData, color: wpilib._wpilib.Color8Bit) -> None
- setRGB(r: int, g: int, b: int) None
A helper method to set all values of the LED.
- Parameters:
r – the r value [0-255]
g – the g value [0-255]
b – the b value [0-255]
- setBitTiming(highTime0: wpimath.units.nanoseconds, lowTime0: wpimath.units.nanoseconds, highTime1: wpimath.units.nanoseconds, lowTime1: wpimath.units.nanoseconds) None
Sets the bit timing.
By default, the driver is set up to drive WS2812B and WS2815, so nothing needs to be set for those.
- Parameters:
highTime0 – high time for 0 bit (default 400ns)
lowTime0 – low time for 0 bit (default 900ns)
highTime1 – high time for 1 bit (default 900ns)
lowTime1 – low time for 1 bit (default 600ns)
- setColorOrder(order: wpilib._wpilib.AddressableLED.ColorOrder) None
Sets the color order for this AddressableLED. The default order is GRB.
This will take effect on the next call to SetData().
- Parameters:
order – the color order
- setData(ledData: List[wpilib._wpilib.AddressableLED.LEDData]) None
Sets the led output data.
If the output is enabled, this will start writing the next data cycle. It is safe to call, even while output is enabled.
- Parameters:
ledData – the buffer to write
- setLength(length: int) None
Sets the length of the LED strip.
Calling this is an expensive call, so its best to call it once, then just update data.
The max length is 5460 LEDs.
- Parameters:
length – the strip length
- setSyncTime(syncTime: wpimath.units.microseconds) None
Sets the sync time.
The sync time is the time to hold output so LEDs enable. Default set for WS2812B and WS2815.
- Parameters:
syncTime – the sync time (default 280us)
- start() None
Starts the output.
The output writes continuously.
- stop() None
Stops the output.