diff --git a/fantemp/terminal.hpp b/fantemp/terminal.hpp index e60bedd..0e9198d 100644 --- a/fantemp/terminal.hpp +++ b/fantemp/terminal.hpp @@ -19,8 +19,10 @@ GF(SHOW_CMD, "show"); GF(CURVE_CMD, "curve"); GF(MONITOR_CMD, "monitor"); GF(BOOTLOADER_CMD, "bootloader"); +GF(UPTIME_CMD, "uptime"); + GF(VERSION_CMD, "version"); -GF(VERSION, "1.2"); +GF(VERSION, "1.3"); static inline bool substringEquals(const char *str, const ::detail::FlashString *flashStr, const size_t &size) { @@ -137,6 +139,8 @@ class Terminal { m_state = State::MONITOR; } else if (substringEquals(m_inputBuffer, detail::BOOTLOADER_CMD, m_inputSize)) { handleBootloader(); + } else if (substringEquals(m_inputBuffer, detail::UPTIME_CMD, m_inputSize)) { + printUptime(); } else if (substringEquals(m_inputBuffer, detail::VERSION_CMD, m_inputSize)) { printVersion(); } else { @@ -164,6 +168,7 @@ class Terminal { m_serial << detail::CURVE_CMD << F(" ......: shows mapping from temperature to fan speed") << detail::ENDL; m_serial << detail::MONITOR_CMD << F(" ....: loops the show command until Ctrl + C is pressed") << detail::ENDL; m_serial << detail::BOOTLOADER_CMD << F(" .: enters the bootloader after 3 seconds") << detail::ENDL; + m_serial << detail::UPTIME_CMD << F(" .....: show system uptime") << detail::ENDL; m_serial << detail::VERSION_CMD << F(" ....: displays firmware version") << detail::ENDL; } @@ -203,6 +208,25 @@ class Terminal { Bootloader::enter(); } + static void printUptime() + { + constexpr auto delimiter = ':'; + + const auto uptime = clk::millis(); + + const auto hours = static_cast(uptime / 1000 / 60 / 60); + const auto minutes = static_cast((uptime / 1000 / 60) % 60); + const auto seconds = static_cast((uptime / 1000) % 60); + + m_serial << F("System uptime: "); + m_serial.template txNumber(hours); + m_serial << delimiter; + m_serial.template txNumber(minutes); + m_serial << delimiter; + m_serial.template txNumber(seconds); + m_serial << detail::ENDL; + } + static void printVersion() { m_serial << F("FanTemp v") << detail::VERSION << detail::ENDL; diff --git a/fantemp/uart b/fantemp/uart index cb436b1..6f592dd 160000 --- a/fantemp/uart +++ b/fantemp/uart @@ -1 +1 @@ -Subproject commit cb436b11a8428c2c40a11b51fedb4d2c7d38ece7 +Subproject commit 6f592dd0987cae4f7f826056e5ff358ad26d3127