Skip to content

Commit 40039bf

Browse files
committed
add hack to fix glitching on C3, added wiggle-room
the "wiggle room" is to not reset segments if min heap is just slightly underrun: alloc functions respect min heap, but UI or other functions may grab some extra heap, leading to unnecessary resets.
1 parent 70015bf commit 40039bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

wled00/wled.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,14 @@ void WLED::loop()
174174
#ifdef ESP8266
175175
uint32_t heap = getFreeHeapSize(); // ESP8266 needs ~8k of free heap for UI to work properly
176176
#else
177+
#ifdef CONFIG_IDF_TARGET_ESP32C3
178+
// calling getContiguousFreeHeap() during led update causes glitches on C3, this is a dirty workaround (tested up to 1500 LEDs)
179+
// this can (probably) be removed once RMT driver for C3 is fixed
180+
delay(15);
181+
#endif
177182
uint32_t heap = getContiguousFreeHeap(); // ESP32 family needs ~10k of contiguous free heap for UI to work properly
178183
#endif
179-
if (heap < MIN_HEAP_SIZE) heapDanger++;
184+
if (heap < MIN_HEAP_SIZE - 1024) heapDanger++; // allow 1k of "wiggle room" for things that do not respect min heap limits
180185
else heapDanger = 0;
181186
switch (heapDanger) {
182187
case 15: // 15 consecutive seconds

0 commit comments

Comments
 (0)