Skip to content

Commit ac0e543

Browse files
committed
add suggested fixes
1 parent 49c40b5 commit ac0e543

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

wled00/FX.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)