Skip to content

Commit 1273217

Browse files
committed
Debug tidy and added fragmentation
1 parent ebc1272 commit 1273217

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

wled00/wled.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,20 @@ void WLED::loop()
379379
#endif
380380
#ifdef WLED_DEBUG_HEAP
381381
if (millis() - debugTime > 4999 ) { // WLEDMM: Special case for debugging heap faster
382-
DEBUG_PRINT(F("*** Free heap: ")); DEBUG_PRINT(heap_caps_get_free_size(0x1800));
383-
DEBUG_PRINT(F("\tLargest free block: ")); DEBUG_PRINT(heap_caps_get_largest_free_block(0x1800));
384-
DEBUG_PRINT(F(" *** \t\tArduino min free stack: ")); DEBUG_PRINT(uxTaskGetStackHighWaterMark(NULL));
382+
size_t largest_free = heap_caps_get_largest_free_block(0x1800);
383+
size_t total_free = heap_caps_get_free_size(0x1800);
384+
DEBUG_PRINT(F("*** Free heap: ")); DEBUG_PRINT(total_free);
385+
DEBUG_PRINT(F(" - Largest free block: ")); DEBUG_PRINT(largest_free);
386+
float fragmentation = 100.0f;
387+
if ((largest_free > 1) && (total_free > largest_free)) {
388+
fragmentation = 100.f * (1.0f - (float(largest_free) / float(total_free)) );
389+
}
390+
DEBUG_PRINT(F(" (frag ")); DEBUG_PRINTF("%0.2f",fragmentation); DEBUG_PRINT(F("%)"));
391+
DEBUG_PRINT(F(" - Arduino min free stack: ")); DEBUG_PRINT(uxTaskGetStackHighWaterMark(NULL));
385392
#if INCLUDE_xTaskGetHandle
386-
DEBUG_PRINT(F(" TCP min free stack: ")); DEBUG_PRINT(wledmm_get_tcp_stacksize());
393+
DEBUG_PRINT(F(" - TCP min free stack: ")); DEBUG_PRINT(wledmm_get_tcp_stacksize());
387394
#endif
395+
388396
DEBUG_PRINTLN(F(" ***"));
389397
debugTime = millis();
390398
}

0 commit comments

Comments
 (0)