From 0e6285edf2d8f981ea36f568df9f793729e52e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 30 Nov 2022 09:52:28 +0100 Subject: [PATCH] add temp code for heap debugging. Disable -DDEBUG_HEAP for release builds. DEBUG_MSG output only for now. --- platformio.ini | 1 + src/Power.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/platformio.ini b/platformio.ini index dbddf7535..792f2f8b1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -55,6 +55,7 @@ build_flags = -Wno-missing-field-initializers -DRADIOLIB_EXCLUDE_MORSE -DRADIOLIB_EXCLUDE_RTTY -DRADIOLIB_EXCLUDE_SSTV + -DDEBUG_HEAP monitor_speed = 115200 diff --git a/src/Power.cpp b/src/Power.cpp index ec86adc94..83eceeadf 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -283,6 +283,9 @@ void Power::readPowerStatus() DEBUG_MSG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d\n", powerStatus2.getHasUSB(), powerStatus2.getIsCharging(), powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent()); newStatus.notifyObservers(&powerStatus2); +#ifdef DEBUG_HEAP + DEBUG_MSG("Heap status: %d/%d bytes free\n", ESP.getFreeHeap(), ESP.getHeapSize()); +#endif // If we have a battery at all and it is less than 10% full, force deep sleep if we have more than 3 low readings in a row // Supect fluctuating voltage on the RAK4631 to force it to deep sleep even if battery is at 85% after only a few days