Author | Rob Hamerling, Copyright © 2014..2014, all rights reserved. |
Adapted-by | |
Compiler | 2.4q2 |
Common part of several libraries to control a chain of WS2812Bs (RGB LEDs with builtin WS2811). See the description of the implementation variants for user guidance. . The main differences between the variants of the WS2812B libraries are: - The libraries using the PIC hardware (USART or MSSP modules) produce a signal which is generally closer to the specifications in the datasheet than with bit-banging. This is probably the effect of the buffering: while the MSSP or USART is busy with transmitting a byte (with 2 or 3 WS2812B 'bits') the processor is available to prepare the output for the next couple of bits to be transmitted. - A disadvantage of the bit-banging method is that the compiler generates somewhat different code for the 18Fs than for the midrange and enhanced midrange PICs, disrupting the bit timing somewhat. This may cause instable operation. - When using MSSP or USART only one specific pin produces the control signal, while with bit-banging any digital output pin can be used. - With SPI and bit-banging the control signal can be generated with the correct polarity. Since a USART uses negative polarity for data the signal must be inverted. This can be done with an external circuit (a simple one transistor inverter will do) and for Synchronous protocol this is the only option. For Asynchronous protocol this can be used too, but some PICs have a builtin inverter. When available the library will use this feature to produce a positive signal (with the BAUDCON_TXCKP bit) and no external inverter is needed.
- Interrupts are disabled during transmission of data to the chain.
ws2812b_all_color(byte in g, byte in r, byte in b)
ws2812b_refresh(byte in g[], byte in r[], byte in b[])
ws2812b_all_color(byte in g, byte in r, byte in b)
Title: Set all LEDS to same color Input: 3 colors (bytes) Notes: It is assumed that the chain of WS2812Bs has WS2812B_NUM pixels
ws2812b_refresh(byte in g[], byte in r[], byte in b[])
Title: Refresh contents of all pixels of the WS2812B chain. Input: 3 Arrays for green, red and blue Notes: It is assumed that the arrays have a length of WS2812B_NUM bytes