Library for the WS2812 LED Driver. Uses bit banging and nops for precise timing. Number of nops executed are configurable at run time.
Dependents: WS2812_Example WS2812_Example_fade Lamp_03 Lamp_04 ... more
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:
-
pin Output pin. Connect to "Din" on the first WS2812 in the strip size Number of LEDs in your strip zeroHigh How many NOPs to insert to ensure TOH is properly generated. See library description for more information. zeroLow How many NOPs to insert to ensure TOL is properly generated. See library description for more information. oneHigh How many NOPs to insert to ensure T1H is properly generated. See library description for more information. oneLow How many NOPs to insert to ensure T1L is properly generated. See library description for more information.
Definition at line 3 of file WS2812.cpp.
~WS2812 | ( | ) |
Destroys instance.
Definition at line 16 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:
-
zeroHigh How many NOPs to insert to ensure TOH is properly generated. See library description for more information. zeroLow How many NOPs to insert to ensure TOL is properly generated. See library description for more information. oneHigh How many NOPs to insert to ensure T1H is properly generated. See library description for more information. oneLow How many NOPs to insert to ensure T1L is properly generated. See library description for more information.
Definition at line 21 of file WS2812.cpp.
void setII | ( | unsigned char | II ) |
Sets the global brightness level.
- Parameters:
-
II The brightness level. Possible values include 0 - 255 (0x00 - 0xFF).
Definition at line 127 of file WS2812.cpp.
void useII | ( | BrightnessControl | bc ) |
Sets the brightness mode.
- Parameters:
-
bc The brightness control. Defaults to OFF. Possible values include OFF, GLOBAL, and PER_PIXEL
Definition at line 118 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:
-
buf Pointer to the PixelArray buffer
Definition at line 76 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:
-
buf Pointer to the PixelArray buffer r_offset The offset where each each pixel pulls its red component. Wraps to beginning if end is reached. g_offset The offset where each each pixel pulls its green component. Wraps to beginning if end is reached. b_offset The offset where each each pixel pulls its blue component. Wraps to beginning if end is reached.
Definition at line 80 of file WS2812.cpp.
Generated on Tue Jul 12 2022 22:53:55 by 1.7.2