2019-09-04 13:28:38 +00:00
|
|
|
#ifndef COMMANDHANDLER_H
|
|
|
|
#define COMMANDHANDLER_H
|
|
|
|
#include "DisplayProxy.h"
|
|
|
|
|
2021-10-28 14:44:20 +00:00
|
|
|
/**
|
2021-11-03 10:13:25 +00:00
|
|
|
* Parse a JSON command and convert it into display command(s)
|
2021-10-28 14:44:20 +00:00
|
|
|
*/
|
2019-09-04 13:28:38 +00:00
|
|
|
class CommandHandler
|
|
|
|
{
|
|
|
|
public:
|
2021-11-03 10:13:25 +00:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param display Takes an implementation of DisplayProxy through polymorphism.
|
|
|
|
*/
|
2021-10-28 11:50:57 +00:00
|
|
|
explicit CommandHandler(DisplayProxy *display);
|
2021-11-03 10:13:25 +00:00
|
|
|
/**
|
|
|
|
* Parse a command in JSON format
|
|
|
|
* @code{.json}
|
|
|
|
* {"cmd":"write","x": 2, "y": 10, "text":"Hello World"}
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* @param cmd String to parse
|
|
|
|
* @return True if the input was parsed correctly.
|
|
|
|
*/
|
|
|
|
bool parseJSON(const char *cmd);
|
2019-09-04 13:28:38 +00:00
|
|
|
private:
|
2021-11-03 10:13:25 +00:00
|
|
|
/**
|
|
|
|
* Internal helper for printing debug strings
|
|
|
|
*/
|
2019-09-04 13:28:38 +00:00
|
|
|
void debugWrite(int x, int y, const char *text);
|
|
|
|
DisplayProxy *display;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|