Class acts as a wrapper around SPI calls to control the Digi-Dot-Booster. More...
#include <DDBooster.h>
Public Types | |
enum | LedType { LED_RGB = 24, LED_RGBW = 32 } |
enum | LedColorOrder { ORDER_RGB, ORDER_GRB } |
Public Member Functions | |
DDBooster () | |
void | configurePins (uint8_t csPin, uint8_t resetPin) |
void | init (uint16_t ledCount, LedType ledType=LED_RGB, LedColorOrder colorOrder=ORDER_GRB) |
void | reset () |
void | setRGB (uint8_t r, uint8_t g, uint8_t b) |
void | setRGBW (uint8_t r, uint8_t g, uint8_t b, uint8_t w) |
void | setHSV (uint16_t h, uint8_t s, uint8_t v) |
void | setLED (uint8_t index) |
void | clearLED (uint8_t index) |
void | setAll () |
void | clearAll () |
void | setRange (uint8_t start, uint8_t end) |
void | setRainbow (uint16_t h, uint8_t s, uint8_t v, uint8_t start, uint8_t end, uint8_t step) |
void | setGradient (int start, int end, uint8_t from[3], uint8_t to[3]) |
void | shiftUp (uint8_t start, uint8_t end, uint8_t count) |
void | shiftDown (uint8_t start, uint8_t end, uint8_t count) |
void | copyLED (uint8_t from, uint8_t to) |
void | repeat (uint8_t start, uint8_t end, uint8_t count) |
void | show () |
Class acts as a wrapper around SPI calls to control the Digi-Dot-Booster.
After creation of the class instance SPI is configured with default values (12MHz, MSB first, mode 0). By default the library uses the SS pin of the Arduino platform for the communication with the Digi-Dot-Booster. If you prefer to use another digital pin for chip select use configurePins to set it. Using configurePins you can also set a reset pin used to toggle the hardware reset of the DD-Booster.
Before calling any functions you have first to initialize the DD-Booster with the number of the LEDs (max. 256), their type (RGB or RGBW) and the color order (RGB or GRB). Both last parameters are optional - DD-Booster is configured for the ws2812 LEDS (RGB type with GRB color order).
When calling the LED controlling functions the corresponding values are sent to the DD-Booster, but only after the show() call the LEDs are really addressed with the current state of the values buffer.
LED color order. ws2812 is using GRB order and it's the default color order for the DD-Booster.
enum DDBooster::LedType |
LED type. Stores the number of bits used for the color of one LED. LED_RGB is the default value used by the DD-Booster
DDBooster::DDBooster | ( | ) |
Default constructor. Initializes SPI interface at 12MHz, MSB first, mode 0
void DDBooster::clearAll | ( | ) |
Clears all LEDs by setting their color to RGB(0,0,0). Internally it simply sends setRGB(0,0,0) and setAll().
void DDBooster::clearLED | ( | uint8_t | index | ) |
Clears a single LED by setting its color to RGB(0,0,0). Internally it simply sends setRGB(0,0,0) and setLED(index).
index | - Index of of the LED to clear. Index starts with 0 |
void DDBooster::configurePins | ( | uint8_t | csPin, |
uint8_t | resetPin | ||
) |
Reassigns used pins for SPI chip select and reset pin. By default the library uses the default SS pin of the SPI interface. To be able to do a hardware reset of the DD-Booster, connect a digital IO pin to the RESET pin of the DD-Booster.
csPin | - Digital Arduino pin to use as chip select |
resetPin | - Digital Arduino pin connected to the RESET pin of the DD-Booster |
void DDBooster::copyLED | ( | uint8_t | from, |
uint8_t | to | ||
) |
Copies a color value of a LED to another one.
from | - Index of the LED to copy from |
to | - Index of the LED to copy to |
void DDBooster::init | ( | uint16_t | ledCount, |
LedType | ledType = LED_RGB , |
||
LedColorOrder | colorOrder = ORDER_GRB |
||
) |
Performs initial configuration of the DD-Booster to set the number of used LEDs and their type. DD-Booster supports max. 256 LEDs.
ledCount | - Number of used LEDs |
ledType | - Type of LEDs used. RGB is default |
colorOrder | - LED color order. GRB is default |
void DDBooster::repeat | ( | uint8_t | start, |
uint8_t | end, | ||
uint8_t | count | ||
) |
Copies the whole range several times in a row.
start | - Index of the first LED in the range. Index starts with 0 |
end | - Index of the last LED in the range |
count | - Number of copy operation |
void DDBooster::reset | ( | ) |
Performs a hardware reset of the DD-Booster by toggling it's RESET pin. To use this function, set the corresponding pin first using configurePins otherwise the call of reset() does nothing.
void DDBooster::setAll | ( | ) |
Assign the previously set color value to a all LEDs.
void DDBooster::setGradient | ( | int | start, |
int | end, | ||
uint8_t | from[3], | ||
uint8_t | to[3] | ||
) |
Creates a gradient from one color to another. start and end index can have negative values to make a gradient starting outside the visible area showing only it's currently visible part considering the intermediate color values.
start | - Index of the first LED in the range. Can be negative. |
end | - Index of the last LED in the range. Can be greater than the number of LEDs |
from | - RGB value of the start color |
to | - RGB value of the end color |
void DDBooster::setHSV | ( | uint16_t | h, |
uint8_t | s, | ||
uint8_t | v | ||
) |
Sets a LED color for next operations using HSV format until another color set operation overwrites it.
h | - Hue part of the color value (0 - 359) |
s | - Saturation part of the color value (0 - 255) |
v | - Value part of the color value (0 - 255) |
void DDBooster::setLED | ( | uint8_t | index | ) |
Assign the previously set color value to a single LED.
index | - Index of of the LED to set. Index starts with 0 |
void DDBooster::setRainbow | ( | uint16_t | h, |
uint8_t | s, | ||
uint8_t | v, | ||
uint8_t | start, | ||
uint8_t | end, | ||
uint8_t | step | ||
) |
Creates a rainbow effect in a range.
h | - Hue part of the color value (0 - 359) |
s | - Saturation part of the color value (0 - 255) |
v | - Value part of the color value (0 - 255) |
start | - Index of the first LED in the range to set. Index starts with 0 |
end | - Index of the last LED in the range to set |
step | - Step value to increment between 2 LEDs. Recommended values 2 - 20 |
void DDBooster::setRange | ( | uint8_t | start, |
uint8_t | end | ||
) |
Assign the previously set color value to a range of LEDs.
start | - Index of the first LED in the range to set. Index starts with 0 |
end | - Index of the last LED in the range to set |
void DDBooster::setRGB | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b | ||
) |
Sets a LED color for next operations using RGB format until another color set operation overwrites it.
r | - Red part of the color value (0 - 255) |
g | - Green part of the color value (0 - 255) |
b | - Blue part of the color value (0 - 255) |
void DDBooster::setRGBW | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b, | ||
uint8_t | w | ||
) |
Sets a LED color for next operations using RGBW format until another color set operation overwrites it.
r | - Red part of the color value (0 - 255) |
g | - Green part of the color value (0 - 255) |
b | - Blue part of the color value (0 - 255) |
w | - White LED level (0 - 255) |
void DDBooster::shiftDown | ( | uint8_t | start, |
uint8_t | end, | ||
uint8_t | count | ||
) |
Shifts down the color values of the LEDs in a range.
start | - Index of the first LED in the range. Index starts with 0 |
end | - Index of the last LED in the range |
count | - Number of LEDs/steps to shift down |
void DDBooster::shiftUp | ( | uint8_t | start, |
uint8_t | end, | ||
uint8_t | count | ||
) |
Shifts up the color values of the LEDs in a range.
start | - Index of the first LED in the range. Index starts with 0 |
end | - Index of the last LED in the range |
count | - Number of LEDs/steps to shift up |
void DDBooster::show | ( | ) |
Shows the changes previously made by sending all values to the LEDs.