UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

APA102 Class

Module: apa102

APA102 LED Strips provide individually controllable LEDs through a SPI interface. For each LED, brightness (0-31) and RGB (0-255) values can be set.
apa102.jpg

Methods

APA102

(
  • ledCount
  • spiBus
  • batchMode
  • csn
)
Number

Instantiates a new APA102 LED Strip

Parameters:

  • ledCount Number

    Number of APA102 leds in the strip

  • spiBus Number

    SPI Bus number

  • batchMode Boolean

    (optional) Immediately write to SPI (false, default) or wait for a pushState call (true)

  • csn Number

    (optional) Chip Select Pin

Returns:

Number:

setLed

(
  • ledIdx
  • brightness
  • r
  • g
  • b
)

Change the color and brightness for a single led

Parameters:

  • ledIdx Number

    Index of the LED in the strip (0 based)

  • brightness Number

    Brightness value (0-31)

  • r Number

    Red component (0-255)

  • g Number

    Green component (0-255)

  • b Number

    Blue component (0-255)

setLedBrightness

(
  • ledIdx
  • brightness
)

Change the brightness for a single led

Parameters:

  • ledIdx Number

    Index of the LED in the strip (0 based)

  • brightness Number

    Brightness value (0-31)

setAllLeds

(
  • brightness
  • r
  • g
  • b
)

Change the color and brightness for all leds

Parameters:

  • brightness Number

    Brightness value (0-31)

  • r Number

    Red component (0-255)

  • g Number

    Green component (0-255)

  • b Number

    Blue component (0-255)

setLeds

(
  • startIdx
  • endIdx
  • brightness
  • r
  • g
  • b
)

Change the color and brightness for a range of leds

Parameters:

  • startIdx Number

    Start index of the range of LEDs in the strip (0 based)

  • endIdx Number

    End index of the range of LEDs in the strip (0 based)

  • brightness Number

    Brightness value (0-31)

  • r Number

    Red component (0-255)

  • g Number

    Green component (0-255)

  • b Number

    Blue component (0-255)

setLedsBrightness

(
  • startIdx
  • endIdx
  • brightness
)

Change the brightness for a range of leds

Parameters:

  • startIdx Number

    Start index of the range of LEDs in the strip (0 based)

  • endIdx Number

    End index of the range of LEDs in the strip (0 based)

  • brightness Number

    Brightness value (0-31)

setLeds

(
  • startIdx
  • endIdx
  • colors
)

(Advanced) Manually control the colors and brightness of a range of LEDS Best used to maximize performance

Parameters:

  • startIdx Number

    Start index of the range of LEDs to update (0 based)

  • endIdx Number

    End index of the range of LEDs to update (0 based)

  • colors Uint8_t *

    Pointer to an array of bytes. Each color is described as the following: B1: Brightness (224-255) B2: Blue (0-255) B3: Green (0-255) B4: Red (0-255) No check done on the boundaries

setBusSpeed

(
  • hz
)

Change the speed/frequency of the SPI bus Note: Slower speeds will allow driving longer strips without having to condition the clock signal with extra hardware

Parameters:

  • hz Number

    Desired bus speed in Hz

pushState

()

Outputs the current LED data to the SPI bus Note: Only required if batch mode is set to TRUE