WS2812

Dependents:   pelion-example-common

Embed: (wiki syntax)

« Back to documentation index

WS2812 Class Reference

WS2812 Class Reference

Library for the WS2812 RGB LED with integrated controller. More...

#include <WS2812.h>

Public Member Functions

 WS2812 (PinName pin, int size, int zeroHigh, int zeroLow, int oneHigh, int oneLow)
 Constructor.
 ~WS2812 ()
void setDelays (int zeroHigh, int zeroLow, int oneHigh, int oneLow)
 Sets the timing parameters for the bit-banged signal.
void write_offsets (int buf[], int r_offset=0, int g_offset=0, int b_offset=0)
 Writes the given buffer to the LED strip with the given offsets.
void write (int buf[])
 Writes the given buffer to the LED strip NOTE: This function is timing critical, therefore interrupts are disabled during the transmission section.
void useII (BrightnessControl bc)
 Sets the brightness mode.
void setII (unsigned char II)
 Sets the global brightness level.

Detailed Description

Library for the WS2812 RGB LED with integrated controller.

The WS2812 is controller that is built into a range of LEDs

Definition at line 30 of file WS2812.h.


Constructor & Destructor Documentation

WS2812 ( PinName  pin,
int  size,
int  zeroHigh,
int  zeroLow,
int  oneHigh,
int  oneLow 
)

Constructor.

Parameters:
pinOutput pin. Connect to "Din" on the first WS2812 in the strip
sizeNumber of LEDs in your strip
zeroHighHow many NOPs to insert to ensure TOH is properly generated. See library description for more information.
zeroLowHow many NOPs to insert to ensure TOL is properly generated. See library description for more information.
oneHighHow many NOPs to insert to ensure T1H is properly generated. See library description for more information.
oneLowHow many NOPs to insert to ensure T1L is properly generated. See library description for more information.

Definition at line 11 of file WS2812.cpp.

~WS2812 (  )

Destroys instance.

Definition at line 24 of file WS2812.cpp.


Member Function Documentation

void setDelays ( int  zeroHigh,
int  zeroLow,
int  oneHigh,
int  oneLow 
)

Sets the timing parameters for the bit-banged signal.

Parameters:
zeroHighHow many NOPs to insert to ensure TOH is properly generated. See library description for more information.
zeroLowHow many NOPs to insert to ensure TOL is properly generated. See library description for more information.
oneHighHow many NOPs to insert to ensure T1H is properly generated. See library description for more information.
oneLowHow many NOPs to insert to ensure T1L is properly generated. See library description for more information.

Definition at line 29 of file WS2812.cpp.

void setII ( unsigned char  II )

Sets the global brightness level.

Parameters:
IIThe brightness level. Possible values include 0 - 255 (0x00 - 0xFF).

Definition at line 135 of file WS2812.cpp.

void useII ( BrightnessControl  bc )

Sets the brightness mode.

Parameters:
bcThe brightness control. Defaults to OFF. Possible values include OFF, GLOBAL, and PER_PIXEL

Definition at line 126 of file WS2812.cpp.

void write ( int  buf[] )

Writes the given buffer to the LED strip NOTE: This function is timing critical, therefore interrupts are disabled during the transmission section.

Parameters:
bufPointer to the PixelArray buffer

Definition at line 84 of file WS2812.cpp.

void write_offsets ( int  buf[],
int  r_offset = 0,
int  g_offset = 0,
int  b_offset = 0 
)

Writes the given buffer to the LED strip with the given offsets.

NOTE: This function is timing critical, therefore interrupts are disabled during the transmission section.

Parameters:
bufPointer to the PixelArray buffer
r_offsetThe offset where each each pixel pulls its red component. Wraps to beginning if end is reached.
g_offsetThe offset where each each pixel pulls its green component. Wraps to beginning if end is reached.
b_offsetThe offset where each each pixel pulls its blue component. Wraps to beginning if end is reached.

Definition at line 88 of file WS2812.cpp.