Library to control NeoPixel strings of RGB leds
Dependents: NeoPixelI2cSlave NeoPixelI2cSlave
Effects/periodic_effect.cpp@3:7d32f46a38d3, 2016-04-15 (annotated)
- Committer:
- dwini
- Date:
- Fri Apr 15 14:38:13 2016 +0000
- Revision:
- 3:7d32f46a38d3
Been to long since i coded this.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dwini | 3:7d32f46a38d3 | 1 | #include "periodic_effect.h" |
dwini | 3:7d32f46a38d3 | 2 | |
dwini | 3:7d32f46a38d3 | 3 | namespace Effects { |
dwini | 3:7d32f46a38d3 | 4 | |
dwini | 3:7d32f46a38d3 | 5 | PeriodicEffect::PeriodicEffect(NeoPixelString * pixelstring, neopixel::Pixel color, int delay_ms) |
dwini | 3:7d32f46a38d3 | 6 | : Effect(pixelstring, color) { |
dwini | 3:7d32f46a38d3 | 7 | |
dwini | 3:7d32f46a38d3 | 8 | this->delay_ms = delay_ms; |
dwini | 3:7d32f46a38d3 | 9 | } |
dwini | 3:7d32f46a38d3 | 10 | |
dwini | 3:7d32f46a38d3 | 11 | void PeriodicEffect::start(void) { |
dwini | 3:7d32f46a38d3 | 12 | Effect::start(); |
dwini | 3:7d32f46a38d3 | 13 | ticker.attach(this, &PeriodicEffect::tick, delay_ms/1000.0); |
dwini | 3:7d32f46a38d3 | 14 | } |
dwini | 3:7d32f46a38d3 | 15 | |
dwini | 3:7d32f46a38d3 | 16 | void PeriodicEffect::stop(void) { |
dwini | 3:7d32f46a38d3 | 17 | Effect::stop(); |
dwini | 3:7d32f46a38d3 | 18 | ticker.detach(); |
dwini | 3:7d32f46a38d3 | 19 | } |
dwini | 3:7d32f46a38d3 | 20 | |
dwini | 3:7d32f46a38d3 | 21 | void PeriodicEffect::tick(void) { |
dwini | 3:7d32f46a38d3 | 22 | requestExecute(); |
dwini | 3:7d32f46a38d3 | 23 | } |
dwini | 3:7d32f46a38d3 | 24 | |
dwini | 3:7d32f46a38d3 | 25 | }; |