Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
284ee8c4
Commit
284ee8c4
authored
Feb 05, 2015
by
Till Klocke
Browse files
Added attribution and fixed documentation in comments
parent
c30002b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/ws2812.c
View file @
284ee8c4
...
@@ -3,6 +3,13 @@
...
@@ -3,6 +3,13 @@
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "auxmods.h"
#include "lrotable.h"
#include "lrotable.h"
/**
* All this code is mostly from http://www.esp8266.com/viewtopic.php?f=21&t=1143&sid=a620a377672cfe9f666d672398415fcb
* from user Markus Gritsch.
* I just put this code into its own module and pushed into a forked repo,
* to easily create a pull request. Thanks to Markus Gritsch for the code.
*
*/
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// -- This WS2812 code must be compiled with -O2 to get the timing right.
// -- This WS2812 code must be compiled with -O2 to get the timing right.
...
@@ -23,11 +30,11 @@ static void ICACHE_FLASH_ATTR send_ws_1(uint8_t gpio)
...
@@ -23,11 +30,11 @@ static void ICACHE_FLASH_ATTR send_ws_1(uint8_t gpio)
i
=
6
;
while
(
i
--
)
GPIO_REG_WRITE
(
GPIO_OUT_W1TC_ADDRESS
,
1
<<
gpio
);
i
=
6
;
while
(
i
--
)
GPIO_REG_WRITE
(
GPIO_OUT_W1TC_ADDRESS
,
1
<<
gpio
);
}
}
// Lua: ws2812(pin, "string")
// Lua: ws2812
.write
(pin, "string")
// Byte triples in the string are interpreted as G R B values.
// Byte triples in the string are interpreted as G R B values.
//
gpio.
ws2812(4, string.char(0, 255, 0)) uses GPIO2 and sets the first LED red.
// ws2812
.write
(4, string.char(0, 255, 0)) uses GPIO2 and sets the first LED red.
//
gpio.
ws2812(3, string.char(0, 0, 255):rep(10)) uses GPIO0 and sets ten LEDs blue.
// ws2812
.write
(3, string.char(0, 0, 255):rep(10)) uses GPIO0 and sets ten LEDs blue.
//
gpio.
ws2812(4, string.char(255, 0, 0, 255, 255, 255)) first LED green, second LED white.
// ws2812
.write
(4, string.char(255, 0, 0, 255, 255, 255)) first LED green, second LED white.
static
int
ICACHE_FLASH_ATTR
lgpio_ws2812
(
lua_State
*
L
)
static
int
ICACHE_FLASH_ATTR
lgpio_ws2812
(
lua_State
*
L
)
{
{
const
uint8_t
pin
=
luaL_checkinteger
(
L
,
1
);
const
uint8_t
pin
=
luaL_checkinteger
(
L
,
1
);
...
...
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