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/AddressableLED.h"
  • Field 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"
    • setColorOrder

      public static void setColorOrder(int handle, int colorOrder)
      Sets the color order for the addressable LED output. The default order is GRB.

      This will take effect on the next call to setData(int, byte[]).

      Parameters:
      handle - the Addressable LED handle
      colorOrder - the color order
    • 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 WS2812B and WS2815, 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 and WS2815.

      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"