Dilbert
Firmware for the Dilbert interactive badge.
 All Classes Files Functions Variables Enumerations Macros Pages
RainbowCycle.h
Go to the documentation of this file.
1 
3 #ifndef _RAINBOW_CYCLE_
4 #define _RAINBOW_CYCLE_
5 
6 #include "NPPattern.h"
7 
8 class RainbowCycle : public NPPattern
9 {
10 public:
11  RainbowCycle(Adafruit_NeoPixel &strip, uint8_t wait)
12  : NPPattern(strip, 31)
13  , m_wait(wait)
14  , m_j(0)
15  {
16  m_next = millis();
17  }
18 
19  virtual ~RainbowCycle()
20  {
21  }
22 
23  void run()
24  {
25  if (m_next < millis())
26  {
27  m_next = millis() + m_wait;
28  if (m_j < 256)
29  {
30  for (int i = 0; i < m_strip.numPixels(); i++)
31  {
32  m_strip.setPixelColor(i, wheel(((i * 256 / m_strip.numPixels()) + m_j) & 255));
33  }
34  m_strip.setBrightness(m_brightness);
35  m_strip.show();
36  m_j++;
37  }
38  else
39  {
40  m_j = 0;
41  }
42  }
43  }
44 
45 private:
46  unsigned long m_wait, m_next;
47  int m_j;
48 };
49 
50 #endif
Definition: RainbowCycle.h:8
Definition: NPPattern.h:6