mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[hal] Fix and document addressable LED timings (#5272)
HAL_SetAddressableLEDBitTiming swapped high and low timings for whatever was written to it. This fixes that bug. Additionally, the API has been updated to take high time first, and then low time. This is due to this being the physical data format, so having the API match is clearer. Additionally, update the docs with the defaults.
This commit is contained in:
@@ -10,7 +10,9 @@ import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.hal.PWMJNI;
|
||||
|
||||
/**
|
||||
* A class for driving addressable LEDs, such as WS2812s and NeoPixels.
|
||||
* A class for driving addressable LEDs, such as WS2812Bs and NeoPixels.
|
||||
*
|
||||
* <p>By default, the timing supports WS2812B LEDs, but is configurable using setBitTiming()
|
||||
*
|
||||
* <p>Only 1 LED driver is currently supported by the roboRIO.
|
||||
*/
|
||||
@@ -67,32 +69,32 @@ public class AddressableLED implements AutoCloseable {
|
||||
/**
|
||||
* Sets the bit timing.
|
||||
*
|
||||
* <p>By default, the driver is set up to drive WS2812s, so nothing needs to be set for those.
|
||||
* <p>By default, the driver is set up to drive WS2812Bs, so nothing needs to be set for those.
|
||||
*
|
||||
* @param lowTime0NanoSeconds low time for 0 bit
|
||||
* @param highTime0NanoSeconds high time for 0 bit
|
||||
* @param lowTime1NanoSeconds low time for 1 bit
|
||||
* @param highTime1NanoSeconds high time for 1 bit
|
||||
* @param highTime0NanoSeconds high time for 0 bit (default 400ns)
|
||||
* @param lowTime0NanoSeconds low time for 0 bit (default 900ns)
|
||||
* @param highTime1NanoSeconds high time for 1 bit (default 900ns)
|
||||
* @param lowTime1NanoSeconds low time for 1 bit (default 600ns)
|
||||
*/
|
||||
public void setBitTiming(
|
||||
int lowTime0NanoSeconds,
|
||||
int highTime0NanoSeconds,
|
||||
int lowTime1NanoSeconds,
|
||||
int highTime1NanoSeconds) {
|
||||
int lowTime0NanoSeconds,
|
||||
int highTime1NanoSeconds,
|
||||
int lowTime1NanoSeconds) {
|
||||
AddressableLEDJNI.setBitTiming(
|
||||
m_handle,
|
||||
lowTime0NanoSeconds,
|
||||
highTime0NanoSeconds,
|
||||
lowTime1NanoSeconds,
|
||||
highTime1NanoSeconds);
|
||||
lowTime0NanoSeconds,
|
||||
highTime1NanoSeconds,
|
||||
lowTime1NanoSeconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sync time.
|
||||
*
|
||||
* <p>The sync time is the time to hold output so LEDs enable. Default set for WS2812.
|
||||
* <p>The sync time is the time to hold output so LEDs enable. Default set for WS2812B.
|
||||
*
|
||||
* @param syncTimeMicroSeconds the sync time
|
||||
* @param syncTimeMicroSeconds the sync time (default 280us)
|
||||
*/
|
||||
public void setSyncTime(int syncTimeMicroSeconds) {
|
||||
AddressableLEDJNI.setSyncTime(m_handle, syncTimeMicroSeconds);
|
||||
|
||||
Reference in New Issue
Block a user