@@ -642,45 +642,39 @@ static const char _data_FX_MODE_TWINKLE[] PROGMEM = "Twinkle@!,!;!,!;!;;m12=0";
642642 * Dissolve function
643643 */
644644uint16_t dissolve (uint32_t color) {
645- unsigned dataSize = (SEGLEN+ 7 ) >> 3 ; // 1 bit per LED
645+ unsigned dataSize = sizeof ( uint32_t ) * SEGLEN;
646646 if (!SEGENV.allocateData (dataSize)) return mode_static (); // allocation failed
647+ uint32_t * pixels = reinterpret_cast <uint32_t *>(SEGENV.data );
647648
648649 if (SEGENV.call == 0 ) {
649- memset (SEGMENT. data , 0xFF , dataSize); // start by fading pixels up
650+ for ( unsigned i = 0 ; i < SEGLEN; i++) pixels[i] = SEGCOLOR ( 1 );
650651 SEGENV.aux0 = 1 ;
651652 }
652653
653654 for (unsigned j = 0 ; j <= SEGLEN / 15 ; j++) {
654655 if (hw_random8 () <= SEGMENT.intensity ) {
655656 for (size_t times = 0 ; times < 10 ; times++) { // attempt to spawn a new pixel 10 times
656657 unsigned i = hw_random16 (SEGLEN);
657- unsigned index = i >> 3 ;
658- unsigned bitNum = i & 0x07 ;
659- bool fadeUp = bitRead (SEGENV.data [index], bitNum);
660658 if (SEGENV.aux0 ) { // dissolve to primary/palette
661- if (fadeUp) {
662- if (color == SEGCOLOR (0 )) {
663- SEGMENT.setPixelColor (i, SEGMENT.color_from_palette (i, true , PALETTE_SOLID_WRAP, 0 ));
664- } else {
665- SEGMENT.setPixelColor (i, color);
666- }
667- bitWrite (SEGENV.data [index], bitNum, false );
659+ if (pixels[i] == SEGCOLOR (1 )) {
660+ pixels[i] = color == SEGCOLOR (0 ) ? SEGMENT.color_from_palette (i, true , PALETTE_SOLID_WRAP, 0 ) : color;
668661 break ; // only spawn 1 new pixel per frame per 50 LEDs
669662 }
670663 } else { // dissolve to secondary
671- if (!fadeUp ) {
672- SEGMENT. setPixelColor (i, SEGCOLOR (1 )); break ;
673- bitWrite (SEGENV. data [index], bitNum, true ) ;
664+ if (pixels[i] != SEGCOLOR ( 1 ) ) {
665+ pixels[i] = SEGCOLOR (1 );
666+ break ;
674667 }
675668 }
676669 }
677670 }
678671 }
672+ // fix for #4401
673+ for (unsigned i = 0 ; i < SEGLEN; i++) SEGMENT.setPixelColor (i, pixels[i]);
679674
680675 if (SEGENV.step > (255 - SEGMENT.speed ) + 15U ) {
681676 SEGENV.aux0 = !SEGENV.aux0 ;
682677 SEGENV.step = 0 ;
683- memset (SEGMENT.data , (SEGENV.aux0 ? 0xFF : 0 ), dataSize); // switch fading
684678 } else {
685679 SEGENV.step ++;
686680 }
@@ -6577,7 +6571,7 @@ uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline.
65776571 int volumeRaw = *(int16_t *)um_data->u_data [1 ];
65786572
65796573 if (SEGENV.call == 0 ) {
6580- for (int i = 0 ; i < SEGLEN; i++) pixels[i] = BLACK; // may not be needed as resetIfRequired() clears buffer
6574+ for (unsigned i = 0 ; i < SEGLEN; i++) pixels[i] = BLACK; // may not be needed as resetIfRequired() clears buffer
65816575 }
65826576
65836577 uint8_t secondHand = micros ()/(256 -SEGMENT.speed )/500 % 16 ;
@@ -7161,7 +7155,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
71617155 if (FFT_MajorPeak < 1 ) FFT_MajorPeak = 1 ; // log10(0) is "forbidden" (throws exception)
71627156
71637157 if (SEGENV.call == 0 ) {
7164- for (int i = 0 ; i < SEGLEN; i++) pixels[i] = BLACK; // may not be needed as resetIfRequired() clears buffer
7158+ for (unsigned i = 0 ; i < SEGLEN; i++) pixels[i] = BLACK; // may not be needed as resetIfRequired() clears buffer
71657159 SEGENV.aux0 = 255 ;
71667160 SEGMENT.custom1 = *binNum;
71677161 SEGMENT.custom2 = *maxVol * 2 ;
@@ -7178,7 +7172,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
71787172 uint8_t pixCol = (log10f (FFT_MajorPeak) - 2 .26f ) * 150 ; // 22Khz sampling - log10 frequency range is from 2.26 (182hz) to 3.967 (9260hz). Let's scale accordingly.
71797173 if (FFT_MajorPeak < 182 .0f ) pixCol = 0 ; // handle underflow
71807174
7181- int k = SEGLEN-1 ;
7175+ unsigned k = SEGLEN-1 ;
71827176 if (samplePeak) {
71837177 pixels[k] = (uint32_t )CRGB (CHSV (92 ,92 ,92 ));
71847178 } else {
0 commit comments