Adding diagnostics
This commit is contained in:
@@ -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];
|
||||
}
|
||||
Reference in New Issue
Block a user