Class AddressableLEDJNI

java.lang.Object
edu.wpi.first.hal.JNIWrapper
edu.wpi.first.hal.AddressableLEDJNI

public class AddressableLEDJNI
extends JNIWrapper
Addressable LED HAL JNI Methods.
See Also:
"hal/AdressableLED.h"
  • Nested Class Summary

    Nested classes/interfaces inherited from class edu.wpi.first.hal.JNIWrapper

    JNIWrapper.Helper
  • Constructor Summary

    Constructors 
    Constructor Description
    AddressableLEDJNI()  
  • Method Summary

    Modifier and Type Method Description
    static void free​(int handle)
    Free the Addressable LED Handle.
    static int initialize​(int pwmHandle)
    Initialize Addressable LED using a PWM Digital handle.
    static void setBitTiming​(int handle, int highTime0NanoSeconds, int lowTime0NanoSeconds, int highTime1NanoSeconds, int lowTime1NanoSeconds)
    Sets the bit timing.
    static void setData​(int handle, byte[] data)
    Sets the led output data.
    static void setLength​(int handle, int length)
    Sets the length of the LED strip.
    static void setSyncTime​(int handle, int syncTimeMicroSeconds)
    Sets the sync time.
    static void start​(int handle)
    Starts the output.
    static void stop​(int handle)
    Stops the output.

    Methods inherited from class edu.wpi.first.hal.JNIWrapper

    forceLoad, suppressUnused

    Methods inherited from class java.lang.Object

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

  • Method Details

    • initialize

      public static int initialize​(int pwmHandle)
      Initialize Addressable LED using a PWM Digital handle.
      Parameters:
      pwmHandle - handle of the digital port for PWM
      Returns:
      Addressable LED handle
      See Also:
      "HAL_InitializeAddressableLED"
    • free

      public static void free​(int handle)
      Free the Addressable LED Handle.
      Parameters:
      handle - the Addressable LED handle to free
      See Also:
      "HAL_FreeAddressableLED"
    • setLength

      public static void setLength​(int handle, int length)
      Sets the length of the LED strip.

      The max length is 5460 LEDs.

      Parameters:
      handle - the Addressable LED handle
      length - the strip length
      See Also:
      "HAL_SetAddressableLEDLength"
    • setData

      public static void setData​(int handle, byte[] data)
      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:
      handle - the Addressable LED handle
      data - the buffer to write
      See Also:
      "HAL_WriteAddressableLEDData"
    • setBitTiming

      public static void setBitTiming​(int handle, int highTime0NanoSeconds, int lowTime0NanoSeconds, int highTime1NanoSeconds, int lowTime1NanoSeconds)
      Sets the bit timing.

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

      Parameters:
      handle - the Addressable LED handle
      highTime0NanoSeconds - high time for 0 bit (default 400ns)
      lowTime0NanoSeconds - low time for 0 bit (default 900ns)
      highTime1NanoSeconds - high time for 1 bit (default 900ns)
      lowTime1NanoSeconds - low time for 1 bit (default 600ns)
      See Also:
      "HAL_SetAddressableLEDBitTiming"
    • setSyncTime

      public static void setSyncTime​(int handle, int syncTimeMicroSeconds)
      Sets the sync time.

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

      Parameters:
      handle - the Addressable LED handle
      syncTimeMicroSeconds - the sync time (default 280us)
      See Also:
      "HAL_SetAddressableLEDSyncTime"
    • start

      public static void start​(int handle)
      Starts the output.

      The output writes continuously.

      Parameters:
      handle - the Addressable LED handle
      See Also:
      "HAL_StartAddressableLEDOutput"
    • stop

      public static void stop​(int handle)
      Stops the output.
      Parameters:
      handle - the Addressable LED handle
      See Also:
      "HAL_StopAddressableLEDOutput"