mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-27 10:21:40 +00:00
Merge pull request #2210 from meshtastic/heap-reboot
move temporary reboot code to blink thread
This commit is contained in:
commit
ed155476ac
@ -1,9 +1,5 @@
|
|||||||
#include "OSThread.h"
|
#include "OSThread.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#ifdef HAS_SCREEN
|
|
||||||
#include "graphics/Screen.h"
|
|
||||||
#endif
|
|
||||||
#include "main.h"
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
namespace concurrency
|
namespace concurrency
|
||||||
@ -83,21 +79,12 @@ void OSThread::run()
|
|||||||
#endif
|
#endif
|
||||||
currentThread = this;
|
currentThread = this;
|
||||||
auto newDelay = runOnce();
|
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
|
#ifdef DEBUG_HEAP
|
||||||
|
auto newHeap = ESP.getFreeHeap();
|
||||||
if (newHeap < heap)
|
if (newHeap < heap)
|
||||||
LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
|
LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
|
||||||
if (heap < newHeap)
|
if (heap < newHeap)
|
||||||
LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
|
LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
runned();
|
runned();
|
||||||
|
11
src/main.cpp
11
src/main.cpp
@ -128,6 +128,17 @@ static int32_t ledBlinker()
|
|||||||
|
|
||||||
setLed(ledOn);
|
setLed(ledOn);
|
||||||
|
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
auto newHeap = ESP.getFreeHeap();
|
||||||
|
if (newHeap < 11000) {
|
||||||
|
LOG_DEBUG("\n\n====== heap too low [11000] -> reboot in 1s ======\n\n");
|
||||||
|
#ifdef HAS_SCREEN
|
||||||
|
screen->startRebootScreen();
|
||||||
|
#endif
|
||||||
|
rebootAtMsec = millis() + 900;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// have a very sparse duty cycle of LED being on, unless charging, then blink 0.5Hz square wave rate to indicate that
|
// have a very sparse duty cycle of LED being on, unless charging, then blink 0.5Hz square wave rate to indicate that
|
||||||
return powerStatus->getIsCharging() ? 1000 : (ledOn ? 1 : 1000);
|
return powerStatus->getIsCharging() ? 1000 : (ledOn ? 1 : 1000);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user