|
19 | 19 |
|
20 | 20 | #define GAMMA 2.6 // For linear brightness correction |
21 | 21 | #define G_CONST 9.806 // Standard acceleration due to gravity |
22 | | -// While the above G_CONST is correct for "real time" drips, you can dial it back |
23 | | -// for a more theatric effect / to slow down the drips like they've still got a |
24 | | -// syrupy "drool string" attached (try much lower values like 2.0 to 3.0). |
| 22 | +// While the above G_CONST is correct for "real time" drips, you can dial it |
| 23 | +// back for a more theatric effect / to slow the drips like they've still got |
| 24 | +// a syrupy "drool string" attached (try much lower values like 2.0 to 3.0). |
25 | 25 |
|
26 | 26 | // NeoPXL8 pin numbers |
27 | 27 | #if defined(ARDUINO_ADAFRUIT_FEATHER_RP2040_SCORPIO) |
@@ -104,6 +104,14 @@ struct { |
104 | 104 | // NeoPXL8 output 7 is normally reserved for ground splats |
105 | 105 | // You CAN add an eighth drip here, but then will not get splats |
106 | 106 | }; |
| 107 | +// There might be situations where the "splat" pixels are more easily |
| 108 | +// installed using a longer strand of fixed-spacing "pebble style" NeoPixels |
| 109 | +// rather than soldering up separate pixels for each one...and then lighting |
| 110 | +// up only specific pixels along that strand for splats, leaving the others |
| 111 | +// un-lit. This table holds indices for seven pixels along that strand |
| 112 | +// corresponding to the seven splats. Could also be used to reverse the |
| 113 | +// order of splat indices, etc. |
| 114 | +uint8_t splatmap[] = { 0, 1, 2, 3, 4, 5, 6 }; |
107 | 115 |
|
108 | 116 | #ifdef USE_HDR |
109 | 117 | Adafruit_NeoPXL8HDR *pixels = NULL; |
@@ -132,7 +140,8 @@ void setup() { |
132 | 140 | drip[i].eventDurationReal = (float)drip[i].eventDurationUsec / 1000000.0; |
133 | 141 | drip[i].splatStartUsec = 0; |
134 | 142 | drip[i].splatDurationUsec = 0; |
135 | | - if(drip[i].length > longestStrand) longestStrand = drip[i].length; |
| 143 | + if(drip[i].length > longestStrand) longestStrand = drip[i].length; |
| 144 | + if((splatmap[i] + 1) > longestStrand) longestStrand = splatmap[i] + 1; |
136 | 145 | // Randomize initial color: |
137 | 146 | memcpy(drip[i].color, palette[random(drip[i].palette_min, drip[i].palette_max + 1)], sizeof palette[0]); |
138 | 147 | memcpy(drip[i].splatColor, drip[i].color, sizeof palette[0]); |
@@ -267,7 +276,7 @@ void loop() { |
267 | 276 | dtUsec = t - drip[i].splatStartUsec; // Elapsed time, in microseconds, since start of splat |
268 | 277 | if(dtUsec < drip[i].splatDurationUsec) { |
269 | 278 | x = 1.0 - sqrt((float)dtUsec / (float)drip[i].splatDurationUsec); |
270 | | - set(7, i, i, x); |
| 279 | + set(7, i, splatmap[i], x); |
271 | 280 | } |
272 | 281 | } |
273 | 282 | } |
@@ -322,7 +331,7 @@ void dripDraw(uint8_t dNum, float a, float b, bool fade) { |
322 | 331 |
|
323 | 332 | // Set one pixel to a given brightness level (0.0 to 1.0). |
324 | 333 | // Strand # and drip # are BOTH passed in because "splats" are always |
325 | | -// on drip 7 but colors come from drip indices. |
| 334 | +// on strand 7 but colors come from drip indices. |
326 | 335 | void set(uint8_t strand, uint8_t d, uint8_t pixel, float brightness) { |
327 | 336 | #if !defined(USE_HDR) // NeoPXL8HDR does its own gamma correction, else... |
328 | 337 | brightness = pow(brightness, GAMMA); |
|
0 commit comments