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