Library to control NeoPixel strings of RGB leds
Dependents: NeoPixelI2cSlave NeoPixelI2cSlave
Diff: neopixel_string.cpp
- Revision:
- 0:66a5d46a740f
- Child:
- 2:bb9ebad05691
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/neopixel_string.cpp Sun Oct 25 11:24:54 2015 +0000 @@ -0,0 +1,36 @@ +#include "neopixel_string.h" + +NeoPixelString::NeoPixelString(PinName spi_pin, unsigned int length) : PixelArray(spi_pin) { + this->length = length; + pixels = new neopixel::Pixel[length]; // Actual buffer of colors + + // Clear all + update(Colors::Black); +} + +void NeoPixelString::update(neopixel::Pixel singlecolor) { + for (unsigned int i = 0; i < length; i++) { + pixels[i] = singlecolor; + } + PixelArray::update(pixels, length); +} + +void NeoPixelString::diagnose(void) { + update(Colors::Black); + wait(1); + for (int i = 0; i < 5; i++) { + update(ColorAdjuster::intensity(Colors::Red, 5)); + wait(0.5); + update(ColorAdjuster::intensity(Colors::Green, 5)); + wait(0.5); + update(ColorAdjuster::intensity(Colors::Blue, 5)); + wait(0.5); + } + + update(Colors::Black); + for (unsigned int i = 0; i < length; i++) { + pixels[i] = ColorAdjuster::intensity(Colors::White, 5); + PixelArray::update(pixels, length); + wait(0.1); + } +} \ No newline at end of file