diff --git a/fantemp/terminal.hpp b/fantemp/terminal.hpp index 4cf5c03..a6a20f0 100644 --- a/fantemp/terminal.hpp +++ b/fantemp/terminal.hpp @@ -14,6 +14,9 @@ GF(ENDL, "\r\n"); GF(HELP_CMD, "help"); GF(SHOW_CMD, "show"); +constexpr auto BACKSPACE = uint8_t{0x7f}; +constexpr auto CTRL_C = uint8_t{0x03}; + template class Terminal { public: @@ -30,11 +33,11 @@ class Terminal { bool handleInput = false; while (m_serial.rxByte(inputByte)) { - if (isprint(inputByte) || inputByte == 0x03) { + if (isprint(inputByte) || inputByte == CTRL_C) { m_inputBuffer[m_inputSize++] = inputByte; // Handle Ctrl + C - if (inputByte == 0x03) { + if (inputByte == CTRL_C) { m_serial << F("^C") << ENDL; handleInput = true; break; @@ -46,8 +49,8 @@ class Terminal { } // Handle backspace - if (inputByte == 0x7f && m_inputSize > 0) { - m_serial << static_cast(0x7f); + if (inputByte == BACKSPACE && m_inputSize > 0) { + m_serial << static_cast(BACKSPACE); --m_inputSize; } // Handle line terminator