`ws2812` buffer extracted to new `pixbuf` module. * The new pixbuf module has more functionality than the `ws2812`-specific buffer it replaces. * This is work in progress towards https://github.com/nodemcu/nodemcu-firmware/issues/2916 * The LED driver modules `ws2812`, `ws2801`, `apa102`, and `tm1829` have sprouted `pixbuf` support. * `NTest` tests for `pixbuf` now exist. While here, document the ws2812 UART-based overlapping with mainline execution. Fixes https://github.com/nodemcu/nodemcu-firmware/issues/3140 Co-authored-by: Gregor Hartmann <HHHartmann@users.noreply.github.com>
2.0 KiB
APA102 Module
Since | Origin / Contributor | Maintainer | Source |
---|---|---|---|
2016-01-26 | Robert Foss | Robert Foss | apa102.c |
This module provides Lua access to APA102 RGB LEDs which are similar in function to the common WS2812 addressable LEDs.
DotStar LEDs are 5050-sized LEDs with an embedded micro controller inside the LED. You can set the color/brightness of each LED to 24-bit color (8 bits each red green and blue). Each LED acts like a shift register, reading incoming color data on the input pins, and then shifting the previous color data out on the output pin. By sending a long string of data, you can control an infinite number of LEDs, just tack on more or cut off unwanted LEDs at the end.
source: Adafruit
apa102.write()
Send ABGR data in 8 bits to a APA102 chain.
Syntax
apa102.write(data_pin, clock_pin, string)
Parameters
-
data_pin
any GPIO pin 0, 1, 2, ... -
clock_pin
any GPIO pin 0, 1, 2, ... -
string
payload to be sent to one or more APA102 LEDs.It may be a pixbuf with four channels or a string, composed from a ABGR quadruplet per element:
A1
the first pixel's Intensity channel (0-31)B1
the first pixel's Blue channel (0-255)G1
the first pixel's Green channel (0-255)R1
the first pixel's Red channel (0-255) ... You can connect a lot of APA102 ...A2
,B2
,G2
,R2
are the next APA102s Intensity, Blue, Green and Red channel parameters
Returns
nil
Example 1
a = 31
b = 0
g = 0
r = 255
leds_abgr = string.char(a, b, g, r, a, b, g, r)
apa102.write(2, 3, leds_abgr) -- turn two APA102s to red, connected to data_pin 2 and clock_pin 3
Example 2
-- set the first 30 leds to red
apa102.write(2, 3, string.char(31, 255, 0, 0):rep(30))