ws2812 - Phantom Lights with RGB Controller (WS2812 Series)#

Adapted Air780E/Air700E Air780EP Air601 Air101/Air103

Note

This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!

Example

-- The library is still in the development stage

ws2812.create(mode, count, id)#

Create Context

Parameters

Incoming Value Type

Explanation

int

Transmission mode, for example ws2812.GPIO, ws2812.PWM, ws2812.SPI

int

RGB Total number of lamps

int

the id of the main parameter, which has different values for different modes.

Return Value

return value type

explanation

userdata

Successful creation returns the context, otherwise nil

Examples

-- GPIO mode, 64 lights, use GPIO9
local leds = ws2812.create(ws2812.GPIO, 64, 9)
-- SPI mode, 32 lights, use SPI1
local leds = ws2812.create(ws2812.SPI, 32, 1)
-- PWM mode, 16 lights, use PWM4
local leds = ws2812.create(ws2812.PWM, 16, 4)
-- HW Mode, 64 lights, using hardware-specific implementation, specific id need to refer to the manual
local leds = ws2812.create(ws2812.RMT, 64, 2)

-- Note: Not all modules support all of the above modes
-- Also, the firmware needs to turn on the corresponding GPIO/SPI/PWM function to use the corresponding mode

ws2812.set(leds,index, R, G, B)#

Set the color of the light

Parameters

Incoming Value Type

Explanation

userdata

Context obtained through ws2812.create

int

Lamp number, starting from 0

int

RGB R value in the value

int

RGB The G value in the value

int

RGB B value in value

Return Value

return value type

explanation

boolean

Returns true if set successfully, otherwise nil

Examples

-- RGB Color-by-color pass
ws2812.set(leds, 5, 0xFF, 0xAA, 0x11)
-- It also supports the passing of a parameter, which is equivalent to the previous one.
ws2812.set(leds, 5, 0xFFAA11)

ws2812.send(leds)#

Send data to device

Parameters

Incoming Value Type

Explanation

userdata

Context obtained through ws2812.create

Return Value

return value type

explanation

boolean

Returns true if set successfully, otherwise nil

Examples

-- There are no more parameters, and the hair is over.
ws2812.send(leds)

ws2812.args(leds, arg0, arg1, arg2, arg3, arg4)#

Configure additional parameters

Parameters

Incoming Value Type

Explanation

userdata

Context obtained through ws2812.create

int

Additional parameters 0

int

Additional parameters 1

int

Additional parameters 2

int

Additional parameters 3

int

Additional parameters 4

Return Value

return value type

explanation

boolean

Returns true if set successfully, otherwise nil

Examples

-- This function is related to the specific mode

--GPIO Mode can adjust the specific delay of T0H T0L, T1H T1L
ws2812.send(leds, t0h, t0l, t1h, t1l)