Skip to content

Commit 73d65fd

Browse files
Ooze Master 3000: add “splat map” for Erin’s project
1 parent 3d08309 commit 73d65fd

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

OozeMaster3000/OozeMaster3000.ino

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
#define GAMMA 2.6 // For linear brightness correction
2121
#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).
2525

2626
// NeoPXL8 pin numbers
2727
#if defined(ARDUINO_ADAFRUIT_FEATHER_RP2040_SCORPIO)
@@ -104,6 +104,14 @@ struct {
104104
// NeoPXL8 output 7 is normally reserved for ground splats
105105
// You CAN add an eighth drip here, but then will not get splats
106106
};
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 };
107115

108116
#ifdef USE_HDR
109117
Adafruit_NeoPXL8HDR *pixels = NULL;
@@ -132,7 +140,8 @@ void setup() {
132140
drip[i].eventDurationReal = (float)drip[i].eventDurationUsec / 1000000.0;
133141
drip[i].splatStartUsec = 0;
134142
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;
136145
// Randomize initial color:
137146
memcpy(drip[i].color, palette[random(drip[i].palette_min, drip[i].palette_max + 1)], sizeof palette[0]);
138147
memcpy(drip[i].splatColor, drip[i].color, sizeof palette[0]);
@@ -267,7 +276,7 @@ void loop() {
267276
dtUsec = t - drip[i].splatStartUsec; // Elapsed time, in microseconds, since start of splat
268277
if(dtUsec < drip[i].splatDurationUsec) {
269278
x = 1.0 - sqrt((float)dtUsec / (float)drip[i].splatDurationUsec);
270-
set(7, i, i, x);
279+
set(7, i, splatmap[i], x);
271280
}
272281
}
273282
}
@@ -322,7 +331,7 @@ void dripDraw(uint8_t dNum, float a, float b, bool fade) {
322331

323332
// Set one pixel to a given brightness level (0.0 to 1.0).
324333
// 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.
326335
void set(uint8_t strand, uint8_t d, uint8_t pixel, float brightness) {
327336
#if !defined(USE_HDR) // NeoPXL8HDR does its own gamma correction, else...
328337
brightness = pow(brightness, GAMMA);

0 commit comments

Comments
 (0)