Class WS281x

java.lang.Object
com.diozero.ws281xj.rpiws281x.WS281x
All Implemented Interfaces:
LedDriverInterface, AutoCloseable

public class WS281x
extends Object
implements LedDriverInterface

Provides support for WS2811B / WS2812B aka Adafriut NeoPixel LEDs via a JNI wrapper around the rpi_ws281x C library.

Also see this implementation.

All colours are represented as 24bit RGB values.

Valid GPIO numbers:

  • 12 / 18 (PWM)
  • 21 / 31 (PCM)
  • 10 (SPI)
  • Constructor Details

    • WS281x

      public WS281x​(int gpioNum, int brightness, int numPixels)
      Parameters:
      gpioNum - GPIO pin to use to drive the LEDs.
      brightness - Brightness level (0..255).
      numPixels - The number of pixels connected.
    • WS281x

      public WS281x​(int frequency, int dmaNum, int gpioNum, int brightness, int numPixels, StripType stripType)
      Parameters:
      frequency - Communication frequency, 800,000 or 400,000.
      dmaNum - DMA number.
      gpioNum - GPIO pin to use to drive the LEDs.
      brightness - Brightness level (0..255).
      numPixels - The number of pixels connected.
      stripType - Strip type
    • WS281x

      public WS281x​(int frequency, int dmaNum, int gpioNum, int brightness, int numPixels, StripType stripType, int channel)
      Parameters:
      frequency - Communication frequency, 800,000 or 400,000.
      dmaNum - DMA number.
      gpioNum - GPIO pin to use to drive the LEDs.
      brightness - Brightness level (0..255).
      numPixels - The number of pixels connected.
      stripType - Strip type
      channel - PWM channel
  • Method Details