-
Notifications
You must be signed in to change notification settings - Fork 10
/
MEOWhites.cpp
140 lines (131 loc) · 3.11 KB
/
MEOWhites.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
G35: An Arduino library for GE Color Effects G-35 holiday lights.
Copyright © 2011 The G35 Authors. Use, modification, and distribution are
subject to the BSD license as described in the accompanying LICENSE file.
By Mike Tsao <http://github.com/sowbug>.
and Mark Ortiz
See README for complete attributions.
*/
#include <MEOWhites.h>
MEOWhites::MEOWhites(MEOG35& g35, uint8_t pattern)
: MEOLightProgram(g35, pattern), intensity_(0), pattern_(pattern), count_(1), sequence_(0), wait_(100)
{
uint8_t current = 0;
switch (pattern_ % 7)
{
case 0: //Warm White
g35_.fill_color(0, light_count_, 0, COLOR_WARMWHITE);
break;
case 1: //Cold White
g35_.fill_color(0, light_count_, 0, COLOR_WHITE);
break;
case 2: // Warm & Cold White
for (int i = 0; i < light_count_; i++)
{
if ((i % 2) == 0)
{
g35_.fill_color(i, 1, 0, COLOR_WHITE);
}
else
{
g35_.fill_color(i, 1, 0, COLOR_WARMWHITE);
}
}
break;
case 3: //Hint of RGB
for (int i = 0; i < light_count_; i++)
{
switch (current)
{
case 0:
g35_.fill_color(i, 1, 0, COLOR(0xF, 0x8, 0x8));
current = 1;
break;
case 1:
g35_.fill_color(i, 1, 0, COLOR(0x8, 0xF, 0x8));
current = 2;
break;
case 2:
g35_.fill_color(i, 1, 0, COLOR(0x8, 0x8, 0xF));
current = 0;
break;
}
}
break;
case 4: //Hint of CYM
for (int i = 0; i < light_count_; i++)
{
switch (current)
{
case 0:
g35_.fill_color(i, 1, 0, COLOR(0x8, 0xF, 0xF));
current = 1;
break;
case 1:
g35_.fill_color(i, 1, 0, COLOR(0xF, 0xF, 0x8));
current = 2;
break;
case 2:
g35_.fill_color(i, 1, 0, COLOR(0xF, 0x8, 0xF));
current = 0;
break;
}
}
break;
}
}
uint32_t MEOWhites::Do()
{
switch (pattern_ % 7)
{
case 5: //Hint of RGB chase
g35_.fill_sequence(0, count_, sequence_, 1, MEOG35::MAX_INTENSITY, RGB);
break;
case 6: //Hint of CYM chase
g35_.fill_sequence(0, count_, sequence_, 1, MEOG35::MAX_INTENSITY, CYM);
break;
default:
if (intensity_ <= MEOG35::MAX_INTENSITY)
{
g35_.broadcast_intensity(intensity_++);
return bulb_frame_;
}
return 1000;
}
if (count_ < light_count_)
{
++count_;
}
else
{
++sequence_;
}
delay(wait_);
return bulb_frame_;
}
color_t MEOWhites::RGB(uint16_t sequence)
{
sequence = sequence % 3;
if (sequence == 0)
{
return COLOR(0xF, 0xB, 0xB);
}
if (sequence == 1)
{
return COLOR(0xB, 0xF, 0xB);
}
return COLOR(0xB, 0xB, 0xF);
}
color_t MEOWhites::CYM(uint16_t sequence)
{
sequence = sequence % 3;
if (sequence == 0)
{
return COLOR(0xB, 0xF, 0xF);
}
if (sequence == 1)
{
return COLOR(0xF, 0xF, 0xB);
}
return COLOR(0xF, 0xB, 0xF);
}