WPILibC++ 2024.3.2
Addressable LED Functions

Functions

HAL_AddressableLEDHandle HAL_InitializeAddressableLED (HAL_DigitalHandle outputPort, int32_t *status)
 Initialize Addressable LED using a PWM Digital handle. More...
 
void HAL_FreeAddressableLED (HAL_AddressableLEDHandle handle)
 Free the Addressable LED Handle. More...
 
void HAL_SetAddressableLEDOutputPort (HAL_AddressableLEDHandle handle, HAL_DigitalHandle outputPort, int32_t *status)
 Set the Addressable LED PWM Digital port. More...
 
void HAL_SetAddressableLEDLength (HAL_AddressableLEDHandle handle, int32_t length, int32_t *status)
 Sets the length of the LED strip. More...
 
void HAL_WriteAddressableLEDData (HAL_AddressableLEDHandle handle, const struct HAL_AddressableLEDData *data, int32_t length, int32_t *status)
 Sets the led output data. More...
 
void HAL_SetAddressableLEDBitTiming (HAL_AddressableLEDHandle handle, int32_t highTime0NanoSeconds, int32_t lowTime0NanoSeconds, int32_t highTime1NanoSeconds, int32_t lowTime1NanoSeconds, int32_t *status)
 Sets the bit timing. More...
 
void HAL_SetAddressableLEDSyncTime (HAL_AddressableLEDHandle handle, int32_t syncTimeMicroSeconds, int32_t *status)
 Sets the sync time. More...
 
void HAL_StartAddressableLEDOutput (HAL_AddressableLEDHandle handle, int32_t *status)
 Starts the output. More...
 
void HAL_StopAddressableLEDOutput (HAL_AddressableLEDHandle handle, int32_t *status)
 Stops the output. More...
 

Detailed Description

Function Documentation

◆ HAL_FreeAddressableLED()

void HAL_FreeAddressableLED ( HAL_AddressableLEDHandle  handle)

Free the Addressable LED Handle.

Parameters
[in]handlethe Addressable LED handle to free

◆ HAL_InitializeAddressableLED()

HAL_AddressableLEDHandle HAL_InitializeAddressableLED ( HAL_DigitalHandle  outputPort,
int32_t *  status 
)

Initialize Addressable LED using a PWM Digital handle.

Parameters
[in]outputPorthandle of the digital port for PWM
[out]statusthe error code, or 0 for success
Returns
Addressable LED handle

◆ HAL_SetAddressableLEDBitTiming()

void HAL_SetAddressableLEDBitTiming ( HAL_AddressableLEDHandle  handle,
int32_t  highTime0NanoSeconds,
int32_t  lowTime0NanoSeconds,
int32_t  highTime1NanoSeconds,
int32_t  lowTime1NanoSeconds,
int32_t *  status 
)

Sets the bit timing.

By default, the driver is set up to drive WS2812Bs, so nothing needs to be set for those.

Parameters
[in]handlethe Addressable LED handle
[in]highTime0NanoSecondshigh time for 0 bit (default 400ns)
[in]lowTime0NanoSecondslow time for 0 bit (default 900ns)
[in]highTime1NanoSecondshigh time for 1 bit (default 900ns)
[in]lowTime1NanoSecondslow time for 1 bit (default 600ns)
[out]statusthe error code, or 0 for success

◆ HAL_SetAddressableLEDLength()

void HAL_SetAddressableLEDLength ( HAL_AddressableLEDHandle  handle,
int32_t  length,
int32_t *  status 
)

Sets the length of the LED strip.

The max length is 5460 LEDs.

Parameters
[in]handlethe Addressable LED handle
[in]lengththe strip length
[out]statusthe error code, or 0 for success

◆ HAL_SetAddressableLEDOutputPort()

void HAL_SetAddressableLEDOutputPort ( HAL_AddressableLEDHandle  handle,
HAL_DigitalHandle  outputPort,
int32_t *  status 
)

Set the Addressable LED PWM Digital port.

Parameters
[in]handlethe Addressable LED handle
[in]outputPortThe digital handle of the PWM port
[out]statusthe error code, or 0 for success

◆ HAL_SetAddressableLEDSyncTime()

void HAL_SetAddressableLEDSyncTime ( HAL_AddressableLEDHandle  handle,
int32_t  syncTimeMicroSeconds,
int32_t *  status 
)

Sets the sync time.

The sync time is the time to hold output so LEDs enable. Default set for WS2812B.

Parameters
[in]handlethe Addressable LED handle
[in]syncTimeMicroSecondsthe sync time (default 280us)
[out]statusthe error code, or 0 for success

◆ HAL_StartAddressableLEDOutput()

void HAL_StartAddressableLEDOutput ( HAL_AddressableLEDHandle  handle,
int32_t *  status 
)

Starts the output.

The output writes continuously.

Parameters
[in]handlethe Addressable LED handle
[out]statusthe error code, or 0 for success

◆ HAL_StopAddressableLEDOutput()

void HAL_StopAddressableLEDOutput ( HAL_AddressableLEDHandle  handle,
int32_t *  status 
)

Stops the output.

Parameters
[in]handlethe Addressable LED handle
[out]statusthe error code, or 0 for success

◆ HAL_WriteAddressableLEDData()

void HAL_WriteAddressableLEDData ( HAL_AddressableLEDHandle  handle,
const struct HAL_AddressableLEDData data,
int32_t  length,
int32_t *  status 
)

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
[in]handlethe Addressable LED handle
[in]datathe buffer to write
[in]lengththe strip length
[out]statusthe error code, or 0 for success