@@ -60,11 +60,23 @@ typedef enum {
6060uint8_t palette[][3 ] = {
6161 { 0 , 255 , 0 }, // Bright green ectoplasm
6262};
63+ #define NUM_COLORS (sizeof palette / sizeof palette[0 ])
6364// Note that color randomization does not pair well with the ICE_BRIGHTNESS
6465// effect; you'll probably want to pick one or the other: random colors
6566// (from palette) and no icicles, or fixed color (per strand or overall)
6667// with ice. Otherwise the color jump of the icicle looks bad and wrong.
6768
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+
6880struct {
6981 uint16_t length; // Length of NeoPixel strip IN PIXELS
7082 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;
103115
104116void setup () {
105117 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
107127
108128 for (int i=0 ; i<N_DRIPS; i++) {
109129 drip[i].mode = MODE_IDLE; // Start all drips in idle mode
@@ -116,6 +136,12 @@ void setup() {
116136 // Randomize initial color:
117137 memcpy (drip[i].color , palette[random (drip[i].palette_min , drip[i].palette_max + 1 )], sizeof palette[0 ]);
118138 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
119145 }
120146
121147#ifdef USE_HDR
@@ -154,6 +180,12 @@ void loop() {
154180 drip[i].eventDurationReal = (float )drip[i].eventDurationUsec / 1000000.0 ;
155181 // Randomize next drip color from palette settings:
156182 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
157189 break ;
158190 case MODE_OOZING:
159191 if (drip[i].dribblePixel ) { // If dribblePixel is nonzero...
0 commit comments