@@ -642,45 +642,39 @@ static const char _data_FX_MODE_TWINKLE[] PROGMEM = "Twinkle@!,!;!,!;!;;m12=0";
642
642
* Dissolve function
643
643
*/
644
644
uint16_t dissolve (uint32_t color) {
645
- unsigned dataSize = (SEGLEN+ 7 ) >> 3 ; // 1 bit per LED
645
+ unsigned dataSize = sizeof ( uint32_t ) * SEGLEN;
646
646
if (!SEGENV.allocateData (dataSize)) return mode_static (); // allocation failed
647
+ uint32_t * pixels = reinterpret_cast <uint32_t *>(SEGENV.data );
647
648
648
649
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 );
650
651
SEGENV.aux0 = 1 ;
651
652
}
652
653
653
654
for (unsigned j = 0 ; j <= SEGLEN / 15 ; j++) {
654
655
if (hw_random8 () <= SEGMENT.intensity ) {
655
656
for (size_t times = 0 ; times < 10 ; times++) { // attempt to spawn a new pixel 10 times
656
657
unsigned i = hw_random16 (SEGLEN);
657
- unsigned index = i >> 3 ;
658
- unsigned bitNum = i & 0x07 ;
659
- bool fadeUp = bitRead (SEGENV.data [index ], bitNum);
660
658
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;
668
661
break ; // only spawn 1 new pixel per frame per 50 LEDs
669
662
}
670
663
} 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 ;
674
667
}
675
668
}
676
669
}
677
670
}
678
671
}
672
+ // fix for #4401
673
+ for (unsigned i = 0 ; i < SEGLEN; i++) SEGMENT.setPixelColor (i, pixels[i]);
679
674
680
675
if (SEGENV.step > (255 - SEGMENT.speed ) + 15U ) {
681
676
SEGENV.aux0 = !SEGENV.aux0 ;
682
677
SEGENV.step = 0 ;
683
- memset (SEGMENT.data , (SEGENV.aux0 ? 0xFF : 0 ), dataSize); // switch fading
684
678
} else {
685
679
SEGENV.step ++;
686
680
}
@@ -6577,7 +6571,7 @@ uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline.
6577
6571
int volumeRaw = *(int16_t *)um_data->u_data [1 ];
6578
6572
6579
6573
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
6581
6575
}
6582
6576
6583
6577
uint8_t secondHand = micros ()/(256 -SEGMENT.speed )/500 % 16 ;
@@ -7161,7 +7155,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
7161
7155
if (FFT_MajorPeak < 1 ) FFT_MajorPeak = 1 ; // log10(0) is "forbidden" (throws exception)
7162
7156
7163
7157
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
7165
7159
SEGENV.aux0 = 255 ;
7166
7160
SEGMENT.custom1 = *binNum;
7167
7161
SEGMENT.custom2 = *maxVol * 2 ;
@@ -7178,7 +7172,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
7178
7172
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.
7179
7173
if (FFT_MajorPeak < 182 .0f ) pixCol = 0 ; // handle underflow
7180
7174
7181
- int k = SEGLEN-1 ;
7175
+ unsigned k = SEGLEN-1 ;
7182
7176
if (samplePeak) {
7183
7177
pixels[k] = (uint32_t )CRGB (CHSV (92 ,92 ,92 ));
7184
7178
} else {
0 commit comments