Skip to content

Commit df37932

Browse files
committed
Add first program from contributor MarkEMarkEMark.
1 parent 582cb35 commit df37932

File tree

4 files changed

+246
-0
lines changed

4 files changed

+246
-0
lines changed

MEOPrograms.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
G35: An Arduino library for GE Color Effects G-35 holiday lights.
3+
Copyright © 20112 The G35 Authors. Use, modification, and distribution are
4+
subject to the BSD license as described in the accompanying LICENSE file.
5+
6+
By Mike Tsao <http://github.com/sowbug>.
7+
Programs referenced in MEOPrograms by Mark Ortiz <github.com/MarkEMarkEMark>.
8+
9+
See README for complete attributions.
10+
*/
11+
12+
#include <MEOPrograms.h>
13+
14+
LightProgram* MEOProgramGroup::CreateProgram(G35& lights,
15+
uint8_t program_index) {
16+
return new Rainbow(lights);
17+
// switch (program_index % ProgramCount) {
18+
// case 0: return new MEOWhites(lights, pattern);
19+
// case 1: return new MEORainbow(lights, pattern);
20+
// case 2: return new MEORandomStrobe(lights, pattern);
21+
// case 3: return new MEOSimplexNoise(lights, pattern);
22+
// case 4: return new MEOSineWave(lights, pattern);
23+
// case 5: return new MEOChasing(lights, pattern);
24+
// case 6: return new MEOColorPhasing(lights, pattern);
25+
// case 7: return new MEODither(lights, pattern);
26+
// case 8: return new MEOOscillate(lights, pattern);
27+
// }
28+
29+
// not reached
30+
return NULL;
31+
}

MEOPrograms.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
G35: An Arduino library for GE Color Effects G-35 holiday lights.
3+
Copyright © 2012 The G35 Authors. Use, modification, and distribution are
4+
subject to the BSD license as described in the accompanying LICENSE file.
5+
6+
By Mike Tsao <http://github.com/sowbug>.
7+
Programs referenced in MEOPrograms by Mark Ortiz <github.com/MarkEMarkEMark>.
8+
9+
See README for complete attributions.
10+
*/
11+
12+
#ifndef INCLUDE_G35_MEO_PROGRAMS_H
13+
#define INCLUDE_G35_MEO_PROGRAMS_H
14+
15+
#include <LightProgram.h>
16+
/* #include <Chasing.h> */
17+
/* #include <ColorPhasing.h> */
18+
/* #include <Dither.h> */
19+
/* #include <Oscillate.h> */
20+
#include <Rainbow.h>
21+
/* #include <RandomStrobe.h> */
22+
/* #include <SimplexNoise.h> */
23+
/* #include <SineWave.h> */
24+
/* #include <Whites.h> */
25+
26+
class MEOProgramGroup : public LightProgramGroup {
27+
public:
28+
enum { ProgramCount = 9 };
29+
30+
virtual LightProgram* CreateProgram(G35& lights, uint8_t program_index);
31+
};
32+
33+
#endif // INCLUDE_G35_MEO_PROGRAMS_H

Rainbow.cpp

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/*
2+
G35: An Arduino library for GE Color Effects G-35 holiday lights.
3+
Copyright © 2012 The G35 Authors. Use, modification, and distribution are
4+
subject to the BSD license as described in the accompanying LICENSE file.
5+
6+
By Mike Tsao <http://github.com/sowbug>.
7+
Programs referenced in MEOPrograms by Mark Ortiz <github.com/MarkEMarkEMark>.
8+
Portions adapted from Adafruit.
9+
10+
See README for complete attributions.
11+
*/
12+
13+
#include <Rainbow.h>
14+
15+
Rainbow::Rainbow(G35& g35)
16+
: LightProgram(g35), wait_(0), pattern_(0), step_(0) {
17+
}
18+
19+
uint32_t Rainbow::Do() {
20+
bool fortyEight;
21+
for (int i=0; i < light_count_; i++) {
22+
switch (pattern_ % 8) {
23+
case 0:
24+
fortyEight = false;
25+
g35_.fill_color(i, 1, G35::MAX_INTENSITY,
26+
Rainbow::LineRG((i + step_) % 32));
27+
break;
28+
case 1:
29+
fortyEight = false;
30+
g35_.fill_color(i, 1, G35::MAX_INTENSITY,
31+
Rainbow::LineGB((i + step_) % 32));
32+
break;
33+
case 2:
34+
fortyEight = false;
35+
g35_.fill_color(i, 1, G35::MAX_INTENSITY,
36+
Rainbow::LineBR((i + step_) % 32));
37+
break;
38+
case 3:
39+
fortyEight = true;
40+
g35_.fill_color(i, 1, G35::MAX_INTENSITY,
41+
Rainbow::Wheel((i + step_) % 48));
42+
break;
43+
case 4:
44+
fortyEight = false;
45+
g35_.fill_color(i, 1, G35::MAX_INTENSITY,
46+
Rainbow::LineRG(((i * 32 / light_count_) + step_) % 32));
47+
break;
48+
case 5:
49+
fortyEight = false;
50+
g35_.fill_color(i, 1, G35::MAX_INTENSITY,
51+
Rainbow::LineGB(((i * 32 / light_count_) + step_) % 32));
52+
break;
53+
case 6:
54+
fortyEight = false;
55+
g35_.fill_color(i, 1, G35::MAX_INTENSITY,
56+
Rainbow::LineBR(((i * 32 / light_count_) + step_) % 32));
57+
break;
58+
case 7:
59+
fortyEight = true;
60+
g35_.fill_color(i, 1, G35::MAX_INTENSITY,
61+
Rainbow::Wheel(((i * 48 / light_count_) + step_) % 48));
62+
break;
63+
}
64+
}
65+
66+
// reset at end of wheel or line
67+
++step_;
68+
if (((step_ == 48) && fortyEight) || ((step_ == 32) && !fortyEight)) {
69+
step_ = 0;
70+
}
71+
72+
delay(wait_);
73+
74+
return bulb_frame_;
75+
}
76+
77+
uint32_t Rainbow::Wheel(uint16_t WheelPos) {
78+
byte r, g, b;
79+
switch (WheelPos / 16) {
80+
case 0:
81+
r = 15 - WheelPos % 16; // red down
82+
g = WheelPos % 16; // green up
83+
b = 0; // blue off
84+
break;
85+
case 1:
86+
g = 15 - WheelPos % 16; // green down
87+
b = WheelPos % 16; // blue up
88+
r = 0; // red off
89+
break;
90+
case 2:
91+
b = 15 - WheelPos % 16; // blue down
92+
r = WheelPos % 16; // red up
93+
g = 0; // green off
94+
break;
95+
}
96+
return (COLOR(r,g,b));
97+
}
98+
99+
uint32_t Rainbow::LineRG(uint16_t WheelPos) {
100+
byte r, g, b;
101+
switch (WheelPos / 16) {
102+
case 0:
103+
r = 15 - WheelPos % 16; // red down
104+
g = WheelPos % 16; // green up
105+
b = 0; // blue off
106+
break;
107+
case 1:
108+
r = WheelPos % 16; // red up
109+
g = 15 - WheelPos % 16; // green down
110+
b = 0; // blue off
111+
break;
112+
}
113+
return (COLOR(r,g,b));
114+
}
115+
116+
uint32_t Rainbow::LineGB(uint16_t WheelPos) {
117+
byte r, g, b;
118+
switch (WheelPos / 16) {
119+
case 0:
120+
r = 0; // red off
121+
g = 15 - WheelPos % 16; // green down
122+
b = WheelPos % 16; // blue up
123+
break;
124+
case 1:
125+
r = 0; // red off
126+
g = WheelPos % 16; // green up
127+
b = 15 - WheelPos % 16; // blue down
128+
break;
129+
}
130+
return (COLOR(r,g,b));
131+
}
132+
133+
uint32_t Rainbow::LineBR(uint16_t WheelPos) {
134+
byte r, g, b;
135+
switch (WheelPos / 16) {
136+
case 0:
137+
r = WheelPos % 16; // red up
138+
g = 0; // green off
139+
b = 15 - WheelPos % 16; // blue down
140+
break;
141+
case 1:
142+
r = 15 - WheelPos % 16; // red down
143+
g = 0; // green off
144+
b = WheelPos % 16; // blue up
145+
break;
146+
}
147+
return (COLOR(r,g,b));
148+
}

Rainbow.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
G35: An Arduino library for GE Color Effects G-35 holiday lights.
3+
Copyright © 2012 The G35 Authors. Use, modification, and distribution are
4+
subject to the BSD license as described in the accompanying LICENSE file.
5+
6+
By Mike Tsao <http://github.com/sowbug>.
7+
Programs referenced in MEOPrograms by Mark Ortiz <github.com/MarkEMarkEMark>.
8+
Portions adapted from Adafruit.
9+
10+
See README for complete attributions.
11+
*/
12+
13+
#ifndef INCLUDE_G35_PROGRAMS_RAINBOW_H
14+
#define INCLUDE_G35_PROGRAMS_RAINBOW_H
15+
16+
#include <LightProgram.h>
17+
18+
class Rainbow : public LightProgram {
19+
public:
20+
Rainbow(G35& g35);
21+
uint32_t Do();
22+
23+
private:
24+
uint32_t Wheel(uint16_t WheelPos);
25+
uint32_t LineRG(uint16_t WheelPos);
26+
uint32_t LineGB(uint16_t WheelPos);
27+
uint32_t LineBR(uint16_t WheelPos);
28+
29+
uint8_t wait_;
30+
uint8_t pattern_;
31+
uint8_t step_;
32+
};
33+
34+
#endif

0 commit comments

Comments
 (0)