32 lines
905 B
Markdown
32 lines
905 B
Markdown
|
# APA102 Module
|
||
|
|
||
|
## 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 should be composed from a AGRB quadruplet per element.
|
||
|
- `A1` the first pixel's Intensity channel (0-31)
|
||
|
- `B1` the first pixel's Blue channel (0-255)<br />
|
||
|
- `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 ...
|
||
|
- `A1`, `G2`, `R2`, `B2` are the next APA102s Intensity, Blue, Green and channel parameters
|
||
|
|
||
|
#### Returns
|
||
|
`nil`
|
||
|
|
||
|
```lua
|
||
|
a = 31
|
||
|
g = 0
|
||
|
r = 255
|
||
|
b = 0
|
||
|
leds_bgr = string.char(a, g, r, b, a, g, r, b)
|
||
|
apa102.write(2, 3, leds_abgr) -- turn two APA102s to red, connected to data_pin 2 and clock_pin 3
|
||
|
```
|