Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a7213de60 | ||
|
|
ed2fddc427 |
No files matched your search
@@ -48,6 +48,14 @@ void Statistics::callback()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Statistics::reset()
|
||||||
|
{
|
||||||
|
for (uint8_t i = 0; i < TEMPERATURE_RANGE; ++i) {
|
||||||
|
m_temperatureHistogram[i] = 0;
|
||||||
|
g_eepTemperatureHistogram[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t Statistics::getMinTemperature()
|
uint8_t Statistics::getMinTemperature()
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < TEMPERATURE_RANGE; ++i) {
|
for (uint8_t i = 0; i < TEMPERATURE_RANGE; ++i) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class Statistics {
|
|||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void callback();
|
static void callback();
|
||||||
|
static void reset();
|
||||||
|
|
||||||
static uint8_t getMinTemperature();
|
static uint8_t getMinTemperature();
|
||||||
static uint8_t getMaxTemperature();
|
static uint8_t getMaxTemperature();
|
||||||
|
|||||||
+49
-15
@@ -22,10 +22,11 @@ GF(MONITOR_CMD, "monitor");
|
|||||||
GF(BOOTLOADER_CMD, "bootloader");
|
GF(BOOTLOADER_CMD, "bootloader");
|
||||||
GF(UPTIME_CMD, "uptime");
|
GF(UPTIME_CMD, "uptime");
|
||||||
GF(STATISTICS_CMD, "statistics");
|
GF(STATISTICS_CMD, "statistics");
|
||||||
|
GF(RESET_CMD, "reset");
|
||||||
GF(HISTOGRAM_CMD, "histogram");
|
GF(HISTOGRAM_CMD, "histogram");
|
||||||
|
|
||||||
GF(VERSION_CMD, "version");
|
GF(VERSION_CMD, "version");
|
||||||
GF(VERSION, "1.5");
|
GF(VERSION, "1.6");
|
||||||
|
|
||||||
static inline bool substringEquals(const char *str, const ::detail::FlashString *flashStr, const size_t &size)
|
static inline bool substringEquals(const char *str, const ::detail::FlashString *flashStr, const size_t &size)
|
||||||
{
|
{
|
||||||
@@ -149,6 +150,8 @@ class Terminal {
|
|||||||
printStatistics();
|
printStatistics();
|
||||||
} else if (substringEquals(m_inputBuffer, detail::HISTOGRAM_CMD, m_inputSize)) {
|
} else if (substringEquals(m_inputBuffer, detail::HISTOGRAM_CMD, m_inputSize)) {
|
||||||
printHistogram();
|
printHistogram();
|
||||||
|
} else if (stringEquals(m_inputBuffer, detail::RESET_CMD, m_inputSize)) {
|
||||||
|
handleReset();
|
||||||
} else if (substringEquals(m_inputBuffer, detail::VERSION_CMD, m_inputSize)) {
|
} else if (substringEquals(m_inputBuffer, detail::VERSION_CMD, m_inputSize)) {
|
||||||
printVersion();
|
printVersion();
|
||||||
} else {
|
} else {
|
||||||
@@ -179,6 +182,7 @@ class Terminal {
|
|||||||
m_serial << detail::UPTIME_CMD << F(" .....: shows system uptime") << detail::ENDL;
|
m_serial << detail::UPTIME_CMD << F(" .....: shows system uptime") << detail::ENDL;
|
||||||
m_serial << detail::STATISTICS_CMD << F(" .: prints overall statistics like min and max temp") << detail::ENDL;
|
m_serial << detail::STATISTICS_CMD << F(" .: prints overall statistics like min and max temp") << detail::ENDL;
|
||||||
m_serial << detail::HISTOGRAM_CMD << F(" ..: prints a histogram of the temperature") << detail::ENDL;
|
m_serial << detail::HISTOGRAM_CMD << F(" ..: prints a histogram of the temperature") << detail::ENDL;
|
||||||
|
m_serial << detail::RESET_CMD << F(" ......: resets statistics to 0 in EEPROM and RAM") << detail::ENDL;
|
||||||
m_serial << detail::VERSION_CMD << F(" ....: displays firmware version") << detail::ENDL;
|
m_serial << detail::VERSION_CMD << F(" ....: displays firmware version") << detail::ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,30 +247,60 @@ class Terminal {
|
|||||||
|
|
||||||
static void printStatistics()
|
static void printStatistics()
|
||||||
{
|
{
|
||||||
m_serial << F("Minimum temperature .: ") << Statistics::getMinTemperature() << F(" C") << detail::ENDL;
|
const auto minTemp = Statistics::getMinTemperature();
|
||||||
m_serial << F("Maximum temperature .: ") << Statistics::getMaxTemperature() << F(" C") << detail::ENDL;
|
const auto maxTemp = Statistics::getMaxTemperature();
|
||||||
|
|
||||||
|
m_serial << F("Minimum temperature .: ");
|
||||||
|
if (minTemp != Statistics::TEMPERATURE_RANGE) {
|
||||||
|
m_serial << minTemp << F(" C");
|
||||||
|
} else {
|
||||||
|
m_serial << F("Not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_serial << detail::ENDL << F("Maximum temperature .: ");
|
||||||
|
if (maxTemp != Statistics::TEMPERATURE_RANGE) {
|
||||||
|
m_serial << maxTemp << F(" C");
|
||||||
|
} else {
|
||||||
|
m_serial << F("Not available");
|
||||||
|
}
|
||||||
|
m_serial << detail::ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printHistogram()
|
static void printHistogram()
|
||||||
{
|
{
|
||||||
const auto totalSamples = Statistics::getTotalHistogramSamples();
|
const auto totalSamples = Statistics::getTotalHistogramSamples();
|
||||||
const auto maximumSamples = Statistics::getHighestHistogramSamples();
|
|
||||||
const auto normalizationFactor = (maximumSamples / 100 > 1) ? (maximumSamples / 100) : 1;
|
|
||||||
|
|
||||||
for (uint8_t t = Statistics::getMinTemperature(); t <= Statistics::getMaxTemperature(); ++t) {
|
if (totalSamples > 0) {
|
||||||
const auto histogramSamples = Statistics::getHistogram(t);
|
const auto maximumSamples = Statistics::getHighestHistogramSamples();
|
||||||
m_serial.template txNumber<uint8_t, 10, 2>(t);
|
auto normalizationFactor = (maximumSamples / 100 > 1) ? (maximumSamples / 100) : 1;
|
||||||
m_serial << F(" C = ");
|
|
||||||
m_serial.template txNumber<uint8_t, 10, 3, ' '>((histogramSamples * 100) / totalSamples);
|
while (maximumSamples / normalizationFactor > 100)
|
||||||
m_serial << F("%\t");
|
++normalizationFactor;
|
||||||
const auto normalizedSamples = static_cast<uint8_t>(histogramSamples / normalizationFactor);
|
|
||||||
for (uint8_t i = 0; i < normalizedSamples; ++i) {
|
for (uint8_t t = Statistics::getMinTemperature(); t <= Statistics::getMaxTemperature(); ++t) {
|
||||||
m_serial << '#';
|
const auto histogramSamples = Statistics::getHistogram(t);
|
||||||
|
m_serial.template txNumber<uint8_t, 10, 2>(t);
|
||||||
|
m_serial << F(" C = ");
|
||||||
|
m_serial.template txNumber<uint8_t, 10, 3, ' '>((histogramSamples * 100) / totalSamples);
|
||||||
|
m_serial << F("%\t");
|
||||||
|
const auto normalizedSamples = static_cast<uint8_t>(histogramSamples / normalizationFactor);
|
||||||
|
for (uint8_t i = 0; i < normalizedSamples; ++i) {
|
||||||
|
m_serial << '#';
|
||||||
|
}
|
||||||
|
m_serial << detail::ENDL;
|
||||||
}
|
}
|
||||||
m_serial << detail::ENDL;
|
} else {
|
||||||
|
m_serial << "There is no data yet!" << detail::ENDL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handleReset()
|
||||||
|
{
|
||||||
|
m_serial << F("Resetting statistics in EEPROM and RAM") << detail::ENDL;
|
||||||
|
Statistics::reset();
|
||||||
|
m_serial << F("Reset statistics") << detail::ENDL;
|
||||||
|
}
|
||||||
|
|
||||||
static void printVersion()
|
static void printVersion()
|
||||||
{
|
{
|
||||||
m_serial << F("FanTemp v") << detail::VERSION << detail::ENDL;
|
m_serial << F("FanTemp v") << detail::VERSION << detail::ENDL;
|
||||||
|
|||||||
Reference in new issue
Block a user