diff --git a/components/modules/ws2812.c b/components/modules/ws2812.c index ee86de79..7369a399 100644 --- a/components/modules/ws2812.c +++ b/components/modules/ws2812.c @@ -36,6 +36,9 @@ static int ws2812_write( lua_State* L ) int top = lua_gettop( L ); for (int stack = 1; stack <= top; stack++) { + if (lua_type( L, stack ) == LUA_TNIL) + continue; + if (lua_type( L, stack ) != LUA_TTABLE) { ws2812_cleanup( L, 0 ); luaL_checktype( L, stack, LUA_TTABLE ); // trigger error diff --git a/docs/en/modules/ws2812.md b/docs/en/modules/ws2812.md index c46a63bd..910f8a0c 100644 --- a/docs/en/modules/ws2812.md +++ b/docs/en/modules/ws2812.md @@ -7,15 +7,13 @@ ws2812 is a library to handle ws2812-like led strips. It works at least on WS2812, WS2812b, APA104, SK6812 (RGB or RGBW). ## ws2812.write() -Send data to one or two led strip using its native format which is generally Green,Red,Blue for RGB strips -and Green,Red,Blue,White for RGBW strips. +Send data to up to 8 led strip using its native format which is generally Green,Red,Blue for RGB strips and Green,Red,Blue,White for RGBW strips. #### Syntax -`ws2812.write(array)` +`ws2812.write(table, ...)` #### Parameters -Array containing an element for each chain (maximum of 8 elements): - +Variable number of tables, each describing a single strip. Required elements are: - `pin` 0 ~ 33, I/O index - `data` payload to be sent to one or more WS2812 like leds through GPIO2