From a33a764b1d1f1de2c1523c09b865be6fe78715d2 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Wed, 1 Apr 2020 02:41:09 +0200 Subject: [PATCH] Add parsing and handling of help command --- fantemp/terminal.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fantemp/terminal.hpp b/fantemp/terminal.hpp index 8b10923..a0fd3a6 100644 --- a/fantemp/terminal.hpp +++ b/fantemp/terminal.hpp @@ -3,6 +3,8 @@ #include #include +#include + #include "flash/flash.hpp" #define ENDL F("\r\n") @@ -49,6 +51,7 @@ class Terminal { if (m_serial.peek(inputByte) && (inputByte == '\r' || inputByte == '\n')) { m_serial.rxByte(inputByte); } + m_serial << ENDL; handleInput = true; break; } @@ -63,7 +66,7 @@ class Terminal { if (handleInput) { parseInput(); m_inputSize = 0; - m_serial << ENDL << F("$ "); + m_serial << F("$ "); } } @@ -74,7 +77,18 @@ class Terminal { static char m_inputBuffer[INPUT_BUFFER_SIZE]; static uint16_t m_inputSize; - static void parseInput() {} + static void parseInput() + { + if (m_inputSize && strncmp_P(m_inputBuffer, reinterpret_cast(F("help")), m_inputSize) == 0) { + printHelp(); + } + } + + static void printHelp() + { + m_serial << F("Help: ") << ENDL; + m_serial << F("help .: print this help message") << ENDL; + } }; template