1
0
MAX7456JSON/lib/CommandHandler/CommandHandler.h
Jens True 5a6d60eee0
All checks were successful
continuous-integration/drone/push Build is passing
Syntax error
2021-11-10 09:37:03 +00:00

58 lines
1.2 KiB
C++

/**
* @file CommandHandler.h
* @author Jens True (jens.chr.true@gmail.com)
* @brief CommandHandler Header
* @version 0.1
* @date 2021-11-10
*
* @copyright Copyright (c) 2021
*
*/
#ifndef COMMANDHANDLER_H
#define COMMANDHANDLER_H
#include "DisplayProxy.h"
/**
* Parse a JSON command and convert it into display command(s).
*/
class CommandHandler
{
public:
/**
* Constructor.
*
* @param display Takes an implementation of DisplayProxy through polymorphism.
*/
explicit CommandHandler(DisplayProxy *display);
/**
* Parse a command in JSON format
* @code{.json}
* To display a string
*
* {"cmd":"write","x": 2, "y": 10, "text":"Hello World"}
*
* or to clear the display
*
* {"cmd":"clear"}
* @endcode
*
* @param cmd String to parse
* @return True if the input was parsed correctly.
*/
bool parseJSON(const char *cmd);
private:
/**
* Internal helpers for printing debug strings
*/
void debugSerial(const char *text);
void debugSerial(const char *command, const char *text);
/**
* Display instance
*/
DisplayProxy *display;
};
#endif