pyupm_apa102 module

class pyupm_apa102.APA102(ledCount, spiBus, batchMode=False, csn=-1)[source]

Bases: object

API for controlling APA102/DotStar RGB LED Strips.

ID: apa102

Name: LED Strip

Category: led

Manufacturer: adafruit

Connection: spi

Link:https://www.adafruit.com/product/2343 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.

C++ includes: apa102.hpp

pushState()[source]

void pushState()

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

setAllLeds(brightness, r, g, b)[source]

void setAllLeds(uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)

Change the color and brightness for all leds

brightness: Brightness value (0-31)

r: Red component (0-255)

g: Green component (0-255)

b: Blue component (0-255)

setBusSpeed(hz)[source]

void setBusSpeed(int 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

hz: Desired bus speed in Hz

setLed(ledIdx, brightness, r, g, b)[source]

void setLed(uint16_t ledIdx, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)

Change the color and brightness for a single led

ledIdx: Index of the LED in the strip (0 based)

brightness: Brightness value (0-31)

r: Red component (0-255)

g: Green component (0-255)

b: Blue component (0-255)

setLedBrightness(ledIdx, brightness)[source]

void setLedBrightness(uint16_t ledIdx, uint8_t brightness)

Change the brightness for a single led

ledIdx: Index of the LED in the strip (0 based)

brightness: Brightness value (0-31)

setLeds(*args)[source]

void setLeds(uint16_t startIdx, uint16_t endIdx, uint8_t *colors)

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

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

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

colors: 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

setLedsBrightness(startIdx, endIdx, brightness)[source]

void setLedsBrightness(uint16_t startIdx, uint16_t endIdx, uint8_t brightness)

Change the brightness for a range of leds

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

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

brightness: Brightness value (0-31)