From 60878305fb866eb8ebcd66c6a94285bfdb0b265f Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Sat, 25 Oct 2025 00:53:25 +0200 Subject: [PATCH] debug code updates & fixes better output when using WLED_DEBUG_HEAP without WLED_DEBUG --- wled00/FXparticleSystem.cpp | 2 +- wled00/wled.cpp | 10 +++++----- wled00/wled.h | 2 +- wled00/wled00.ino | 13 +++++++------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/wled00/FXparticleSystem.cpp b/wled00/FXparticleSystem.cpp index 9e5162c8..908a1d46 100644 --- a/wled00/FXparticleSystem.cpp +++ b/wled00/FXparticleSystem.cpp @@ -1789,7 +1789,7 @@ uint32_t calculateNumberOfParticles1D(const uint32_t fraction, const bool isadva numberofParticles = numberofParticles < 20 ? 20 : numberofParticles; // 20 minimum //make sure it is a multiple of 4 for proper memory alignment (easier than using padding bytes) numberofParticles = (numberofParticles+3) & ~0x03; // note: with a separate particle buffer, this is probably unnecessary - PSPRINTLN(" calc numparticles:" + String(numberofParticles)) + PSPRINTLN(" calc numparticles:" + String(numberofParticles)); return numberofParticles; } diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 47826138..1842d6ad 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -382,13 +382,13 @@ void WLED::loop() #endif #ifdef WLED_DEBUG_HEAP if (millis() - debugTime > 4999 ) { // WLEDMM: Special case for debugging heap faster - DEBUG_PRINT(F("*** Free heap: ")); DEBUG_PRINT(heap_caps_get_free_size(0x1800)); - DEBUG_PRINT(F("\tLargest free block: ")); DEBUG_PRINT(heap_caps_get_largest_free_block(0x1800)); - DEBUG_PRINT(F(" *** \t\tArduino min free stack: ")); DEBUG_PRINT(uxTaskGetStackHighWaterMark(NULL)); + USER_PRINT(F("*** Free heap: ")); USER_PRINT(heap_caps_get_free_size(0x1800)); + USER_PRINT(F("\tLargest free block: ")); USER_PRINT(heap_caps_get_largest_free_block(0x1800)); + USER_PRINT(F(" *** \t\tArduino min free stack: ")); USER_PRINT(uxTaskGetStackHighWaterMark(NULL)); #if INCLUDE_xTaskGetHandle - DEBUG_PRINT(F(" TCP min free stack: ")); DEBUG_PRINT(wledmm_get_tcp_stacksize()); + USER_PRINT(F(" TCP min free stack: ")); USER_PRINT(wledmm_get_tcp_stacksize()); #endif - DEBUG_PRINTLN(F(" ***")); + USER_PRINTLN(F(" ***")); debugTime = millis(); } #endif // WLED_DEBUG_HEAP diff --git a/wled00/wled.h b/wled00/wled.h index ffd179fd..dd1ba6da 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -880,7 +880,7 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); #endif // debug macro variable definitions -#ifdef WLED_DEBUG +#if defined(WLED_DEBUG) || defined(WLED_DEBUG_HEAP) WLED_GLOBAL unsigned long debugTime _INIT(0); WLED_GLOBAL int lastWifiState _INIT(3); WLED_GLOBAL unsigned long wifiStateChangedTime _INIT(0); diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 83d3f959..087607ab 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -76,19 +76,20 @@ void setup() { void loop() __attribute__((used)); // needed for -flto void loop() { //WLEDMM show loops per second -#ifdef WLED_DEBUG +#if defined(WLED_DEBUG) || defined(WLED_DEBUG_HEAP) loopCounter++; //if (millis() - lastMillis >= 10000) { if (millis() - lastMillis >= 8000) { long delta = millis() - lastMillis; - if (delta > 0) { + if ((delta > 0) && (loopCounter > 0)) { lps = (loopCounter*1000U) / delta; //if (delta > (showtime / 1000)) lps2 = (loopCounter*1000U) / (delta - (showtime / 1000)); - USER_PRINTF("%lu lps\t", lps); - USER_PRINTF("%u fps\t", strip.getFps()); + USER_PRINTF("%3lu lps %5.1fms \t", lps, float(delta) / float(loopCounter)); + USER_PRINTF("%3u fps\t\t", strip.getFps()); //USER_PRINTF("%lu lps without show\t\t", lps2); - USER_PRINTF("target frametime %dms\t", int(strip.getFrameTime())); - USER_PRINTF("target FPS %d\n", int(strip.getTargetFps())); + //USER_PRINTF("target frametime %dms\t", int(strip.getFrameTime())); + //USER_PRINTF("target FPS %d", int(strip.getTargetFps())); + USER_PRINTLN(""); } lastMillis = millis(); loopCounter = 0;