-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackgroundShow.ino
140 lines (101 loc) · 4.18 KB
/
BackgroundShow.ino
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
//------------------------------------------------------------------------
// BackgroundShow Function Calls
//------------------------------------------------------------------------
// run the "Background Show" while the knob is in zone 2
//
// THIS SHOULD be a list of function calls to functions defined in the BackgroundShow or Shared function definitions area
//
void runBackgroundShow()
{
// unsigned long startTime; // time we begin the light show, in milliseconds
// int intermissionDelay = 400; // brief pause between displays
// int postShowDelay = 2000; // longer delay at the end of the show
// Serial.println("Beginning Background Show.");
// //first display
// fadeBlinkSingleLedsGoingClockwise(100, 100, 1, 5);
// if (fade.delayAndCheckForExit(intermissionDelay) == true) return; // check knob during intermission
// //second display
// fadeShowAllTheColors(500, 1000, 1, 2);
// if (fade.delayAndCheckForExit(intermissionDelay) == true) return; // check knob during intermission
// // third display
// crossFadeRightAndLeft(100, 100, 5, 2);
// if (fade.delayAndCheckForExit(intermissionDelay) == true) return; // check knob during intermission
// if (fade.delayAndCheckForExit(postShowDelay) == true) return; // check knob during intermission
// Serial.print(" Background Show finished. Run time in milliseconds: ");
// Serial.println(millis() - startTime);
// slinky();
}
void slinky()
{
byte bottom[] = {2, 3, 4, 5, 6};
byte top[] = {7, 8, 9, 10, 11};
byte twoLeds[2];
for(int count = 0; count < 5; count++)
{
for(int i = 0; i < 4; i++)
{
twoLeds[0] = bottom[i];
twoLeds[1] = top[i];
fade.up(4, twoLeds, 2);
fDelay(200);
fade.down(4, twoLeds, 2);
}
for(int i = 4; i > 0; i--)
{
twoLeds[0] = bottom[i];
twoLeds[1] = top[i];
fade.up(4, twoLeds, 2);
fDelay(200);
fade.down(4, twoLeds, 2);
}
}
}
//------------------------------------------------------------------------
// BackgroundShow Function Definitions
//------------------------------------------------------------------------
// All your function definitions for BackgroundShow should be entered here
//
//
// fade an LED up and down, then move to the next LED in a clockwise direction
//
void fadeBlinkSingleLedsGoingClockwise(int onTime, int offTime, byte repeatCount, byte fadeSpeed)
{
byte ledNumber;
byte count;
for(count = 1; count <= repeatCount; count++)
{
for(ledNumber = 8; ledNumber >= 2; ledNumber--)
{
fade.up(fadeSpeed, ledNumber);
if (fade.delayAndCheckForExit(onTime) == true) return; // check knob during on time
fade.down(fadeSpeed, ledNumber);
if (fade.delayAndCheckForExit(offTime) == true) return; // check knob during off time
}
for(ledNumber = 9; ledNumber <= 15; ledNumber++)
{
fade.up(fadeSpeed, ledNumber);
if (fade.delayAndCheckForExit(onTime) == true) return; // check knob during on time
fade.down(fadeSpeed, ledNumber);
if (fade.delayAndCheckForExit(offTime) == true) return; // check knob during off time
}
}
}
//
// alternate all the LEDs on the right and left using crossFade
//
void crossFadeRightAndLeft(int onTime, int waitTime, byte repeatCount, byte fadeSpeed)
{
byte count;
byte leftArray[7] = {2, 3, 4, 5, 6, 7, 8};
byte rightArray[7] = {9, 10, 11, 12, 13, 14, 15};
fade.up(fadeSpeed, rightArray, sizeof(rightArray));
if (fade.delayAndCheckForExit(onTime) == true) return; // check knob during on time
for(count = 1; count <= repeatCount; count++)
{
fade.crossFade(fadeSpeed, leftArray, sizeof(leftArray), rightArray, sizeof(rightArray)); // crossfade left up and right down
if (fade.delayAndCheckForExit(waitTime) == true) return; // check knob during wait time
fade.crossFade(fadeSpeed, rightArray, sizeof(rightArray), leftArray, sizeof(leftArray)); // crossfade right up and left down
if (fade.delayAndCheckForExit(waitTime) == true) return; // check knob during wait time
}
fade.down(fadeSpeed, rightArray, sizeof(rightArray)); // turn off all LEDs
}