File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -665,6 +665,12 @@ uint16_t mode_twinkle(void) {
665665 // Cycle mode: randomly switch all LEDs to new color, then back to old color
666666 if (SEGMENT.check1 )
667667 {
668+ // tiny segments: no cycling needed, avoid bitset allocation
669+ if (SEGLEN <= 1 )
670+ {
671+ return mode_static ();
672+ }
673+
668674 unsigned dataSize = (SEGLEN + 7 ) >> 3 ; // 1 bit per LED for tracking
669675 if ( ! SEGENV.allocateData (dataSize))
670676 {
@@ -675,7 +681,7 @@ uint16_t mode_twinkle(void) {
675681 uint32_t it = strip.now / cycleTime;
676682
677683 // Initialize on first call
678- if (SEGENV.call == 0 )
684+ if (( SEGENV.call == 0 ) || (SEGENV. aux1 > 1 ))
679685 {
680686 SEGENV.aux0 = 0 ; // Count of LEDs switched in current cycle
681687 SEGENV.aux1 = 0 ; // Direction: 0 = switching to new color, 1 = switching back
You can’t perform that action at this time.
0 commit comments