@@ -1289,6 +1289,9 @@ static uint16_t mode_fireworks_core(bool useaudio) {
12891289 if (valid1) { if (SEGMENT.is2D ()) SEGMENT.setPixelColorXY (SEGENV.aux0 %width, SEGENV.aux0 /width, sv1); else SEGMENT.setPixelColor (SEGENV.aux0 , sv1); } // restore spark color after blur
12901290 if (valid2) { if (SEGMENT.is2D ()) SEGMENT.setPixelColorXY (SEGENV.aux1 %width, SEGENV.aux1 /width, sv2); else SEGMENT.setPixelColor (SEGENV.aux1 , sv2); } // restore old spark color after blur
12911291
1292+ #if defined(ARDUINO_ARCH_ESP32)
1293+ random16_add_entropy (esp_random () & 0xFFFF ); // improve randomness (esp32)
1294+ #endif
12921295 if (addPixels) // WLEDMM
12931296 for (int i=0 ; i<max (1 , width/20 ); i++) {
12941297 if (random8 (myIntensity) == 0 ) { // WLEDMM
@@ -2615,6 +2618,13 @@ uint16_t ripple_base()
26152618 uint16_t maxRipples = min (1 + (SEGLEN >> 2 ), MAX_RIPPLES); // 56 max for 16 segment ESP8266
26162619 uint16_t dataSize = sizeof (ripple) * maxRipples;
26172620
2621+ const uint16_t cols = strip.isMatrix ? SEGMENT.virtualWidth () : 1 ;
2622+ const uint16_t rows = strip.isMatrix ? SEGMENT.virtualHeight () : SEGMENT.virtualLength ();
2623+ const int16_t maxDim = max (2 , (cols + rows) / 4 ); // WLEDMM
2624+ #if defined(ARDUINO_ARCH_ESP32)
2625+ random16_add_entropy (esp_random () & 0xFFFF ); // improve randomness (esp32)
2626+ #endif
2627+
26182628 if (!SEGENV.allocateData (dataSize)) return mode_static (); // allocation failed
26192629 if (SEGENV.call == 0 ) {SEGENV.setUpLeds (); SEGMENT.fill (BLACK);} // WLEDMM use lossless getPixelColor()
26202630
@@ -2638,7 +2648,9 @@ uint16_t ripple_base()
26382648 uint16_t cx = rippleorigin >> 8 ;
26392649 uint16_t cy = rippleorigin & 0xFF ;
26402650 uint8_t mag = scale8 (sin8_t ((propF>>2 )), amp);
2641- if (propI > 0 ) SEGMENT.drawCircle (cx, cy, propI, color_blend (SEGMENT.getPixelColorXY (cx + propI, cy), col, mag), true );
2651+ propI = min (propI, maxDim); // WLEDMM make sure that circles are visible
2652+ if ((propI > 0 ) && (unsigned (cx + propI) < cols) && (unsigned (cy) < rows)) // WLEDMM
2653+ SEGMENT.drawCircle (cx, cy, propI, color_blend (SEGMENT.getPixelColorXY (cx + propI, cy), col, mag), true );
26422654 } else
26432655 #endif
26442656 {
@@ -3687,6 +3699,9 @@ uint16_t mode_exploding_fireworks(void)
36873699
36883700 float gravity = -0 .0004f - (SEGMENT.speed /800000 .0f ); // m/s/s
36893701 gravity *= rows;
3702+ #if defined(ARDUINO_ARCH_ESP32)
3703+ random16_add_entropy (esp_random () & 0xFFFF ); // improves randonmess
3704+ #endif
36903705
36913706 if (SEGENV.aux0 < 2 ) { // FLARE
36923707 if (SEGENV.aux0 == 0 ) { // init flare
@@ -3708,7 +3723,7 @@ uint16_t mode_exploding_fireworks(void)
37083723 flare->pos += flare->vel ;
37093724 flare->posX += flare->velX ;
37103725 flare->pos = constrain (flare->pos , 0 , rows-1 );
3711- flare->posX = constrain (flare->posX , 0 , cols-strip.isMatrix );
3726+ flare->posX = constrain (flare->posX , 0 , cols-int ( strip.isMatrix ) );
37123727 flare->vel += gravity;
37133728 flare->col -= 2 ;
37143729 } else {
@@ -3738,10 +3753,10 @@ uint16_t mode_exploding_fireworks(void)
37383753 sparks[i].colIndex = random8 ();
37393754 sparks[i].vel *= flare->pos /rows; // proportional to height
37403755 sparks[i].velX *= strip.isMatrix ? flare->posX /cols : 0 ; // proportional to width
3741- sparks[i].vel *= -gravity *50 ;
3756+ sparks[i].vel *= -gravity *50 . 0f ;
37423757 }
37433758 // sparks[1].col = 345; // this will be our known spark
3744- *dying_gravity = gravity/2 ;
3759+ *dying_gravity = gravity/2 . 0f ;
37453760 SEGENV.aux0 = 3 ;
37463761 }
37473762
0 commit comments