-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBasicSegment.h
66 lines (58 loc) · 1.38 KB
/
BasicSegment.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef BASICSEGMENT_H
#define BASICSEGMENT_H
#ifdef ARDUINO
#include <Adafruit_NeoPixel.h>
#else
#include "test/Placeholders/Adafruit.h"
#endif
class rgbColors
{
public:
unsigned short red = 0;
unsigned short green = 255;
unsigned short blue = 0;
rgbColors() = default;
rgbColors(unsigned short red, unsigned short green, unsigned short blue)
{
this->red = red;
this->green = green;
this->blue = blue;
};
bool operator==(const rgbColors& other) const
{
return (red == other.red) && (green == other.green) && (blue == other.blue);
};
bool operator!=(const rgbColors& other) const
{
return !(*this == other);
};
};
class Segment
{
public:
virtual void turnOn() = 0;
virtual void turnOff() = 0;
virtual ~Segment() {};
};
class BasicSegment : public Segment
{
private:
short segmentLength;
short startLed;
bool state;
Adafruit_NeoPixel ledArray;
rgbColors colors;
short brightness = 200;
public:
BasicSegment() = default;
BasicSegment(Adafruit_NeoPixel& ledArray, short startLed, short segmentLength);
~BasicSegment() {};
void turnOn();
void turnOff();
void setBrightness(short brightness);
void setColors(unsigned short red, unsigned short green, unsigned short blue);
bool getState();
int getBrightness();
rgbColors getColors();
};
#endif