diff --git a/fantemp/statistics.cpp b/fantemp/statistics.cpp index 4af0cb9..915fc59 100644 --- a/fantemp/statistics.cpp +++ b/fantemp/statistics.cpp @@ -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() { for (uint8_t i = 0; i < TEMPERATURE_RANGE; ++i) { diff --git a/fantemp/statistics.hpp b/fantemp/statistics.hpp index e27c598..e9d19c5 100644 --- a/fantemp/statistics.hpp +++ b/fantemp/statistics.hpp @@ -8,6 +8,7 @@ class Statistics { static void init(); static void callback(); + static void reset(); static uint8_t getMinTemperature(); static uint8_t getMaxTemperature(); diff --git a/fantemp/terminal.hpp b/fantemp/terminal.hpp index ae4a22d..e9c7550 100644 --- a/fantemp/terminal.hpp +++ b/fantemp/terminal.hpp @@ -22,10 +22,11 @@ GF(MONITOR_CMD, "monitor"); GF(BOOTLOADER_CMD, "bootloader"); GF(UPTIME_CMD, "uptime"); GF(STATISTICS_CMD, "statistics"); +GF(RESET_CMD, "reset"); GF(HISTOGRAM_CMD, "histogram"); 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) { @@ -149,6 +150,8 @@ class Terminal { printStatistics(); } else if (substringEquals(m_inputBuffer, detail::HISTOGRAM_CMD, m_inputSize)) { printHistogram(); + } else if (stringEquals(m_inputBuffer, detail::RESET_CMD, m_inputSize)) { + handleReset(); } else if (substringEquals(m_inputBuffer, detail::VERSION_CMD, m_inputSize)) { printVersion(); } else { @@ -179,6 +182,7 @@ class Terminal { 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::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; } @@ -290,6 +294,13 @@ class Terminal { } } + 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() { m_serial << F("FanTemp v") << detail::VERSION << detail::ENDL;