Dilbert
Firmware for the Dilbert interactive badge.
 All Classes Files Functions Variables Enumerations Macros Pages
NPPattern.h
Go to the documentation of this file.
1 
3 #ifndef _NPPATTERN_
4 #define _NPPATTERN_
5 
6 class NPPattern
7 {
8 public:
9  NPPattern(Adafruit_NeoPixel &strip, int brightness)
10  : m_strip(strip)
11  , m_brightness(brightness)
12  {
13  }
14 
15  virtual ~NPPattern()
16  {
17  }
18 
19  virtual void run(){};
20 
21  // Input a value 0 to 255 to get a color value.
22  // The colours are a transition r - g - b - back to r.
23  uint32_t wheel(byte wheelPos)
24  {
25  wheelPos = 255 - wheelPos;
26  if (wheelPos < 85)
27  {
28  return Adafruit_NeoPixel::Color(255 - wheelPos * 3, 0, wheelPos * 3);
29  }
30  if (wheelPos < 170)
31  {
32  wheelPos -= 85;
33  return Adafruit_NeoPixel::Color(0, wheelPos * 3, 255 - wheelPos * 3);
34  }
35  wheelPos -= 170;
36  return Adafruit_NeoPixel::Color(wheelPos * 3, 255 - wheelPos * 3, 0);
37  }
38 
39  inline void setBrightness(int inBrightness)
40  {
41  m_strip.setBrightness(inBrightness);
42  m_brightness = m_strip.getBrightness();
43  }
44 
45  inline int getBrightness()
46  {
47  return m_brightness;
48  }
49 
50 protected:
51  Adafruit_NeoPixel &m_strip;
52  int m_brightness;
53 };
54 
55 #endif
Definition: NPPattern.h:6