Library to control NeoPixel strings of RGB leds
Dependents: NeoPixelI2cSlave NeoPixelI2cSlave
Diff: neopixel_string.cpp
- Revision:
- 2:bb9ebad05691
- Parent:
- 0:66a5d46a740f
diff -r f544810b6598 -r bb9ebad05691 neopixel_string.cpp --- a/neopixel_string.cpp Mon Nov 23 18:50:01 2015 +0000 +++ b/neopixel_string.cpp Mon Nov 23 21:32:24 2015 +0000 @@ -8,11 +8,31 @@ update(Colors::Black); } +unsigned int NeoPixelString::getLength(void) { + return this->length; +} + +void NeoPixelString::update(void) { + PixelArray::update(pixels, length); +} + void NeoPixelString::update(neopixel::Pixel singlecolor) { for (unsigned int i = 0; i < length; i++) { pixels[i] = singlecolor; } - PixelArray::update(pixels, length); + update(); +} + +neopixel::Pixel NeoPixelString::getPixel(unsigned int i) { + if (i < this->length) { + return pixels[i]; + } +} + +void NeoPixelString::setPixel(unsigned i, neopixel::Pixel pixel) { + if (i < this->length) { + pixels[i] = pixel; + } } void NeoPixelString::diagnose(void) {