1
0
MAX7456JSON/lib/CommandHandler/CommandHandler.h
Jens True 353f04fba5
All checks were successful
continuous-integration/drone/push Build is passing
Cleanup
2021-11-09 09:00:30 +00:00

48 lines
1014 B
C++

#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