Add monitor command to continuously show measurements
This commit is contained in:
parent
d6fa78ae5f
commit
6003ea6603
@ -14,6 +14,7 @@ GF(ENDL, "\r\n");
|
|||||||
GF(HELP_CMD, "help");
|
GF(HELP_CMD, "help");
|
||||||
GF(SHOW_CMD, "show");
|
GF(SHOW_CMD, "show");
|
||||||
GF(CURVE_CMD, "curve");
|
GF(CURVE_CMD, "curve");
|
||||||
|
GF(MONITOR_CMD, "monitor");
|
||||||
|
|
||||||
constexpr auto BACKSPACE = uint8_t{0x7f};
|
constexpr auto BACKSPACE = uint8_t{0x7f};
|
||||||
constexpr auto CTRL_C = uint8_t{0x03};
|
constexpr auto CTRL_C = uint8_t{0x03};
|
||||||
@ -77,14 +78,23 @@ class Terminal {
|
|||||||
m_inputSize = 0;
|
m_inputSize = 0;
|
||||||
m_serial << F("$ ");
|
m_serial << F("$ ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_state == State::MONITOR)
|
||||||
|
showState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr auto INPUT_BUFFER_SIZE = 128;
|
static constexpr auto INPUT_BUFFER_SIZE = 128;
|
||||||
|
|
||||||
|
enum class State {
|
||||||
|
NONE,
|
||||||
|
MONITOR,
|
||||||
|
};
|
||||||
|
|
||||||
static Uart m_serial;
|
static Uart m_serial;
|
||||||
static char m_inputBuffer[INPUT_BUFFER_SIZE];
|
static char m_inputBuffer[INPUT_BUFFER_SIZE];
|
||||||
static uint16_t m_inputSize;
|
static uint16_t m_inputSize;
|
||||||
|
static State m_state;
|
||||||
|
|
||||||
static void parseInput()
|
static void parseInput()
|
||||||
{
|
{
|
||||||
@ -97,6 +107,8 @@ class Terminal {
|
|||||||
showState();
|
showState();
|
||||||
} else if (strncmp_P(m_inputBuffer, reinterpret_cast<const char *>(CURVE_CMD), m_inputSize) == 0) {
|
} else if (strncmp_P(m_inputBuffer, reinterpret_cast<const char *>(CURVE_CMD), m_inputSize) == 0) {
|
||||||
printCurve();
|
printCurve();
|
||||||
|
} else if (strncmp_P(m_inputBuffer, reinterpret_cast<const char *>(MONITOR_CMD), m_inputSize) == 0) {
|
||||||
|
m_state = State::MONITOR;
|
||||||
} else {
|
} else {
|
||||||
printUnknown();
|
printUnknown();
|
||||||
}
|
}
|
||||||
@ -106,14 +118,16 @@ class Terminal {
|
|||||||
static void handleCtrlC()
|
static void handleCtrlC()
|
||||||
{
|
{
|
||||||
m_serial << F("Abort!") << ENDL;
|
m_serial << F("Abort!") << ENDL;
|
||||||
|
m_state = State::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printHelp()
|
static void printHelp()
|
||||||
{
|
{
|
||||||
m_serial << F("FanTemp command overview: ") << ENDL;
|
m_serial << F("FanTemp command overview: ") << ENDL;
|
||||||
m_serial << HELP_CMD << F(" ..: print this help message") << ENDL;
|
m_serial << HELP_CMD << F(" ....: print this help message") << ENDL;
|
||||||
m_serial << SHOW_CMD << F(" ..: shows current temperature and fan speed") << ENDL;
|
m_serial << SHOW_CMD << F(" ....: shows current temperature and fan speed") << ENDL;
|
||||||
m_serial << CURVE_CMD << F(" .: shows the curve used to map temperature to fan speed") << ENDL;
|
m_serial << CURVE_CMD << F(" ...: shows the curve used to map temperature to fan speed") << ENDL;
|
||||||
|
m_serial << MONITOR_CMD << F(" .: loops the show command until Ctrl + C is pressed") << ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showState()
|
static void showState()
|
||||||
@ -156,3 +170,6 @@ char Terminal<Uart>::m_inputBuffer[INPUT_BUFFER_SIZE];
|
|||||||
|
|
||||||
template <class Uart>
|
template <class Uart>
|
||||||
uint16_t Terminal<Uart>::m_inputSize = 0;
|
uint16_t Terminal<Uart>::m_inputSize = 0;
|
||||||
|
|
||||||
|
template <class Uart>
|
||||||
|
typename Terminal<Uart>::State Terminal<Uart>::m_state = State::NONE;
|
||||||
|
Loading…
Reference in New Issue
Block a user