Adding diagnostics

This commit is contained in:
2026-08-09 09:20:38 -06:00
parent 5b6b810efd
commit e411c934d5
8 changed files with 216 additions and 10 deletions
+41
View File
@@ -0,0 +1,41 @@
#include "diagnostics_state.h"
void DiagnosticsState::update()
{
current.timestamp = millis();
current.freeHeap =
ESP.getFreeHeap();
current.minimumFreeHeap =
ESP.getMinFreeHeap();
current.cpuFrequency =
ESP.getCpuFreqMHz();
history[historyIndex] = current;
historyIndex++;
if(historyIndex >= DIAGNOSTIC_HISTORY_SIZE)
{
historyIndex = 0;
}
}
DiagnosticSample DiagnosticsState::getCurrent()
{
return current;
}
DiagnosticSample DiagnosticsState::getHistory(uint8_t index)
{
if(index >= DIAGNOSTIC_HISTORY_SIZE)
{
return current;
}
return history[index];
}