@@ -32,17 +32,12 @@ static uint16_t breathIn[] = { 7, 14, 21, 28, 35,
3232 255, 255, 255, 255, 255,
3333 255, 255, 255, 255, 255};
3434
35- const int N_BREATH_OUT_FRAMES = 50;
36- static uint16_t breathOut[] = { 100, 97, 94, 91, 88,
37- 85, 82, 79, 76, 73,
38- 70, 67, 64, 61, 58,
39- 55, 52, 49, 46, 43,
40- 40, 37, 34, 31, 28,
41- 25, 22, 19, 16, 13,
42- 10, 7, 4, 1, 0,
43- 0, 0, 0, 0, 0,
44- 0, 0, 0, 0, 0,
45- 0, 0, 0, 0, 0};
35+ const int N_BREATH_OUT_FRAMES = 45;
36+ static uint16_t breathOut[] = { 255, 255, 255, 255, 255, 255, 255, 255, 255,
37+ 255, 255, 238, 231, 224, 217, 210, 203, 196,
38+ 189, 182, 175, 168, 161, 154, 147, 140, 133,
39+ 126, 119, 112, 105, 98, 91, 84, 77, 70, 63,
40+ 56, 49, 42, 35, 28, 21, 14, 7};
4641
4742static int breathFrames = N_BREATH_IN_FRAMES;
4843static uint16_t *breath = breathIn;
@@ -52,7 +47,7 @@ void setGradientPixelColor(uint16_t ledPosition, uint16_t step, float redRatio,
5247 float green = step * greenRatio;
5348 float red = step * redRatio;
5449 float blue = step * blueRatio;
55- arcada.pixels.setPixelColor(ledPosition, green, red , blue);
50+ arcada.pixels.setPixelColor(ledPosition, red, green , blue);
5651}
5752
5853void stepOrangeBlackGradient(uint16_t ledPosition, uint16_t step) {
@@ -79,49 +74,49 @@ void stepRedOrangeGradient(uint16_t ledPosition, uint16_t step) {
7974 int red = 255;
8075 float green = step * .647;
8176 int blue = 0;
82- arcada.pixels.setPixelColor(ledPosition, green, red , blue);
77+ arcada.pixels.setPixelColor(ledPosition, red, green , blue);
8378}
8479
8580void stepOrangeYellowGradient(uint16_t ledPosition, uint16_t step) {
8681 int red = 255;
8782 float green = 165 + (step % 90);
8883 int blue = 0;
89- arcada.pixels.setPixelColor(ledPosition, green, red , blue);
84+ arcada.pixels.setPixelColor(ledPosition, red, green , blue);
9085}
9186
9287void stepYellowGreenGradient(uint16_t ledPosition, uint16_t step) {
9388 int red = 255 - step * 2;
9489 float green = 255 - (step * 1.5);
9590 int blue = 0;
96- arcada.pixels.setPixelColor(ledPosition, green, red , blue);
91+ arcada.pixels.setPixelColor(ledPosition, red, green , blue);
9792}
9893
9994void stepGreenBlueGradient(uint16_t ledPosition, uint16_t step) {
10095 int red = 0;
10196 float green = 128 - step;
10297 int blue = step;
103- arcada.pixels.setPixelColor(ledPosition, green, red , blue);
98+ arcada.pixels.setPixelColor(ledPosition, red, green , blue);
10499}
105100
106101void stepBlueIndigoGradient(uint16_t ledPosition, uint16_t step) {
107102 int red = step;
108103 float green = 0;
109104 int blue = 255 - step;
110- arcada.pixels.setPixelColor(ledPosition, green, red , blue);
105+ arcada.pixels.setPixelColor(ledPosition, red, green , blue);
111106}
112107
113108void stepIndigoVioletGradient(uint16_t ledPosition, uint16_t step) {
114109 int red = 75+step;
115110 float green = step;
116111 int blue = 130+step;
117- arcada.pixels.setPixelColor(ledPosition, green, red , blue);
112+ arcada.pixels.setPixelColor(ledPosition, red, green , blue);
118113}
119114
120115void stepVioletRedGradient(uint16_t ledPosition, uint16_t step) {
121116 int red = 238+(step*.17);
122117 float green = 130 - step;
123118 int blue = 238 - (step * 2);
124- arcada.pixels.setPixelColor(ledPosition, green, red , blue);
119+ arcada.pixels.setPixelColor(ledPosition, red, green , blue);
125120}
126121
127122typedef void (*StepColorGradient)(uint16_t, uint16_t);
@@ -172,7 +167,7 @@ void advanceBreath(void)
172167 if(breath == breathIn) {
173168 breath = breathOut;
174169 breathFrames = N_BREATH_OUT_FRAMES;
175- breathGradient = &stepPurpleBlackGradient ;
170+ breathGradient = &stepRedBlackGradient ;
176171 }
177172 else {
178173 breath = breathIn;
@@ -186,10 +181,8 @@ void advanceBreath(void)
186181}
187182
188183void advanceHalloweenGradients(void) {
189- int i;
190- for(i = 0; i < arcada.pixels.numPixels(); i++) {
191- switch (colorIndex)
192- {
184+ for(int i = 0; i < arcada.pixels.numPixels(); i++) {
185+ switch (colorIndex) {
193186 case 0:
194187 stepOrangeBlackGradient(i, currentStep);
195188 break;
@@ -234,17 +227,17 @@ void advanceHeartBeat(void) {
234227 }
235228}
236229
237- void user_setup(void) {
238- lastBehaviorChange, lastWave, lastColorShift, lastRainbowColorShift = micros();
239- arcada.pixels.setBrightness(255);
240- advanceHalloweenGradients();
241- }
242-
243230void changeBehavior(int newBehavior, uint32_t timeOfChange) {
244231 currentBehavior = newBehavior;
245232 lastBehaviorChange = timeOfChange;
246233}
247234
235+ void user_setup(void) {
236+ lastBehaviorChange, lastWave, lastColorShift, lastRainbowColorShift = micros();
237+ arcada.pixels.setBrightness(255);
238+ advanceHalloweenGradients();
239+ changeBehavior(0, micros());
240+ }
248241
249242void user_loop(void) {
250243 uint8_t pressed_buttons = arcada.readButtons();
@@ -279,18 +272,16 @@ void user_loop(void) {
279272 case 3:
280273 advanceRainbowWalk();
281274 break;
282- case 20:
283- changeBehavior(0, elapsedSince);
284- break;
285275 default:
286276 arcada.pixels.fill(0, 0, 0);
287277 arcada.pixels.show();
288278 break;
289279 }
290280
291- if( elapsedSince - lastBehaviorChange > SAMPLE_TIME * 500 ) {
281+ if (( elapsedSince - lastBehaviorChange) > ( SAMPLE_TIME * 1000) ) {
292282 lastBehaviorChange = elapsedSince;
293283 currentBehavior++;
284+ currentBehavior %= 4;
294285 }
295286 }
296287}
0 commit comments