Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
75580f5d
Commit
75580f5d
authored
Jan 11, 2016
by
devsaurus
Browse files
transferred ws2812 module documentation
parent
4878abc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
docs/en/modules/ws2812.md
0 → 100644
View file @
75580f5d
# WS2812 Module
## ws2812.write()
Send GRB data in 8 bits to a WS2812 chain.
#### Syntax
`ws2812.writegrb(pin, string)`
#### Parameters
-
`pin`
any GPIO pin 0, 1, 2, ...
-
`string`
payload to be sent to one or more WS2812 LEDs.
It should be composed from a GRB triplet per element.
-
`G1`
the first pixel's Green channel (0-255)
-
`R1`
the first pixel's Red channel (0-255)
-
`B1`
the first pixel's Blue channel (0-255)
... You can connect a lot of WS2812 ...
-
`G2`
,
`R2`
,
`B2`
are the next WS2812's Green, Red, and Blue channel parameters
#### Returns
`nil`
```
lua
g
=
0
r
=
255
b
=
0
leds_grb
=
string.char
(
g
,
r
,
b
,
g
,
r
,
b
)
ws2812
.
write
(
2
,
leds_grb
)
-- turn two WS2812Bs to red, connected to pin 2
```
## ws2812.writergb()
Send GRB data in 8bits to a WS2812 chain.
#### Syntax
`ws2812.writergb(pin, string)`
#### Parameters
-
`pin`
any GPIO pin 0, 1, 2, ...
-
`string`
payload to be sent to one or more WS2812 LEDs.
It should be composed from an RGB triplet per element.
-
`R1`
the first pixel's Red channel (0-255)
-
`G1`
the first pixel's Green channel (0-255)
-
`B1`
the first pixel's Blue channel (0-255)
... You can connect a lot of WS2812 ...
-
`R2`
,
`G2`
,
`B2`
are the next WS2812's Red, Green, and Blue channel parameters
#### Returns
`nil`
#### Example
```
lua
leds_rgb
=
string.char
(
255
,
0
,
0
,
0
,
255
,
0
,
0
,
0
,
255
)
ws2812
.
writergb
(
2
,
leds_rgb
)
-- turn three WS2812Bs to red, green, and blue respectively
```
mkdocs.yml
View file @
75580f5d
...
...
@@ -51,5 +51,6 @@ pages:
-
'
u8g'
:
'
en/modules/u8g.md'
-
'
uart'
:
'
en/modules/uart.md'
-
'
ucg'
:
'
en/modules/ucg.md'
-
'
ws2812'
:
'
en/modules/ws2812'
-
Deutsch
:
-
Home
:
'
de/index.md'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment