@@ -60,11 +60,23 @@ typedef enum {
60
60
uint8_t palette[][3 ] = {
61
61
{ 0 , 255 , 0 }, // Bright green ectoplasm
62
62
};
63
+ #define NUM_COLORS (sizeof palette / sizeof palette[0 ])
63
64
// Note that color randomization does not pair well with the ICE_BRIGHTNESS
64
65
// effect; you'll probably want to pick one or the other: random colors
65
66
// (from palette) and no icicles, or fixed color (per strand or overall)
66
67
// with ice. Otherwise the color jump of the icicle looks bad and wrong.
67
68
69
+ // Optional "Carrie mode" -- if a pin is defined here, and a switch or button
70
+ // added between this pin and ground -- when active, each new drip is drawn
71
+ // using the last color in the palette table (and slowly returns to original
72
+ // color scheme when released). i.e. there might normally be pleasant wintry
73
+ // colors in the palette, then plop pure red at the end of the list and watch
74
+ // the fun unfold!
75
+ // #define CARRIE_PIN A2
76
+ // If you could use an extra ground pin for that, define that here; this
77
+ // is a signal ground only, for the switch, NOT for powering anything.
78
+ // #define CARRIE_GROUND A3
79
+
68
80
struct {
69
81
uint16_t length; // Length of NeoPixel strip IN PIXELS
70
82
uint16_t dribblePixel; // Index of pixel where dribble pauses before drop (0 to length-1)
@@ -103,7 +115,15 @@ int longestStrand = (N_DRIPS < 8) ? N_DRIPS : 0;
103
115
104
116
void setup () {
105
117
Serial.begin (9600 );
106
- randomSeed (analogRead (A0) + analogRead (A3));
118
+ randomSeed (analogRead (A0) + analogRead (A1));
119
+
120
+ #ifdef CARRIE_PIN
121
+ pinMode (CARRIE_PIN, INPUT_PULLUP);
122
+ #endif
123
+ #ifdef CARRIE_GROUND
124
+ pinMode (CARRIE_GROUND, OUTPUT);
125
+ digitalWrite (CARRIE_GROUND, LOW);
126
+ #endif
107
127
108
128
for (int i=0 ; i<N_DRIPS; i++) {
109
129
drip[i].mode = MODE_IDLE; // Start all drips in idle mode
@@ -116,6 +136,12 @@ void setup() {
116
136
// Randomize initial color:
117
137
memcpy (drip[i].color , palette[random (drip[i].palette_min , drip[i].palette_max + 1 )], sizeof palette[0 ]);
118
138
memcpy (drip[i].splatColor , drip[i].color , sizeof palette[0 ]);
139
+ #ifdef CARRIE_PIN
140
+ // If "Carrie" switch is on, override above color with last palette entry
141
+ if (!digitalRead (CARRIE_PIN)) {
142
+ memcpy (drip[i].color , palette[NUM_COLORS - 1 ], sizeof palette[0 ]);
143
+ }
144
+ #endif
119
145
}
120
146
121
147
#ifdef USE_HDR
@@ -154,6 +180,12 @@ void loop() {
154
180
drip[i].eventDurationReal = (float )drip[i].eventDurationUsec / 1000000.0 ;
155
181
// Randomize next drip color from palette settings:
156
182
memcpy (drip[i].color , palette[random (drip[i].palette_min , drip[i].palette_max + 1 )], sizeof palette[0 ]);
183
+ #ifdef CARRIE_PIN
184
+ // If "Carrie" switch is on, override color with last palette entry
185
+ if (!digitalRead (CARRIE_PIN)) {
186
+ memcpy (drip[i].color , palette[NUM_COLORS - 1 ], sizeof palette[0 ]);
187
+ }
188
+ #endif
157
189
break ;
158
190
case MODE_OOZING:
159
191
if (drip[i].dribblePixel ) { // If dribblePixel is nonzero...
0 commit comments