58 lines
1.2 KiB
C++
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 |