Driver for Data Over Power addressable LEDs. More...
#include <DOPLED.h>
Public Member Functions | |
| DOPLED (uint8_t pin, uint8_t timeBase_us) | |
| Creates a DOPLED Object with a specific timebase. | |
| DOPLED (uint8_t pin) | |
| Creates a DOPLED Object. | |
| void | begin () |
| Enables the ESP32's RMT output. | |
| void | end () |
| Disables the ESP32's RMT output and set the pin LOW. | |
| void | sendRaw (uint8_t *data, size_t size) |
| void | fillMatchingAddresses (uint8_t mask, uint8_t address, uint8_t r, uint8_t g, uint8_t b) |
| void | writePixel (uint8_t address, uint8_t r, uint8_t g, uint8_t b) |
| Sets a specific pixel to a specific color. | |
| void | fillAll (uint8_t r, uint8_t g, uint8_t b) |
| Fills all pixels with a specific color. | |
| void | fillRandomGroups (uint8_t mask, uint8_t address, uint8_t r, uint8_t g, uint8_t b) |
| Creates random groups and sets them to a specific color. | |
| void | setFlags (uint8_t flagByte) |
| bool | transmitDone () |
| Checks if the previous transmission has completed. | |
| ~DOPLED () | |
Driver for Data Over Power addressable LEDs.
| DOPLED::DOPLED | ( | uint8_t | pin, |
| uint8_t | timeBase_us ) |
Creates a DOPLED Object with a specific timebase.
The timebase defines the width of each pulse. Different LEDs may tolerate different timings. Typical value is 70-120us. Lower timings allow faster updates but may not work with all LEDs.
| pin | ESP32 output pin |
| timeBase_us | Timebase in microseconds (default: 70us) |
| DOPLED::DOPLED | ( | uint8_t | pin | ) |
Creates a DOPLED Object.
| pin | ESP32 output pin |
| DOPLED::~DOPLED | ( | ) |
Destructor for the DOPLED class. Cleans up the RMT channel and encoder.
| void DOPLED::begin | ( | ) |
Enables the ESP32's RMT output.
| void DOPLED::end | ( | ) |
Disables the ESP32's RMT output and set the pin LOW.
DOP LEDs use the same amount of power when displaying black as when displaying white. Call this method when the LEDs are off for long duations to reduce power consumption.
| void DOPLED::fillAll | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b ) |
Fills all pixels with a specific color.
| r | Red value (0-255) |
| g | Green value (0-255) |
| b | Blue value (0-255) |
| void DOPLED::fillMatchingAddresses | ( | uint8_t | mask, |
| uint8_t | address, | ||
| uint8_t | r, | ||
| uint8_t | g, | ||
| uint8_t | b ) |
Sets a group of pixels according to the mask and address.
The mask determines which bits of the pixel address are checked by the LEDs. Pixels matching the specified bits will be set.
Ex: fillMatchingAddresses(0b00000011, 0, 255, 0, 0) - set pixels 0, 4, 8, 12, etc. to red.
Ex: fillMatchingAddresses(0b11111000, 0, 0, 0, 255) - set pixels 0-7 to blue.
Ex: fillMatchingAddresses(0b00000010, 0, 0, 255, 0) - set alternating groups of 2 to green.
| mask | 8-bit bitmask indicating which address bits will be checked. |
| address | 8-bit address of the first pixel to be set. |
| r | Red value (0-255) |
| g | Green value (0-255) |
| b | Blue value (0-255) |
| void DOPLED::fillRandomGroups | ( | uint8_t | mask, |
| uint8_t | address, | ||
| uint8_t | r, | ||
| uint8_t | g, | ||
| uint8_t | b ) |
Creates random groups and sets them to a specific color.
The mask and address specify which groups of LEDs will be set. The groups are decided on the fly by the LEDs when the first random command is executed. The same group can be addressed multiple times using the same mask and address. Sending a fillAll command will reset the random groups.
Only the last 4 bits of the mask and address are used.
Ex:
fillRandomGroups(0b0001, 0b0000, 255, 0, 0); - Sets random 50% of the string to red.
fillRandomGroups(0b0001, 0b0001, 0, 255, 0); - Sets the other 50% to green.
See example project Random for more examples.
| mask | 4-bit bitmask indicating which group bits will be checked. |
| address | 4-bit address indicating the group to be addressed. |
| r | Red value (0-255) |
| g | Green value (0-255) |
| b | Blue value (0-255) |
| void DOPLED::sendRaw | ( | uint8_t * | data, |
| size_t | size ) |
| data | Byte array containing the raw data to be sent. |
| size | Size of the byte array. |
| void DOPLED::setFlags | ( | uint8_t | flagByte | ) |
Sets the last 3 bits of the command byte, which are configurable flags. It is not known what these flags do, but they are included for completeness.
| flagByte | 3-bit value containing the flags to use. |
| bool DOPLED::transmitDone | ( | ) |
Checks if the previous transmission has completed.
If this method returns false, calling any command that sends data will block until the previous transmission has finished.
| void DOPLED::writePixel | ( | uint8_t | address, |
| uint8_t | r, | ||
| uint8_t | g, | ||
| uint8_t | b ) |
Sets a specific pixel to a specific color.
| address | 8-bit address of the pixel to be set. |
| r | Red value (0-255) |
| g | Green value (0-255) |
| b | Blue value (0-255) |