forked from sowbug/G35Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first program from contributor MarkEMarkEMark.
- Loading branch information
Showing
4 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
G35: An Arduino library for GE Color Effects G-35 holiday lights. | ||
Copyright © 20112 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>. | ||
Programs referenced in MEOPrograms by Mark Ortiz <github.com/MarkEMarkEMark>. | ||
See README for complete attributions. | ||
*/ | ||
|
||
#include <MEOPrograms.h> | ||
|
||
LightProgram* MEOProgramGroup::CreateProgram(G35& lights, | ||
uint8_t program_index) { | ||
return new Rainbow(lights); | ||
// switch (program_index % ProgramCount) { | ||
// case 0: return new MEOWhites(lights, pattern); | ||
// case 1: return new MEORainbow(lights, pattern); | ||
// case 2: return new MEORandomStrobe(lights, pattern); | ||
// case 3: return new MEOSimplexNoise(lights, pattern); | ||
// case 4: return new MEOSineWave(lights, pattern); | ||
// case 5: return new MEOChasing(lights, pattern); | ||
// case 6: return new MEOColorPhasing(lights, pattern); | ||
// case 7: return new MEODither(lights, pattern); | ||
// case 8: return new MEOOscillate(lights, pattern); | ||
// } | ||
|
||
// not reached | ||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
G35: An Arduino library for GE Color Effects G-35 holiday lights. | ||
Copyright © 2012 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>. | ||
Programs referenced in MEOPrograms by Mark Ortiz <github.com/MarkEMarkEMark>. | ||
See README for complete attributions. | ||
*/ | ||
|
||
#ifndef INCLUDE_G35_MEO_PROGRAMS_H | ||
#define INCLUDE_G35_MEO_PROGRAMS_H | ||
|
||
#include <LightProgram.h> | ||
/* #include <Chasing.h> */ | ||
/* #include <ColorPhasing.h> */ | ||
/* #include <Dither.h> */ | ||
/* #include <Oscillate.h> */ | ||
#include <Rainbow.h> | ||
/* #include <RandomStrobe.h> */ | ||
/* #include <SimplexNoise.h> */ | ||
/* #include <SineWave.h> */ | ||
/* #include <Whites.h> */ | ||
|
||
class MEOProgramGroup : public LightProgramGroup { | ||
public: | ||
enum { ProgramCount = 9 }; | ||
|
||
virtual LightProgram* CreateProgram(G35& lights, uint8_t program_index); | ||
}; | ||
|
||
#endif // INCLUDE_G35_MEO_PROGRAMS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/* | ||
G35: An Arduino library for GE Color Effects G-35 holiday lights. | ||
Copyright © 2012 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>. | ||
Programs referenced in MEOPrograms by Mark Ortiz <github.com/MarkEMarkEMark>. | ||
Portions adapted from Adafruit. | ||
See README for complete attributions. | ||
*/ | ||
|
||
#include <Rainbow.h> | ||
|
||
Rainbow::Rainbow(G35& g35) | ||
: LightProgram(g35), wait_(0), pattern_(0), step_(0) { | ||
} | ||
|
||
uint32_t Rainbow::Do() { | ||
bool fortyEight; | ||
for (int i=0; i < light_count_; i++) { | ||
switch (pattern_ % 8) { | ||
case 0: | ||
fortyEight = false; | ||
g35_.fill_color(i, 1, G35::MAX_INTENSITY, | ||
Rainbow::LineRG((i + step_) % 32)); | ||
break; | ||
case 1: | ||
fortyEight = false; | ||
g35_.fill_color(i, 1, G35::MAX_INTENSITY, | ||
Rainbow::LineGB((i + step_) % 32)); | ||
break; | ||
case 2: | ||
fortyEight = false; | ||
g35_.fill_color(i, 1, G35::MAX_INTENSITY, | ||
Rainbow::LineBR((i + step_) % 32)); | ||
break; | ||
case 3: | ||
fortyEight = true; | ||
g35_.fill_color(i, 1, G35::MAX_INTENSITY, | ||
Rainbow::Wheel((i + step_) % 48)); | ||
break; | ||
case 4: | ||
fortyEight = false; | ||
g35_.fill_color(i, 1, G35::MAX_INTENSITY, | ||
Rainbow::LineRG(((i * 32 / light_count_) + step_) % 32)); | ||
break; | ||
case 5: | ||
fortyEight = false; | ||
g35_.fill_color(i, 1, G35::MAX_INTENSITY, | ||
Rainbow::LineGB(((i * 32 / light_count_) + step_) % 32)); | ||
break; | ||
case 6: | ||
fortyEight = false; | ||
g35_.fill_color(i, 1, G35::MAX_INTENSITY, | ||
Rainbow::LineBR(((i * 32 / light_count_) + step_) % 32)); | ||
break; | ||
case 7: | ||
fortyEight = true; | ||
g35_.fill_color(i, 1, G35::MAX_INTENSITY, | ||
Rainbow::Wheel(((i * 48 / light_count_) + step_) % 48)); | ||
break; | ||
} | ||
} | ||
|
||
// reset at end of wheel or line | ||
++step_; | ||
if (((step_ == 48) && fortyEight) || ((step_ == 32) && !fortyEight)) { | ||
step_ = 0; | ||
} | ||
|
||
delay(wait_); | ||
|
||
return bulb_frame_; | ||
} | ||
|
||
uint32_t Rainbow::Wheel(uint16_t WheelPos) { | ||
byte r, g, b; | ||
switch (WheelPos / 16) { | ||
case 0: | ||
r = 15 - WheelPos % 16; // red down | ||
g = WheelPos % 16; // green up | ||
b = 0; // blue off | ||
break; | ||
case 1: | ||
g = 15 - WheelPos % 16; // green down | ||
b = WheelPos % 16; // blue up | ||
r = 0; // red off | ||
break; | ||
case 2: | ||
b = 15 - WheelPos % 16; // blue down | ||
r = WheelPos % 16; // red up | ||
g = 0; // green off | ||
break; | ||
} | ||
return (COLOR(r,g,b)); | ||
} | ||
|
||
uint32_t Rainbow::LineRG(uint16_t WheelPos) { | ||
byte r, g, b; | ||
switch (WheelPos / 16) { | ||
case 0: | ||
r = 15 - WheelPos % 16; // red down | ||
g = WheelPos % 16; // green up | ||
b = 0; // blue off | ||
break; | ||
case 1: | ||
r = WheelPos % 16; // red up | ||
g = 15 - WheelPos % 16; // green down | ||
b = 0; // blue off | ||
break; | ||
} | ||
return (COLOR(r,g,b)); | ||
} | ||
|
||
uint32_t Rainbow::LineGB(uint16_t WheelPos) { | ||
byte r, g, b; | ||
switch (WheelPos / 16) { | ||
case 0: | ||
r = 0; // red off | ||
g = 15 - WheelPos % 16; // green down | ||
b = WheelPos % 16; // blue up | ||
break; | ||
case 1: | ||
r = 0; // red off | ||
g = WheelPos % 16; // green up | ||
b = 15 - WheelPos % 16; // blue down | ||
break; | ||
} | ||
return (COLOR(r,g,b)); | ||
} | ||
|
||
uint32_t Rainbow::LineBR(uint16_t WheelPos) { | ||
byte r, g, b; | ||
switch (WheelPos / 16) { | ||
case 0: | ||
r = WheelPos % 16; // red up | ||
g = 0; // green off | ||
b = 15 - WheelPos % 16; // blue down | ||
break; | ||
case 1: | ||
r = 15 - WheelPos % 16; // red down | ||
g = 0; // green off | ||
b = WheelPos % 16; // blue up | ||
break; | ||
} | ||
return (COLOR(r,g,b)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
G35: An Arduino library for GE Color Effects G-35 holiday lights. | ||
Copyright © 2012 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>. | ||
Programs referenced in MEOPrograms by Mark Ortiz <github.com/MarkEMarkEMark>. | ||
Portions adapted from Adafruit. | ||
See README for complete attributions. | ||
*/ | ||
|
||
#ifndef INCLUDE_G35_PROGRAMS_RAINBOW_H | ||
#define INCLUDE_G35_PROGRAMS_RAINBOW_H | ||
|
||
#include <LightProgram.h> | ||
|
||
class Rainbow : public LightProgram { | ||
public: | ||
Rainbow(G35& g35); | ||
uint32_t Do(); | ||
|
||
private: | ||
uint32_t Wheel(uint16_t WheelPos); | ||
uint32_t LineRG(uint16_t WheelPos); | ||
uint32_t LineGB(uint16_t WheelPos); | ||
uint32_t LineBR(uint16_t WheelPos); | ||
|
||
uint8_t wait_; | ||
uint8_t pattern_; | ||
uint8_t step_; | ||
}; | ||
|
||
#endif |