fix: start web stats capture from boot on >=4MB PSRAM boards

This commit is contained in:
Jared Dohrman
2026-04-17 14:42:51 +10:00
parent 29aa60ea2f
commit 05fcffc838
4 changed files with 30 additions and 9 deletions
+18
View File
@@ -64,6 +64,14 @@ bool shouldUseLiveOnlyStats() {
#endif
}
bool hasBootAutoCapturePsram() {
#if defined(ESP32)
return psramFound() && ESP.getPsramSize() >= (4UL * 1024UL * 1024UL);
#else
return false;
#endif
}
template <typename T>
T* allocHistoryBuffer(size_t count) {
#if defined(ESP32)
@@ -291,6 +299,9 @@ void StatsHistory::begin(bool enabled, ArchiveStorage* archive) {
_enabled = enabled;
_next_summary_flush_ms = millis() + kSummaryFlushIntervalMs;
_next_event_flush_ms = millis() + kEventFlushIntervalMs;
if (_enabled && shouldAutoActivateFromBoot()) {
activate();
}
}
void StatsHistory::setArchive(ArchiveStorage* archive) {
@@ -315,6 +326,9 @@ void StatsHistory::setEnabled(bool enabled) {
_last_access_ms = 0;
_next_summary_flush_ms = millis() + kSummaryFlushIntervalMs;
_next_event_flush_ms = millis() + kEventFlushIntervalMs;
if (shouldAutoActivateFromBoot()) {
activate();
}
}
}
@@ -397,6 +411,10 @@ bool StatsHistory::supportsPersistence() const {
return !_live_only;
}
bool StatsHistory::shouldAutoActivateFromBoot() const {
return _enabled && !_live_only && hasBootAutoCapturePsram();
}
bool StatsHistory::isAccessActive(uint32_t now_ms) const {
if (!_live_only) {
return true;