move temporary reboot code to blink thread

This commit is contained in:
Thomas Göttgens
2023-01-27 14:46:53 +01:00
parent d14bd652eb
commit 61028293b8
2 changed files with 12 additions and 14 deletions

View File

@@ -1,9 +1,5 @@
#include "OSThread.h"
#include "configuration.h"
#ifdef HAS_SCREEN
#include "graphics/Screen.h"
#endif
#include "main.h"
#include <assert.h>
namespace concurrency
@@ -83,21 +79,12 @@ void OSThread::run()
#endif
currentThread = this;
auto newDelay = runOnce();
#ifdef ARCH_ESP32
auto newHeap = ESP.getFreeHeap();
if (newHeap < 10000) {
LOG_DEBUG("\n\n====== heap too low [10000] -> reboot in 5s ======\n\n");
#ifdef HAS_SCREEN
screen->startRebootScreen();
#endif
rebootAtMsec = millis() + 5000;
}
#ifdef DEBUG_HEAP
auto newHeap = ESP.getFreeHeap();
if (newHeap < heap)
LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
if (heap < newHeap)
LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
#endif
#endif
runned();